time.sleep(0.1)
-def update_channel_events(bot: aptbot.bot.Bot, message: aptbot.bot.Message, modules: dict[str, ModuleType]):
- try:
- method = Thread(
- target=modules[message.channel].main,
- args=(bot, message, )
- )
- except KeyError:
- pass
- else:
- method.daemon = True
- method.start()
-
-
def start(bot: aptbot.bot.Bot, modules: dict[str, ModuleType]):
load_modules(modules)
message_handler_thread = Thread(
)
message_handler_thread.daemon = True
message_handler_thread.start()
- while True:
- for channel, _ in modules:
- update_channel_thread = Thread(
- target=update_channel_events,
- args=(
- bot,
- aptbot.bot.Message({}, "", None, channel, ""),
- modules,
- )
- )
- update_channel_thread.daemon = True
- update_channel_thread.start()
- time.sleep(10)
+ for channel in modules:
+ update_channel = Thread(
+ target=modules[channel].start,
+ args=(bot, )
+ )
+ update_channel.daemon = True
+ update_channel.start()
def load_modules(modules: dict[str, ModuleType]):
self._connected_channels = []
def send_command(self, command: str):
- if "PASS" not in command:
- print(f"< {command}")
+ # if "PASS" not in command:
+ # print(f"< {command}")
self._irc.send((command + "\r\n").encode())
def connect(self):
def send_privmsg(self, channel: str, text: Union[list[str], str]):
if isinstance(text, list):
for t in text:
- print(
- f"#{channel} ({Commands.PRIVMSG.value}) | {self._nick}: {t}")
+ # print(
+ # f"#{channel} ({Commands.PRIVMSG.value}) | {self._nick}: {t}")
self.send_command(
f"{Commands.PRIVMSG.value} #{channel} :{t}")
- time.sleep(1.5)
else:
- print(f"#{channel} ({Commands.PRIVMSG.value}) | {self._nick}: {text}")
+ # print(f"#{channel} ({Commands.PRIVMSG.value}) | {self._nick}: {text}")
self.send_command(f"{Commands.PRIVMSG.value} #{channel} :{text}")
@staticmethod
def parse_message(received_msg: str) -> Message:
- print(received_msg)
+ # print(received_msg)
message = Message()
value_start = received_msg.find(