show how many seconds by which you missed !bef/!bang
This commit is contained in:
parent
e9f6e8a06a
commit
1d92923a77
1 changed files with 9 additions and 3 deletions
|
@ -5,7 +5,6 @@ import random, re, time
|
||||||
from src import EventManager, ModuleManager, utils
|
from src import EventManager, ModuleManager, utils
|
||||||
|
|
||||||
DUCK = "・゜゜・。。・゜゜\_o< QUACK!"
|
DUCK = "・゜゜・。。・゜゜\_o< QUACK!"
|
||||||
NO_DUCK = "There was no duck!"
|
|
||||||
|
|
||||||
DEFAULT_MIN_MESSAGES = 100
|
DEFAULT_MIN_MESSAGES = 100
|
||||||
|
|
||||||
|
@ -66,6 +65,7 @@ class Module(ModuleManager.BaseModule):
|
||||||
|
|
||||||
def _duck_action(self, channel, user, action, setting):
|
def _duck_action(self, channel, user, action, setting):
|
||||||
duck_timestamp = channel.duck_active
|
duck_timestamp = channel.duck_active
|
||||||
|
channel.set_setting("duck-last", time.time())
|
||||||
channel.duck_active = None
|
channel.duck_active = None
|
||||||
|
|
||||||
user_id = user.get_id()
|
user_id = user.get_id()
|
||||||
|
@ -82,10 +82,16 @@ class Module(ModuleManager.BaseModule):
|
||||||
channel.name)
|
channel.name)
|
||||||
|
|
||||||
def _no_duck(self, channel, user, stderr):
|
def _no_duck(self, channel, user, stderr):
|
||||||
|
message = "There was no duck!"
|
||||||
|
duck_timestamp = channel.get_setting("duck-last", None)
|
||||||
|
if not duck_timestamp == None:
|
||||||
|
seconds = round(time.time()-duck_timestamp, 2)
|
||||||
|
message += " missed by %s seconds" % seconds
|
||||||
|
|
||||||
if channel.get_setting("ducks-kick"):
|
if channel.get_setting("ducks-kick"):
|
||||||
channel.send_kick(user.nickname, NO_DUCK)
|
channel.send_kick(user.nickname, message)
|
||||||
else:
|
else:
|
||||||
stderr.write("%s: %s" % (user.nickname, NO_DUCK))
|
stderr.write("%s: %s" % (user.nickname, message))
|
||||||
|
|
||||||
@utils.hook("received.command.bef", alias_of="befriend")
|
@utils.hook("received.command.bef", alias_of="befriend")
|
||||||
@utils.hook("received.command.befriend", channel_only=True)
|
@utils.hook("received.command.befriend", channel_only=True)
|
||||||
|
|
Loading…
Reference in a new issue