From 2b2ce259241433ca0a3a98a6ea4a37113aed525d Mon Sep 17 00:00:00 2001 From: Mistivia Date: Fri, 24 Oct 2025 22:24:06 +0800 Subject: add teleirc --- ircbot/main.py | 11 ++-- irclog/view.html | 137 ++++++++++++++++++++++++++++++++++++++++++-- teleirc/.gitignore | 1 + teleirc/config.toml.example | 24 ++++++++ teleirc/deploy.sh | 2 + 5 files changed, 165 insertions(+), 10 deletions(-) create mode 100644 teleirc/.gitignore create mode 100644 teleirc/config.toml.example create mode 100644 teleirc/deploy.sh diff --git a/ircbot/main.py b/ircbot/main.py index 05aac2b..28745c4 100644 --- a/ircbot/main.py +++ b/ircbot/main.py @@ -13,6 +13,7 @@ NICKNAME = "android" IDENT = NICKNAME REALNAME = "bot" CHANNELS = ["#main", "#ezl9fd7fa13c4bad4f4"] +GREETINGS = ["#main"] LOGPATH = '/volume/webroot/irclog' BUFFER_SIZE = 2048 @@ -56,14 +57,14 @@ def yesterday_log(chan): @command("log") def log_command(chan, sender, args): - log1 = today_log(chan) - log0 = yesterday_log(chan) - return "今天: " + log1 + '\n' + "昨天: " + log0 + return today_log(chan) @command("join") def join_command(chan, sender, args): if sender == NICKNAME: return '' + if not chan in GREETINGS: + return '' return "Dōmo, " + sender + ' san.' @command("dict") @@ -156,9 +157,7 @@ def write_log(channel, nick, msg): return if msg.startswith('!log'): return - if msg.startswith('今天: https://raye.mistivia.com/irclog/') and nick == NICKNAME: - return - if msg.startswith('昨天: https://raye.mistivia.com/irclog/') and nick == NICKNAME: + if msg.startswith('https://raye.mistivia.com/irclog/') and nick == NICKNAME: return now = datetime.datetime.now() base_dir = LOGPATH diff --git a/irclog/view.html b/irclog/view.html index 6d8385c..34b5154 100644 --- a/irclog/view.html +++ b/irclog/view.html @@ -2,6 +2,7 @@ + IRC Log Viewer

IRC Log Viewer

+ +
+ + +
+
+
+ +
+ + diff --git a/teleirc/.gitignore b/teleirc/.gitignore new file mode 100644 index 0000000..5b6c096 --- /dev/null +++ b/teleirc/.gitignore @@ -0,0 +1 @@ +config.toml diff --git a/teleirc/config.toml.example b/teleirc/config.toml.example new file mode 100644 index 0000000..5e98b6d --- /dev/null +++ b/teleirc/config.toml.example @@ -0,0 +1,24 @@ +[general] +MediaDownloadPath="/var/www/tmp" +MediaServerDownload="https://yourserver.com/matterbridge" + +[irc.myirc] +Server="raye.mistivia.com:6697" +Nick="TeleIRC" +UseTLS=true +SkipTLSVerify=false +RemoteNickFormat="<{NICK}> " + +[telegram.mytelegram] +Token="xxxxxxxxxxxxxx" +RemoteNickFormat="<{NICK}> " + +[[gateway]] +name="g1" +enable=true +[[gateway.inout]] +account="telegram.mytelegram" +channel="-0000000000000" +[[gateway.inout]] +account="irc.myirc" +channel="#test" diff --git a/teleirc/deploy.sh b/teleirc/deploy.sh new file mode 100644 index 0000000..e390c1d --- /dev/null +++ b/teleirc/deploy.sh @@ -0,0 +1,2 @@ +scp config.toml root@raye:/etc/matterbridge/ +ssh root@raye 'nitroctl restart teleirc' -- cgit v1.0