diff options
| author | Mistivia <i@mistivia.com> | 2025-10-30 16:44:08 +0800 |
|---|---|---|
| committer | Mistivia <i@mistivia.com> | 2025-10-30 16:44:08 +0800 |
| commit | c48b1a9889cb0903d76e5e2fad1d8fc3647232f0 (patch) | |
| tree | c3ce9fd840d3029521a6189cd4faacdd9668ff16 /ircbot/main.py | |
| parent | 3a39be2a4ccccfaf0fc3408849d8c003a8702385 (diff) | |
fix too much greetings
Diffstat (limited to 'ircbot/main.py')
| -rw-r--r-- | ircbot/main.py | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/ircbot/main.py b/ircbot/main.py index 8b1e214..7c15096 100644 --- a/ircbot/main.py +++ b/ircbot/main.py @@ -6,6 +6,7 @@ import json import os import datetime import urllib.parse +import hashlib config = None with open('./config.json', 'r', encoding='utf-8') as f: @@ -30,8 +31,6 @@ def command(name): return func return decorator -# ================================================ - @command("help") def help_cmd(chan, sender, args): return """命令列表: @@ -41,17 +40,40 @@ def help_cmd(chan, sender, args): 4. 复读机:!say 复读内容 5. AI词典: !dict 单词 6. 查看聊天记录:!log + 7. 举办电话会议: !meet """ + +@command("meet") +def meet_cmd(chan, sender, args): + data_to_hash = SERVER + chan + '#' + str(int(time.time()) // 120) + data_bytes = data_to_hash.encode('utf-8') + hash_object = hashlib.sha256() + hash_object.update(data_bytes) + hex_digest = hash_object.hexdigest() + return '加入会议: https://meet.jit.si/' + hex_digest[:24] + '#config.startWithVideoMuted=true' + @command("log") def log_command(chan, sender, args): return f"https://raye.mistivia.com/irclog/view/?chan={chan[1:]}" +LAST_SEEN = dict() + @command("join") def join_command(chan, sender, args): if sender == NICKNAME: return '' if not chan in GREETINGS: return '' + if sender in config['no_greeting_nicks']: + return '' + if chan in LAST_SEEN \ + and sender in LAST_SEEN[chan] \ + and time.time() - LAST_SEEN[chan][sender] < 900: + LAST_SEEN[chan][sender] = time.time() + return '' + if chan not in LAST_SEEN: + LAST_SEEN[chan] = dict() + LAST_SEEN[chan][sender] = time.time() return "Dōmo, " + sender + ' san.' @command("dict") |
