From bee2fc62ac7808cf081e58947023cd4c61c0109e Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Sat, 29 Jun 2024 22:42:20 +0200 Subject: 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 Reviewed-by: Bence Ferdinandy --- contrib/ircbot/Karma/plugin.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'contrib') 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) -- cgit