bot.py 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # coding: utf8
  2. import ConfigParser
  3. from mysql import noaMysql
  4. from irc import noaIRC
  5. config = ConfigParser.ConfigParser()
  6. config.readfp(open('config.ini'))
  7. connectionSection = 'connection'
  8. mySQLsection = 'mysql'
  9. # connection to IRC
  10. ircCredentials = {
  11. 'host' : config.get(connectionSection, 'host'),
  12. 'port' : int(config.get(connectionSection, 'port')),
  13. 'key' : config.get(connectionSection, 'key'),
  14. 'user' : config.get(connectionSection, 'nick'),
  15. 'channel' : config.get(connectionSection, 'channel')
  16. }
  17. #patterns
  18. message_pattern = config.get('pattern', 'chat_message')
  19. # connection to MySQL
  20. mysqlCredentials = {
  21. 'host' : config.get(mySQLsection, 'host'),
  22. 'port' : int(config.get(mySQLsection, 'port')),
  23. 'user' : config.get(mySQLsection, 'user'),
  24. 'passwd' : config.get(mySQLsection, 'passwd'),
  25. 'db' : config.get(mySQLsection, 'db')
  26. }
  27. mysqlCore = noaMysql(mysqlCredentials)
  28. ircCore = noaIRC(**ircCredentials)
  29. ircCore.setMySQLconnector(mysqlCore)
  30. ircCore.setPattern(message_pattern)
  31. ircCore.run()