Well, you found me. Congratulations. Was it worth it?
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

35 lines
818 B

import socket
from threading import Thread
from irc import IRC
from secrets import USER, PASSWORD
class Bot(object):
def __init__(self, irc, v5, channels):
self.irc = IRC(*irc)
self.sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
self.channels = channels
self._v5_handler = Thread(target=self._handle_v5)
def start(self):
# Start IRC
self.irc.start(USER, PASSWORD)
for c in self.channels:
self.irc.join(c)
# Start v5 handler
self._v5_handler.start()
# Run IRC
self.irc.run()
def _handle_v5(self):
while True:
data, addr = self.v5_sock.recvfrom(4096)
data = data.decode()
print(f"v5: Received <{data}>")
self.irc.msg(data, "#glados")