depot/packages/servers/ircbot/main.py

36 lines
824 B
Python
Raw Normal View History

2022-09-24 17:51:13 +03:00
import justirc
def main():
2022-09-24 17:56:08 +03:00
config = dict(nick='smith', debug=False)
run_bot(config)
2022-09-24 17:51:13 +03:00
2022-09-24 17:56:08 +03:00
def run_bot(c):
bot = justirc.IRCConnection()
2022-09-24 17:51:13 +03:00
2022-09-24 17:56:08 +03:00
if c['debug']:
@bot.on('packet')
def new_packet(e):
print(e.packet)
2022-09-24 17:51:13 +03:00
@bot.on('connect')
def connect(e):
2022-09-24 17:56:08 +03:00
bot.send_line(f'NICK {c["nick"]}')
bot.send_line(f'USER {c["nick"]} 8 * {c["nick"]}')
2022-09-24 17:51:13 +03:00
@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()