try to auto-reconnect when disconnected (not crashed), and don't break when there's no MOTD?
hopefully this stuff works, lol
This commit is contained in:
parent
7d48fa6889
commit
7c966381fe
7
bot.py
7
bot.py
|
@ -4,6 +4,7 @@ import ircstates, socket, ssl
|
|||
from config import *
|
||||
from stuff import stuff
|
||||
from util import Util
|
||||
from time import sleep
|
||||
|
||||
|
||||
class bot:
|
||||
|
@ -24,6 +25,9 @@ class bot:
|
|||
stuff(self, sock)
|
||||
except KeyboardInterrupt:
|
||||
util.quit("^C")
|
||||
except ircstates.server.ServerDisconnectedException:
|
||||
sleep(3)
|
||||
self.__init__()
|
||||
else:
|
||||
with socket.create_connection((self.host, self.port)) as sock:
|
||||
try:
|
||||
|
@ -31,6 +35,9 @@ class bot:
|
|||
stuff(self, sock)
|
||||
except KeyboardInterrupt:
|
||||
util.quit("^C")
|
||||
except ircstates.server.ServerDisconnectedException:
|
||||
sleep(3)
|
||||
self.__init__()
|
||||
|
||||
|
||||
print("starting bot...")
|
||||
|
|
4
stuff.py
4
stuff.py
|
@ -86,9 +86,9 @@ def stuff(bot, sock):
|
|||
f"IDENTIFY {config.self.nick} {config.server.nickserv_pass}",
|
||||
line.source.split("!")[0],
|
||||
)
|
||||
if line.command == "433":
|
||||
if line.command == "433": #433 is ERR_NICKNAMEINUSE
|
||||
util.nick(config.self.nick + "_")
|
||||
if line.command == "376":
|
||||
if line.command == "376" or line.command == "422": #376 is RPL_ENDOFMOTD and 422 is ERR_NOMOTD
|
||||
send(irctokens.build("CAP", ["LS", "302"]).format())
|
||||
elif line.command == "CAP" and line.params[1] == "LS":
|
||||
if server_caps == []:
|
||||
|
|
Loading…
Reference in New Issue