blob: 83cc0ac765dbcd9793be213a5bd84b0dc2451585 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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()
|