aboutsummaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2024-06-29 22:42:20 +0200
committerRobin Jarry <robin@jarry.cc>2024-07-02 22:00:28 +0200
commitbee2fc62ac7808cf081e58947023cd4c61c0109e (patch)
treeeaef11de98c014b08937a2dff39042d97a813283 /contrib
parent7a2372773ca870466029cf4137fde71082979a25 (diff)
downloadaerc-bee2fc62ac7808cf081e58947023cd4c61c0109e.tar.gz
ircbot: wait random delay before un-flipping tables
Unflipping tables instantly is not very considerate and certainly does not have the same emotional impact compared to waiting for a moment to digest the table flipping. Wait for a random period of time using a log normal distribution: | # | # # | # # | # # | # # | # # # | # # # # | # # # # | # # # # # | # # # # # # | # # # # # # # | # # # # # # # # | # # # # # # # # # # # # | # # # # # # # # # # # # # # # # . . . +----------------------------------------------------- 0 1 2 3 4 5 6 7 8 delay(seconds) Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Bence Ferdinandy <bence@ferdinandy.com>
Diffstat (limited to 'contrib')
-rw-r--r--contrib/ircbot/Karma/plugin.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/contrib/ircbot/Karma/plugin.py b/contrib/ircbot/Karma/plugin.py
index c82f0c7f..dbc64fca 100644
--- a/contrib/ircbot/Karma/plugin.py
+++ b/contrib/ircbot/Karma/plugin.py
@@ -33,6 +33,8 @@ import os
import re
import sys
import csv
+import time
+import random
import supybot.conf as conf
import supybot.utils as utils
@@ -42,6 +44,7 @@ import supybot.plugins as plugins
import supybot.ircmsgs as ircmsgs
import supybot.ircutils as ircutils
import supybot.callbacks as callbacks
+import supybot.schedule as schedule
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('Karma')
@@ -272,7 +275,17 @@ class Karma(callbacks.Plugin):
def _doKarma(self, irc, msg, channel, line):
match = self.TABLE_FLIP.match(line)
if match:
- irc.reply(f'┳━┳ノ(°_°ノ)')
+ event_name = f'unflip {msg.nic}'
+ try:
+ schedule.removeEvent(event_name)
+ except KeyError:
+ pass
+ schedule.addEvent(
+ irc.reply,
+ time.time() + random.lognormvariate(0.5, 0.5),
+ name=event_name,
+ args=['┳━┳ノ(°_°ノ)'],
+ )
return
inc = self.registryValue('incrementChars', channel, irc.network)