Skip to content

Commit 1d92923

Browse files
committed
show how many seconds by which you missed !bef/!bang
1 parent e9f6e8a commit 1d92923

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

modules/ducks.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from src import EventManager, ModuleManager, utils
66

77
DUCK = "・゜゜・。。・゜゜\_o< QUACK!"
8-
NO_DUCK = "There was no duck!"
98

109
DEFAULT_MIN_MESSAGES = 100
1110

@@ -66,6 +65,7 @@ def _send_duck(self, timer):
6665

6766
def _duck_action(self, channel, user, action, setting):
6867
duck_timestamp = channel.duck_active
68+
channel.set_setting("duck-last", time.time())
6969
channel.duck_active = None
7070

7171
user_id = user.get_id()
@@ -82,10 +82,16 @@ def _duck_action(self, channel, user, action, setting):
8282
channel.name)
8383

8484
def _no_duck(self, channel, user, stderr):
85+
message = "There was no duck!"
86+
duck_timestamp = channel.get_setting("duck-last", None)
87+
if not duck_timestamp == None:
88+
seconds = round(time.time()-duck_timestamp, 2)
89+
message += " missed by %s seconds" % seconds
90+
8591
if channel.get_setting("ducks-kick"):
86-
channel.send_kick(user.nickname, NO_DUCK)
92+
channel.send_kick(user.nickname, message)
8793
else:
88-
stderr.write("%s: %s" % (user.nickname, NO_DUCK))
94+
stderr.write("%s: %s" % (user.nickname, message))
8995

9096
@utils.hook("received.command.bef", alias_of="befriend")
9197
@utils.hook("received.command.befriend", channel_only=True)

0 commit comments

Comments
 (0)