Skip to content

Commit

Permalink
Merge pull request #33 from morenod/0.6.X
Browse files Browse the repository at this point in the history
correct calc of silence if not defined or past value
  • Loading branch information
morenod authored Aug 5, 2017
2 parents adddc84 + a090d0c commit 42e1cf5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions punsbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

allowed_chars_puns = string.ascii_letters + " " + string.digits + "áéíóúàèìòùäëïöü"
allowed_chars_triggers = allowed_chars_puns + "^$.*+?(){}\\[]<>=-"
version = "0.6.0"
version = "0.6.1"
required_validations = 5

if 'TOKEN' not in os.environ:
Expand Down Expand Up @@ -172,7 +172,9 @@ def help(message):
Puns will be enabled if karma is over %s on groups with more than %s people.
On groups with less people, only positive karma is required
''' % (silence_until(message.chat.id), efectivity(message.chat.id), required_validations, required_validations)
Version: %s
''' % (silence_until(message.chat.id), efectivity(message.chat.id), required_validations, required_validations, version)
bot.reply_to(message, helpmessage)


Expand Down Expand Up @@ -299,7 +301,10 @@ def silence(message):
bot.reply_to(message, 'Disabling PunsBot for more than one hour is not funny 😢')
return
chatoptions = load_chat_options(message.chat.id)
chatoptions['silence'] = 60 * int(quote) + int((chatoptions['silence']) if chatoptions['silence'] is not None else int(time.time()))
if chatoptions['silence'] is None or int(chatoptions['silence']) <= int(time.time()):
chatoptions['silence'] = 60 * int(quote) + int(time.time())
else:
chatoptions['silence'] = 60 * int(quote) + int(chatoptions['silence'])
set_chat_options(chatoptions)
bot.reply_to(message, 'PunsBot will be muted until ' + time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(chatoptions['silence'])))

Expand Down

0 comments on commit 42e1cf5

Please sign in to comment.