Skip to content
This repository has been archived by the owner on Oct 23, 2022. It is now read-only.

Commit

Permalink
swear fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
djetelina committed May 19, 2016
1 parent 0c60334 commit f7bc859
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions cogs/swear.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ def __init__(self, user, bot):
self.user = user
self.bot = bot
self.points = 0
self.warnings = ["Please don't swear!", "Don't swear, thanks!"]
watchlist.update({self.user: self})
self.new()

def new(self):
self.points += 1
self.point_check()
loop.create_task(self.decay)
loop.create_task(self.decay())

async def decay(self):
time = 120
Expand All @@ -37,12 +38,12 @@ async def decay(self):

def point_check(self):
if self.points >= 3:
loop.create_task(self.warn_user)
loop.create_task(self.warn_user())
elif self.points == 0:
del watchlist[self.user]

async def warn_user(self):
s.whisper(self.user, "I'm warning you", self.bot)
await s.whisper(self.user, random.choice(self.warnings), self.bot)


class Swear:
Expand All @@ -57,21 +58,21 @@ async def message(self, message):
self.check_grey(message)
self.check_black(message)

async def check_grey(self, message):
def check_grey(self, message):
for word in self.greylist:
if word in message.content:
self.trigger(message)
return

async def check_black(self, message):
def check_black(self, message):
for word in self.blacklist:
if word in message.content:
self.trigger(message)
return

async def trigger(self, message):
def trigger(self, message):
if message.author in watchlist:
watchlist['message.author'].new()
watchlist[message.author].new()
else:
Warns(message.author, self.bot)

Expand Down
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async def on_message(message):
swear = bot.get_cog('Swear')

if swear is not None:
await swear.message(bot, message)
await swear.message(message)

await bot.process_commands(message)

Expand Down

0 comments on commit f7bc859

Please sign in to comment.