Updated bot.py and sasl.py

This commit is contained in:
Yuuki Chan 2024-02-22 19:34:28 +09:00
parent 3cb3a43f4e
commit 71b10eaba1
2 changed files with 8 additions and 7 deletions

View file

@ -196,9 +196,9 @@ class Bot:
await plugin.handle_message(source_nick, channel, message)
case 'CAP':
if args[1] == 'ACK' and 'sasl' in args[2]:
handle_sasl(self.config, self.ircsend)
await handle_sasl(self.config, self.ircsend)
case 'AUTHENTICATE':
handle_authenticate(args, self.config, self.ircsend)
await handle_authenticate(args, self.config, self.ircsend)
case 'INVITE':
channel = args[1]
await self.ircsend(f'JOIN {channel}')
@ -206,6 +206,7 @@ class Bot:
case 'VERSION':
await self.ircsend(f'NOTICE {source_nick} :I am a bot version 1.0.0')
case '001':
await asyncio.sleep(1)
await self.ircsend('JOIN #YuukiTest')
# for channel in self.channel_manager.get_channels():
# await self.ircsend(f'JOIN {channel}')

View file

@ -5,7 +5,7 @@ NULL_BYTE = '\x00'
ENCODING = 'UTF-8'
def handle_sasl(config, ircsend):
async def handle_sasl(config, ircsend):
"""
Handles SASL authentication by sending an AUTHENTICATE command.
@ -13,10 +13,10 @@ def handle_sasl(config, ircsend):
config (dict): Configuration dictionary
ircsend (function): Function to send IRC commands
"""
ircsend('AUTHENTICATE PLAIN')
await ircsend('AUTHENTICATE PLAIN')
def handle_authenticate(args, config, ircsend):
async def handle_authenticate(args, config, ircsend):
"""
Handles the AUTHENTICATE command response.
@ -31,7 +31,7 @@ def handle_authenticate(args, config, ircsend):
f'{config["SASL"]["SASLNick"]}{NULL_BYTE}'
f'{config["SASL"]["SASLPassword"]}')
ap_encoded = base64.b64encode(authpass.encode(ENCODING)).decode(ENCODING)
ircsend(f'AUTHENTICATE {ap_encoded}')
await ircsend(f'AUTHENTICATE {ap_encoded}')
else:
raise KeyError('SASLNICK and/or SASLPASS not found in config')
@ -43,4 +43,4 @@ async def handle_903(ircsend):
Parameters:
ircsend (function): Function to send IRC commands
"""
ircsend('CAP END')
await ircsend('CAP END')