Advertisement
effyn

very basic chatango bot

Mar 22nd, 2016
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. import ch
  2.  
  3. class bot(ch.RoomManager):
  4.  
  5. def onInit(self):
  6. print("\n[-] <bot_name> initialized")
  7. self.setNameColor("000000")
  8. self.setFontColor("000000")
  9. self.setFontFace("Arial")
  10. self.setFontSize(12)
  11. #self.enableBg()
  12.  
  13. def onConnect(self, room):
  14. print("\n[-] connected to "+room.name+"\n")
  15.  
  16. def onReconnect(self, room):
  17. print("\n[-] reconnected to "+room.name+"\n")
  18.  
  19. def onDisconnect(self, room):
  20. print("\n[!] disconnected from "+room.name+"\n")
  21.  
  22. def onMessage(self, room, user, message):
  23. print("\t{0}: {1}".format(user.name,message.body))
  24.  
  25. if self.user == user: return
  26.  
  27. msg_data = message.body.split(" ",1)
  28.  
  29. if len(msg_data) > 1:
  30. cmd, args = msg_data[0], msg_data[1]
  31. else:
  32. cmd, args = msg_data[0],""
  33. cmd = cmd.lower()
  34. args = args.lower()
  35. msg = message.body.lower()
  36.  
  37. if len(cmd) > 0:
  38. #if cmd[0] in prefixes:
  39. if cmd[0] == "/":
  40. iscmd = True
  41. cmd = cmd[1:]
  42. else:
  43. iscmd = False
  44.  
  45. if iscmd:
  46. if cmd == "say":
  47. room.message(args)
  48.  
  49. rooms = ["room_1","room_2"]
  50. username = "bot_name"
  51. password = "password"
  52. bot.easy_start(rooms,username,password)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement