diff options
| author | Mistivia <i@mistivia.com> | 2025-11-04 23:42:27 +0800 |
|---|---|---|
| committer | Mistivia <i@mistivia.com> | 2025-11-04 23:42:27 +0800 |
| commit | 8532af453ccc9071ddc919b063788d6b496af991 (patch) | |
| tree | a27e2069248767d3655be417a2d45235cecf6158 /ircbot | |
| parent | 8dbcdce76cbd4cd3b2ad2dcfce5bf828d91aa07c (diff) | |
freeze domo in 5 min after connect
Diffstat (limited to 'ircbot')
| -rw-r--r-- | ircbot/main.py | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/ircbot/main.py b/ircbot/main.py index a106dc1..db49a8e 100644 --- a/ircbot/main.py +++ b/ircbot/main.py @@ -10,6 +10,8 @@ import hashlib import re import requests +connect_time = time.time() + config = None with open('./config.json', 'r', encoding='utf-8') as f: config = json.load(f) @@ -97,19 +99,23 @@ def log_command(chan, sender, args): return f"https://raye.mistivia.com/irclog/view/?chan={chan[1:]}" def load_lastseen(): - try: - with open("lastseen", "r") as fp: - return json.load(fp) - except: - return dict() + return dict() + # try: + # with open("lastseen", "r") as fp: + # return json.load(fp) + # except: + # return dict() LAST_SEEN = load_lastseen() def save_lastseen(): - with open("lastseen", "w") as fp: - json.dump(LAST_SEEN, fp) + pass + # with open("lastseen", "w") as fp: + # json.dump(LAST_SEEN, fp) def get_greeting(chan, sender, args): + if time.time() - connect_time < 300: + return '' if sender == NICKNAME: return '' if not chan in GREETINGS: @@ -396,7 +402,7 @@ class IRCBot: self.socket.settimeout(300) self.socket.connect((self.server, self.port)) print("Connection successful.") - + connect_time = time.time() self.send_raw(f"NICK {self.nickname}") self.send_raw(f"USER {self.ident} 0 * :{self.realname}") |
