test-bot.py 716 B

1234567891011121314151617181920212223242526
  1. # -*- coding: utf-8 -*-
  2. import irc
  3. ## IRC Config
  4. server = "127.0.0.1"
  5. port = 11007
  6. channels = ["#dev", "#memes", "#philosophy", "#markets", "#math", "#random", "#test"]
  7. botnick = "testbot"
  8. ircc = irc.IRC()
  9. ircc.connect(server, port, channels, botnick)
  10. while True:
  11. text = ircc.get_response().strip()
  12. if not len(text) > 0:
  13. continue
  14. # print(text)
  15. text_list = text.split(' ')
  16. #print(text_list)
  17. if text_list[1] == "PRIVMSG":
  18. channel = text_list[2]
  19. msg = ' '.join(text_list[3:]).strip()
  20. bot_msg = text.split(':')[-1].strip()
  21. if bot_msg.lower() == "test" or bot_msg.lower() == "echo":
  22. ircc.send(channel, f"{bot_msg} back")
  23. continue