summaryrefslogtreecommitdiff
path: root/bot.py
diff options
context:
space:
mode:
authorPawky Laguish2024-11-26 21:16:05 +0000
committerPawky Laguish2024-11-26 21:16:05 +0000
commitea30e6ff34f6c5356e42c23a3b0c74fbbaa17771 (patch)
tree9a2f3125c5755bafc9b279103a29030fb608c244 /bot.py
wip
Diffstat (limited to 'bot.py')
-rwxr-xr-xbot.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/bot.py b/bot.py
new file mode 100755
index 0000000..83cc0ac
--- /dev/null
+++ b/bot.py
@@ -0,0 +1,45 @@
+#!./venv/bin/python3
+#!/usr/bin/env python3
+import ircstates, socket, ssl
+
+from config import *
+from stuff import stuff
+from util import Util
+from time import sleep
+
+
+class bot:
+ server = ircstates.Server(config.server.name)
+ host = config.server.host
+ port = config.server.port
+
+ if __name__ == __module__ == "__main__":
+
+ @classmethod
+ def __init__(self):
+ if config.server.ssl:
+ with socket.create_connection((self.host, self.port)) as sock_raw:
+ ctx = ssl.create_default_context()
+ with ctx.wrap_socket(sock_raw, server_hostname=self.host) as sock:
+ try:
+ util = Util(config, sock)
+ 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:
+ util = Util(config, sock)
+ stuff(self, sock)
+ except KeyboardInterrupt:
+ util.quit("^C")
+ except ircstates.server.ServerDisconnectedException:
+ sleep(3)
+ self.__init__()
+
+
+print("starting bot...")
+bot()