38 lines
1.1 KiB
Python
Executable File
38 lines
1.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
import ircstates, socket, ssl
|
|
|
|
from config import *
|
|
from stuff import stuff
|
|
from util import Util
|
|
|
|
|
|
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")
|
|
else:
|
|
with socket.create_connection((self.host, self.port)) as sock:
|
|
try:
|
|
util = Util(config, sock)
|
|
stuff(self, sock)
|
|
except KeyboardInterrupt:
|
|
util.quit("^C")
|
|
|
|
|
|
print("starting bot...")
|
|
bot()
|