summaryrefslogtreecommitdiff
path: root/ircbot/main.py
diff options
context:
space:
mode:
authorMistivia <i@mistivia.com>2025-10-25 15:03:55 +0800
committerMistivia <i@mistivia.com>2025-10-25 22:05:45 +0800
commit45516d648321adc0d8ef567fcb767cd412d10109 (patch)
tree51112538d1eb1c9d97b765b486bc74f313f120d8 /ircbot/main.py
parent2b2ce259241433ca0a3a98a6ea4a37113aed525d (diff)
update
Diffstat (limited to 'ircbot/main.py')
-rw-r--r--ircbot/main.py43
1 files changed, 20 insertions, 23 deletions
diff --git a/ircbot/main.py b/ircbot/main.py
index 28745c4..3c8c40b 100644
--- a/ircbot/main.py
+++ b/ircbot/main.py
@@ -12,9 +12,11 @@ PORT = 6667
NICKNAME = "android"
IDENT = NICKNAME
REALNAME = "bot"
-CHANNELS = ["#main", "#ezl9fd7fa13c4bad4f4"]
+CHANNELS = [
+]
GREETINGS = ["#main"]
LOGPATH = '/volume/webroot/irclog'
+RELAYBOT = 'TeleIRC'
BUFFER_SIZE = 2048
@@ -34,30 +36,12 @@ def help_cmd(chan, sender, args):
2. 丢骰子: !dice [骰数]d[面数]
3. 随机选择:!choice 选项1 选项2 ... 选项n
4. 复读机:!say 复读内容
- 5. AI词典:!dict 单词
+ 5. AI词典: !dict 单词
6. 查看聊天记录:!log
"""
-def today_log(chan):
- now = datetime.datetime.now()
- year = now.strftime("%Y")
- month = now.strftime("%m")
- day = now.strftime("%d")
- url = (f"https://raye.mistivia.com/irclog/view.html#{chan}/"
- f"{year}/{month}-{day}")
- return url
-
-def yesterday_log(chan):
- now = datetime.datetime.now() - datetime.timedelta(days=1)
- year = now.strftime("%Y")
- month = now.strftime("%m")
- day = now.strftime("%d")
- url = (f"https://raye.mistivia.com/irclog/view.html#{chan}/"
- f"{year}/{month}-{day}")
- return url
-
@command("log")
def log_command(chan, sender, args):
- return today_log(chan)
+ return f"https://raye.mistivia.com/irclog/view/?chan={chan[1:]}"
@command("join")
def join_command(chan, sender, args):
@@ -337,12 +321,25 @@ class IRCBot:
cmd_parts = message[1:].split()
cmd = cmd_parts[0].lower()
args = cmd_parts[1:]
-
reply_target = target if target.startswith('#') else sender_nick
-
self.handle_command(sender_nick, reply_target, cmd, args)
except IndexError:
pass
+ elif sender_nick == RELAYBOT:
+ end_of_nick_index = message.find('>')
+ nick = message[1:end_of_nick_index]
+ msg_start_index = end_of_nick_index + 2
+ msg = message[msg_start_index:].strip()
+ if msg.startswith("!") or msg.startswith("!"):
+ try:
+ cmd_parts = msg[1:].split()
+ cmd = cmd_parts[0].lower()
+ args = cmd_parts[1:]
+ if target.startswith('#'):
+ reply_target = target
+ self.handle_command(nick, reply_target, cmd, args)
+ except IndexError:
+ pass
elif command == "JOIN":
args = params