Advertisement
Guest User

Vexbot v1

a guest
Oct 1st, 2014
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.89 KB | None | 0 0
  1. ###################
  2. ##Python Chatango bot (Vex) v1
  3. ##-2014
  4. ###################
  5.  
  6. #imports
  7. import ch
  8. import random
  9. import sys
  10. import os
  11. import cgi
  12. import traceback
  13. import time
  14. import urllib
  15. import datetime
  16. import json
  17. from xml.etree import cElementTree as ET
  18. #end imports
  19.  
  20. prefix = "|"
  21.  
  22. class Vex (ch.RoomManager) :
  23.  
  24. ## called when bot starts, sets font, ect.
  25. def onInit(self):
  26. self.setNameColor("999999")
  27. self.setFontColor("999999")
  28. self.setFontFace("latha")
  29. self.setFontSize(11)
  30. self.enableBg()
  31. self.enableRecording()
  32.  
  33. ## called when bot connects to a room
  34. def onConnect(self,room):
  35. print ("[Sys] Connected to : "+room.name)
  36. self.setNameColor("999999")
  37. self.setFontColor("999999")
  38. self.setFontFace("latha")
  39. self.setFontSize(11)
  40. self.enableBg()
  41. self.enableRecording()
  42. room.message("[Sys] Vex v0.01 - ONLINE")
  43.  
  44. ## called when bot reconnects to a room
  45. def onReconnect(self,room):
  46. print ("[Sys] Reconnected to : "+room.name)
  47. self.setNameColor("999999")
  48. self.setFontColor("999999")
  49. self.setFontFace("latha")
  50. self.setFontSize(11)
  51. self.enableBg()
  52. self.enableRecording()
  53. room.message("[Sys] Vex v0.01 - ONLINE")
  54.  
  55. ## called when the bot disconnects from a room
  56. def onDisconnect(self,room):
  57. print("[Sys] Disconnected from : "+room.name)
  58.  
  59. ## called when the bot gets a flood warning, to avoid a flood ban
  60. def onFloodWarning(self,room):
  61. print("[Sys] FloodWarning in :"+room.name)
  62. room.reconnect()
  63.  
  64. ## called when a message is posted, the fun stuff goes here
  65. def onMessage(self,room,user,message):
  66.  
  67. ##prints out the chatroom in the log
  68. print(user.name+" : "+message.body)
  69.  
  70. ##Split messages into command and arguments
  71. msgdata = message.body.split(" ",1)
  72. if len(msgdata) > 1:
  73. cmd, args = msgdata[0], msgdata[1]#if command and argument
  74. else:
  75. cmd, args = msgdata[0],""#if command and no argument
  76. cmd=cmd.lower()
  77.  
  78. #if prefix is used
  79. if len(cmd)>0:
  80. if cmd[0]==prefix:
  81. used_prefix = True
  82. cmd = cmd[1:]
  83. else:
  84. used_prefix= False
  85. else:
  86. return
  87.  
  88. ##first command
  89. if message.body.startswith("Vex"):
  90. room.message("Hello, "+user.name+".")
  91.  
  92. if message.body.startswith("
  93.  
  94. ##say command
  95. elif used_prefix and cmd == "say":
  96. if args:
  97. room.message(args)
  98. else:
  99. room.message("Error. No arguments.")
  100.  
  101.  
  102. ##used to connect to the chat ect.
  103. if __name__ == "__main__":
  104. Vex.easy_start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement