Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ########################################################################
- ########################################################################
- ##### File: HatterBot version 1.4.0 #####
- ##### by: 0rx #####
- ##### http://remaire.chatango.com #####
- ##### http://tango-hyoo.chatango.com #####
- ##### This bot script is made with the help of some great friends #####
- ##### with that, this bot is made for educational purposes only. #####
- ##### You're free to copy this script as long as you credit those #####
- ##### people below. #####
- ##### Credits: - Poeticartist1 (Owner of Nadashiki) #####
- ##### - TryHardHusky(Horny Bot Maker) #####
- ##### - 0rx(Author) #####
- ##### - Agunq(Fellow Bot Maker) #####
- ##### - Peoples from [email protected] #####
- ########################################################################
- ########################################################################
- ## YOU WILL NEED THE CH.PY TO RUN THIS BOT!
- ## YOU CAN GET IT FROM HERE http://pastebin.com/MBwdSZsW
- import ch
- import random
- import sys
- import os
- import re
- import cgi
- import codecs
- import traceback
- import time
- import datetime
- import urllib
- import binascii
- import youtube
- import helperCmd
- import json
- import cmds
- import __future__
- ##############################################################
- lockdown = False
- activated = True
- ##############################################################
- ## Timer Stuff ###############################################
- startTime = time.time()
- ## End ###############################################
- ##############################################################
- ##############################################################
- ## File Stuff ################################################
- ## PMLOG
- filename = "pmlog.txt"#the text file you need to have in same place as bot
- pmlog=[]
- f = open(filename, 'r') #open status.txt and make a writing variable called file
- print("[INFO]LOADING PMLOG")#print to console
- time.sleep(1)#pause for one second
- for name in f.readlines():
- if len(name.strip())>0: pmlog.append(name.strip())
- f.close()#close the file
- ## Nicknames
- nicks=dict()#empty list
- f=open ("Nicks.txt","r")#r=read w=right
- print ("[INF]Loading Nicks...")#print
- time.sleep(1)
- for line in f.readlines():#loop through eachline and read each line
- try:#try code
- if len(line.strip())>0:#strip the whitespace checkgreater than 0
- user , nick = json.loads(line.strip())
- nicks[user] = json.dumps(nick)
- except:
- print("[Error]Can't load nick %s" % line)
- ## definitions
- dictionary = dict() #volatile..
- f = open("definitions.txt", 'r') #read-only
- print("[INF]Loading Definitions...")
- time.sleep(1)
- for line in f.readlines():
- try:
- if len(line.strip())>0:
- word, definitions, name = json.loads(line.strip())
- dictionary[word] = json.dumps([definitions, name])
- except:
- print("{ERROR]Cant load Definitions: %s" % line)
- f.close()
- ## Locks##
- locks = []
- f = open("locks.txt", 'r')
- time.sleep(1)
- for name in f.readlines():
- if len(name.strip())>0: locks.append(name.strip())
- f.close()
- ##OWNER##
- spermitted = []
- f = open("spermitted.txt", "r") #read-only
- print("[INF]Loading Supreme Masters...")
- time.sleep(1)
- for name in f.readlines():
- if len(name.strip())>0: spermitted.append(name.strip())
- f.close()
- ##MODS##
- permitted = []
- f = open("permitted.txt", "r")
- print("[INF]Loading Mods...")
- time.sleep(1)
- for name in f.readlines():
- if len(name.strip())>0: permitted.append(name.strip())
- f.close()
- ##Arch-Knights##
- hpermitted = []
- f = open("hpermitted.txt", "r") #read-only
- print("[INF]Loading Arch-Knights....")
- time.sleep(1)
- for name in f.readlines():
- if len(name.strip())>0: hpermitted.append(name.strip())
- f.close()
- ##Players##
- whitelist = []
- f = open("whitelist.txt", "r") #read-only
- print("[INF]Loading Players...")
- time.sleep(1)
- for name in f.readlines():
- if len(name.strip())>0: whitelist.append(name.strip())
- f.close()
- ##Peeps##
- friend = []
- f = open("friend.txt", "r") # read-only
- print("[INF]Loading Friends...")
- time.sleep(1)
- for name in f.readlines():
- if len(name.strip())>0: whitelist.append(name.strip())
- f.close()
- ##Rooms##
- rooms = []
- f = open("rooms.txt", "r") #read-only
- print("[INF]Loading Rooms...")
- time.sleep(1)
- for name in f.readlines():
- if len(name.strip())>0: rooms.append(name.strip())
- f.close()
- blacklist = ['botteh','mechabot','nadashiki','aqunq','justhoax','ragebot','illogic']
- specials = ['senops','sarashiki23','ampunganz','galaksi2','dovion','frizki']
- def saveNicks():
- print("[SAVE] SAVING NICKS...")
- f = open("Nicks.txt", "w")
- for user in nicks:
- nick = json.loads(nicks[user])
- f.write(json.dumps([user, nick])+"\n")
- f.close()
- def sntonick(username):
- user = username.lower()
- if user in nicks:
- nick = json.loads(nicks[user])
- return nick
- else:
- return user
- ## End #######################################################
- ##############################################################
- ##############################################################
- ## Define Stuff ##############################################
- ## End #######################################################
- ##############################################################
- ##############################################################
- ######## Mon Nov 18 2013 22:15:33 WIB ########
- ##############################################################
- if sys.version_info[0] > 2:
- import urllib.request as urlreq
- else:
- import urllib2 as urlreq
- ##############################################################
- ## Time Stuff ################################################
- def getUptime():
- """
- Returns the number of seconds since the programs started.
- """
- #do return startTime if you want the process start time
- return time.time() - startTime
- ## System Uptime
- def uptime():
- try:
- f = open( "/proc/uptime")
- contents = f.read().split()
- f.close()
- except:
- return "Cannot open uptime file"
- total_seconds = float(contents[0])
- ## Helper vars:
- MINUTE = 60
- HOUR = MINUTE * 60
- DAY = HOUR * 24
- ## Get the days, hours, etc:
- days = int( total_seconds / DAY )
- hours = int( ( total_seconds % DAY ) / HOUR )
- minutes = int( ( total_seconds % HOUR ) / MINUTE )
- seconds = int( total_seconds % MINUTE )
- ## Build up the pretty string (like this: "N days. N hours, N minutes, N seconds")
- string = ""
- if days > 0:
- string += str(days) + " " + (days == 1 and "day" or "days" ) + ", "
- if len(string) > 0 or hours > 0:
- string += str(hours) + " " + (hours == 1 and "hour" or "hours" ) + ", "
- if len(string) > 0 or minutes > 0:
- string += str(minutes) + " " + (minutes == 1 and "minute" or "minutes" ) + ", "
- string += str(seconds) + " " + (seconds == 1 and "second" or "seconds" )
- return string;
- ## End #########################################################
- ################################################################
- ################################################################
- ## Important TestBot Class #####################################
- class TestBot(ch.RoomManager):
- ## Setting Font Format and Colors
- def onInit(self):
- self.setNameColor("FF9966")
- self.setFontColor("33CCFF")
- self.setFontFace("1")
- self.setFontSize(11)
- self.enableBg()
- self.enableRecording()
- ## Rank Configs
- def getAccess(self, user):
- if user.name in spermitted: return 5
- elif user.name in permitted: return 4
- elif user.name in hpermitted: return 3
- elif user.name in whitelist: return 2
- elif user.name in friend: return 1
- else: return 0
- ##############################################################
- ## Connecting and Disconnecting crap #########################
- def onConnect(self, room):
- print("[+] Mad Hatter Connected to "+room.name)
- def onReconnect(self, room):
- print("[+] Mad Hatter Reconnected to "+room.name), room.message("Reconnected")
- def onDisconnect(self, room):
- print("[+] Mad Hatter Disconnected from "+room.name)
- def onJoin(self, room, user):
- print("[+] "+user.name+" joined "+room.name)
- if lockdown: return
- if self.getAccess(user) == 5:
- time.sleep(2)
- room.message("*Bows down to "+ user.name +"*")
- return
- # if self.getAccess(user) == 3:
- # time.sleep(2)
- # room.message("Arch Knight is present")
- #return
- # elif self.getAccess(user) == 4 and not user.name == "ramielsama":
- # time.sleep(2)
- # room.message("Wellcome back "+sntonick(user.name)+" !!", True)
- #return
- elif user.name == "ramielsama":
- time.sleep(2)
- room.message("Wellcome back "+sntonick(user.name)+" ! *Hugs and kisses My Fallen Angel*", True)
- return
- def onConnectFail(self, room):
- print("[ERR} Room Not Found")
- def onBan(self, room, user, target):
- print("someone got banned in "+room.name)
- ## End #######################################################
- ##############################################################
- ##############################################################
- ## Setting up Commands #######################################
- def onMessage(self, room, user, message):
- global activated
- global lockdown
- ## rpg game
- global rpgbool
- global monster
- global monsterlife
- global rpgbattleactive
- global bosslist
- global boss
- global bosslife
- #Print to console
- if room.getLevel(self.user) > 0:
- print("[%s]\033[94m[MSG]\033[0m\033[31m[LVL %s]\033[0m[%s][%s] %s: %s" % (time.strftime("%d/%m/%y- %H:%M:%S", time.localtime(time.time())), self.getAccess(user), room.name, message.ip, user.name.title(), message.body))
- else:
- print("[%s]\033[94m[MSG]\033[0m\033[31m[LVL %s]\033[0m[%s][%s] %s: %s" % (time.strftime("%d/%m/%y- %H:%M:%S", time.localtime(time.time())), self.getAccess(user), room.name, message.ip, user.name.title(), message.body))
- ##roomlog
- roomlog.append("[%s]\033[LVL %s]\033[%s] %s: %s" % (time.strftime("%d/%m/%y- %H:%M:%S", time.localtime(time.time())), self.getAccess(user), room.name, user.name.capitalize(), message.body))
- if self.user == user: return #ignore self(bot)
- if "wl me" == message.body:
- if room.getLevel(user) < 1 and self.getAccess(user) == 0:
- friend.append(user.name)
- room.message(user.name+" can use me now. ^^")
- else: room.message("You're silly >_>")
- if "descend" in message.body:
- if self.getAccess(user) < 4:
- if user.name == "ramielsama":
- permitted.append(user.name)
- room.message("A Fallen Angel descends to earth :o")
- if user.name in friend:
- friend.remove(user.name)
- if user.name in whitelist:
- whitelist.remove(user.name)
- if user.name == "xmothra":
- spermitted.append(user.name)
- room.message("Here comes my mighty creator :o")
- if user.name in friend:
- friend.remove(user.name)
- if user.name in whitelist:
- whitelist.remove(user.name)
- else: return
- else: return
- if "test" == message.body or "Test" == message.body or "tes" == message.body or "Tes" == message.body:
- room.message("Test request has been granted, you may test it now :)")
- if self.getAccess(user) == 0 and not room.getLevel(user) >= 1: return #ignore non-whitelisted users except room mods/owners
- if self.getAccess(user) < 4 and not activated: return #ignore everyone when in lockdown
- if user.name in blacklist: return #ignore blacklisted user
- if self.getAccess(user) < 3 and not room.getLevel(user) < 1 and room.name in locks: return #ignore rank 1 and 2 when room locked
- if message.body[0] == "'" or message.body[0] == ":": #prefix part in this line
- data = message.body[1:].split(" ", 1)
- if len(data) == 2:
- cmd, args = data[0], data[1]
- else:
- cmd, args = data[0], ""
- if lockdown and self.getAccess(user) < 4: return
- # Nick
- elif (cmd == "nick"):
- try:
- if args:
- nicks[user.name]=json.dumps(args)
- room.message (user.name+" will now be called "+args ,True)
- saveNicks()
- if args == "":
- room.message("type 'nick (your-new-nickname-here)")
- except:
- room.message("Sorry, but it seems that I failed to give you a nickname.")
Advertisement
Add Comment
Please, Sign In to add comment