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 | |
| parent | 3a39be2a4ccccfaf0fc3408849d8c003a8702385 (diff) | |
fix too much greetings
Diffstat (limited to 'ircbot')
| -rw-r--r-- | ircbot/config.json.example | 3 | ||||
| -rw-r--r-- | ircbot/deploy.sh | 3 | ||||
| -rw-r--r-- | ircbot/main.py | 26 | ||||
| -rw-r--r-- | ircbot/topics | 1 |
4 files changed, 28 insertions, 5 deletions
diff --git a/ircbot/config.json.example b/ircbot/config.json.example index 7889331..b618f9b 100644 --- a/ircbot/config.json.example +++ b/ircbot/config.json.example @@ -9,6 +9,9 @@ "greetings": [ "#main" ], + "no_greeting_nicks": [ + "TelegramBridge" + ], "logpath": "/var/log/irclog", "relaybot": "TeleIRC" }
\ No newline at end of file diff --git a/ircbot/deploy.sh b/ircbot/deploy.sh index ea48acd..3b4ab46 100644 --- a/ircbot/deploy.sh +++ b/ircbot/deploy.sh @@ -1,3 +1,2 @@ -scp main.py root@raye:/home/user/ircbot/ -scp config.json root@raye:/home/user/ircbot/ +rsync -avz ./ root@raye:/home/user/ircbot/ ssh root@raye 'nitroctl restart ircbot'
\ No newline at end of file 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") diff --git a/ircbot/topics b/ircbot/topics deleted file mode 100644 index 0482ed7..0000000 --- a/ircbot/topics +++ /dev/null @@ -1 +0,0 @@ -{"#test": "lzisdv"}
\ No newline at end of file |
