Updated bot.py and sasl.py
This commit is contained in:
parent
3cb3a43f4e
commit
71b10eaba1
2 changed files with 8 additions and 7 deletions
|
@ -196,9 +196,9 @@ class Bot:
|
||||||
await plugin.handle_message(source_nick, channel, message)
|
await plugin.handle_message(source_nick, channel, message)
|
||||||
case 'CAP':
|
case 'CAP':
|
||||||
if args[1] == 'ACK' and 'sasl' in args[2]:
|
if args[1] == 'ACK' and 'sasl' in args[2]:
|
||||||
handle_sasl(self.config, self.ircsend)
|
await handle_sasl(self.config, self.ircsend)
|
||||||
case 'AUTHENTICATE':
|
case 'AUTHENTICATE':
|
||||||
handle_authenticate(args, self.config, self.ircsend)
|
await handle_authenticate(args, self.config, self.ircsend)
|
||||||
case 'INVITE':
|
case 'INVITE':
|
||||||
channel = args[1]
|
channel = args[1]
|
||||||
await self.ircsend(f'JOIN {channel}')
|
await self.ircsend(f'JOIN {channel}')
|
||||||
|
@ -206,6 +206,7 @@ class Bot:
|
||||||
case 'VERSION':
|
case 'VERSION':
|
||||||
await self.ircsend(f'NOTICE {source_nick} :I am a bot version 1.0.0')
|
await self.ircsend(f'NOTICE {source_nick} :I am a bot version 1.0.0')
|
||||||
case '001':
|
case '001':
|
||||||
|
await asyncio.sleep(1)
|
||||||
await self.ircsend('JOIN #YuukiTest')
|
await self.ircsend('JOIN #YuukiTest')
|
||||||
# for channel in self.channel_manager.get_channels():
|
# for channel in self.channel_manager.get_channels():
|
||||||
# await self.ircsend(f'JOIN {channel}')
|
# await self.ircsend(f'JOIN {channel}')
|
||||||
|
|
10
src/sasl.py
10
src/sasl.py
|
@ -5,7 +5,7 @@ NULL_BYTE = '\x00'
|
||||||
ENCODING = 'UTF-8'
|
ENCODING = 'UTF-8'
|
||||||
|
|
||||||
|
|
||||||
def handle_sasl(config, ircsend):
|
async def handle_sasl(config, ircsend):
|
||||||
"""
|
"""
|
||||||
Handles SASL authentication by sending an AUTHENTICATE command.
|
Handles SASL authentication by sending an AUTHENTICATE command.
|
||||||
|
|
||||||
|
@ -13,10 +13,10 @@ def handle_sasl(config, ircsend):
|
||||||
config (dict): Configuration dictionary
|
config (dict): Configuration dictionary
|
||||||
ircsend (function): Function to send IRC commands
|
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.
|
Handles the AUTHENTICATE command response.
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ def handle_authenticate(args, config, ircsend):
|
||||||
f'{config["SASL"]["SASLNick"]}{NULL_BYTE}'
|
f'{config["SASL"]["SASLNick"]}{NULL_BYTE}'
|
||||||
f'{config["SASL"]["SASLPassword"]}')
|
f'{config["SASL"]["SASLPassword"]}')
|
||||||
ap_encoded = base64.b64encode(authpass.encode(ENCODING)).decode(ENCODING)
|
ap_encoded = base64.b64encode(authpass.encode(ENCODING)).decode(ENCODING)
|
||||||
ircsend(f'AUTHENTICATE {ap_encoded}')
|
await ircsend(f'AUTHENTICATE {ap_encoded}')
|
||||||
else:
|
else:
|
||||||
raise KeyError('SASLNICK and/or SASLPASS not found in config')
|
raise KeyError('SASLNICK and/or SASLPASS not found in config')
|
||||||
|
|
||||||
|
@ -43,4 +43,4 @@ async def handle_903(ircsend):
|
||||||
Parameters:
|
Parameters:
|
||||||
ircsend (function): Function to send IRC commands
|
ircsend (function): Function to send IRC commands
|
||||||
"""
|
"""
|
||||||
ircsend('CAP END')
|
await ircsend('CAP END')
|
||||||
|
|
Loading…
Add table
Reference in a new issue