Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###################
- ##Python Chatango bot (Vex) v1
- ##-2014
- ###################
- #imports
- import ch
- import random
- import sys
- import os
- import cgi
- import traceback
- import time
- import urllib
- import datetime
- import json
- from xml.etree import cElementTree as ET
- #end imports
- prefix = "|"
- class Vex (ch.RoomManager) :
- ## called when bot starts, sets font, ect.
- def onInit(self):
- self.setNameColor("999999")
- self.setFontColor("999999")
- self.setFontFace("latha")
- self.setFontSize(11)
- self.enableBg()
- self.enableRecording()
- ## called when bot connects to a room
- def onConnect(self,room):
- print ("[Sys] Connected to : "+room.name)
- self.setNameColor("999999")
- self.setFontColor("999999")
- self.setFontFace("latha")
- self.setFontSize(11)
- self.enableBg()
- self.enableRecording()
- room.message("[Sys] Vex v0.01 - ONLINE")
- ## called when bot reconnects to a room
- def onReconnect(self,room):
- print ("[Sys] Reconnected to : "+room.name)
- self.setNameColor("999999")
- self.setFontColor("999999")
- self.setFontFace("latha")
- self.setFontSize(11)
- self.enableBg()
- self.enableRecording()
- room.message("[Sys] Vex v0.01 - ONLINE")
- ## called when the bot disconnects from a room
- def onDisconnect(self,room):
- print("[Sys] Disconnected from : "+room.name)
- ## called when the bot gets a flood warning, to avoid a flood ban
- def onFloodWarning(self,room):
- print("[Sys] FloodWarning in :"+room.name)
- room.reconnect()
- ## called when a message is posted, the fun stuff goes here
- def onMessage(self,room,user,message):
- ##prints out the chatroom in the log
- print(user.name+" : "+message.body)
- ##Split messages into command and arguments
- msgdata = message.body.split(" ",1)
- if len(msgdata) > 1:
- cmd, args = msgdata[0], msgdata[1]#if command and argument
- else:
- cmd, args = msgdata[0],""#if command and no argument
- cmd=cmd.lower()
- #if prefix is used
- if len(cmd)>0:
- if cmd[0]==prefix:
- used_prefix = True
- cmd = cmd[1:]
- else:
- used_prefix= False
- else:
- return
- ##first command
- if message.body.startswith("Vex"):
- room.message("Hello, "+user.name+".")
- if message.body.startswith("
- ##say command
- elif used_prefix and cmd == "say":
- if args:
- room.message(args)
- else:
- room.message("Error. No arguments.")
- ##used to connect to the chat ect.
- if __name__ == "__main__":
- Vex.easy_start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement