Skip to content

Commit b88f74c

Browse files
Create event_handlers.py
1 parent a3444d1 commit b88f74c

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

‎src/event_handlers.py‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
2+
3+
defhandle_ping(bot, args):
4+
"""
5+
Handle PING command from the server.
6+
"""
7+
nospoof=args[0][1:] ifargs[0].startswith(':') elseargs[0]
8+
bot._ircsend(f'PONG :{nospoof}')
9+
10+
defhandle_cap(bot, args):
11+
"""
12+
Handle CAP command from the server.
13+
"""
14+
ifargs[1] =='ACK'and'sasl'inargs[2]:
15+
bot.sasl_handler.handle_sasl()
16+
17+
defhandle_authenticate(bot, args):
18+
"""
19+
Handle AUTHENTICATE command from the server.
20+
"""
21+
bot.sasl_handler.handle_authenticate(args)
22+
23+
defhandle_903(bot, args):
24+
bot.sasl_handler.handle_903(bot._ircsend)
25+
26+
defhandle_privmsg(bot, args):
27+
source, args=args
28+
ifargs[1].startswith('\x01VERSION\x01'):
29+
source_nick=source.split('!')[0]
30+
bot._ircsend(f'NOTICE {source_nick} :\x01VERSION EliteBot 0.1\x01')
31+
else:
32+
channel, message=args[0], args[1]
33+
source_nick=source.split('!')[0]
34+
ifmessage.startswith('&'):
35+
cmd, *cmd_args=message[1:].split()
36+
bot.handle_command(source_nick, channel, cmd, cmd_args)
37+
forplugininbot.plugins:
38+
plugin.handle_message(source_nick, channel, message)
39+
40+
defhandle_001(bot, args):
41+
forchannelinbot.channel_manager.get_channels():
42+
bot._ircsend(f'JOIN {channel}')
43+
44+
defhandle_invite(bot, args):
45+
channel=args[1]
46+
bot._ircsend(f'join {channel}')
47+
bot.channel_manager.save_channel(channel)
48+
49+
defhandle_version(bot, source):
50+
source_nick=source.split('!')[0]
51+
bot._ircsend('NOTICE', f'{source_nick} :I am a bot version 1.0.0')

0 commit comments

Comments
(0)