From 9c8abab1e31245a083627a55dbd289daf0b4292a Mon Sep 17 00:00:00 2001 From: Tiago Carvalho Date: Sat, 24 Sep 2022 15:51:13 +0100 Subject: [PATCH] packages/ircbot: add bot code --- packages/servers/ircbot/main.py | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 packages/servers/ircbot/main.py diff --git a/packages/servers/ircbot/main.py b/packages/servers/ircbot/main.py new file mode 100644 index 0000000..e294a98 --- /dev/null +++ b/packages/servers/ircbot/main.py @@ -0,0 +1,37 @@ +import justirc + +NICK = 'smith' + +def main(): + bot = justirc.IRCConnection() + + @bot.on('packet') + def new_packet(e): + print(e.packet) + + @bot.on('connected') + def reload_plugins(e): + print('bot has connected') + + @bot.on('connect') + def connect(e): + bot.send_line(f'NICK {NICK}') + bot.send_line(f'USER {NICK} 8 * {NICK}') + bot.emit('connected') + + @bot.on('welcome') + def welcome(e): + bot.join_channel("#general") + + @bot.on('message') + def message(e): + message = e.message.lower() + if message == '.fistbump': + message = f'vroooooooooooo fiiiist, {e.sender} :vvvv)))' + bot.send_message(e.channel, message) + + bot.connect('irc.privatevoid.net', port=6697, tls=True) + bot.run_loop() + +if __name__ == '__main__': + main()