Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ############################################################################
- ############################################################################
- #### Getting Started Bot ############
- #### File = Kana's bot.py ############
- #### Originaly by = Wildanchuan ############
- #### Edited by = Thelorgorenk ############
- #### you can PM for info about making a chatango ############
- #### bot in http://0rx.chatango.com, and you can ############
- #### and you can also chat in : ############
- #### http://khususme.chatango.com ############
- #### Last update: ############
- #### 09.00 PM August, 27 2015 by Thelorgorenk ############
- ############################################################################
- ############################################################################
- ##Importing Random Crap xD
- #here you can see that you're importing ch library
- import ch
- import random
- import sys
- import json
- import time
- import re
- if sys.version_info[0] > 2:
- import urllib.request as urlreq
- else:
- import urllib2 as urlreq
- from time import localtime, strftime
- wordtodaytime = dict()
- ##Dance moves!
- #kinda useless
- dancemoves = [
- "(>^.^)>",
- "(v^.^)v",
- ]
- song = [
- "Dirimu, dirimulah! Orang yang beriku senyum ini",
- "Jika kita bisa membuat air mata yang bersinar, itu 'kan 'jadi bintang jatuh",
- "Tanganmu t'lah terluka, tapi jangan pernah lepaskannya lagi",
- "Dari langit yang terpenuhi keinginan, hari esok 'kan segera datang",
- "Cahya yang membimbingku adalah dirimu",
- "Dan aku pun ditarik karenanya",
- "Sebelum kusadarim kita mulai sebrangi jalan itu",
- "Sekaranglah saatnya! Jikalau kita hanya bisa bersinar di sini",
- ]
- bete = [
- "kunci",
- ]
- pagi = [
- "ohayou oni-chan",
- ]
- def tube(args):
- try:
- search = args.split()
- url = urlreq.urlopen("https://www.googleapis.com/youtube/v3/search?q=%s&part=snippet&key=AIzaSyBSnh-sIjd97_FmQVzlyGbcaYXuSt_oh84" % "+".join(search))
- udict = url.read().decode('utf-8')
- data = json.loads(udict)
- rest = []
- for f in data["items"]:
- rest.append(f)
- d = random.choice(rest)
- link = "http://www.youtube.com/watch?v=" + d["id"]["videoId"]
- videoid = d["id"]["videoId"]
- title = d["snippet"]["title"]
- uploader = d["snippet"]["channelTitle"]
- descript = d["snippet"]['description']
- count = d["snippet"]["publishedAt"]
- return "<f x1233FF33='1'>Ha<f x1200F='1'>sil:<f x12F00='1'> %s <br/><br/><br/><br/><br/><br/><br/><br/><font color='#ffcc00'><b>%s</b></font><br/><font color='#ff0000'><b>Yang ngeupload</b></font>:<b> %s</b><br/><font color='#ff0000'><b>Di publikasikan pada</b></font>: %s<br/><font color='#ff0000'><b>Rincian</b></font>:<i> %s ...</i><br/> " % (link, title, uploader, count, descript[:200])
- except Exception as e:
- return str(e)
- # implied command?
- # call bot name with command after
- # call bot name with command after
- #Setting Pretty Colors
- #Font setting for your bot
- class TestBot(ch.RoomManager):
- def onInit(self):
- self.setNameColor("FF0000")
- self.setFontColor("FF00")
- self.setFontFace("Gorgia")
- self.setFontSize(13)
- self.enableBg()
- self.enableRecording()
- ##### Pars Def
- def pars(args):
- args=args.lower()
- userlist = roomUsers()
- for name in userlist:
- if args in name:return name
- ##gugel image
- def gsimg(self, search):
- encoded = urllib.parse.quote(search)
- rawData = urllib.request.urlopen('http://ajax.googleapis.com/ajax/services/search/images?v=1.0&q='+encoded).read().decode('utf-8')
- jsonData = json.loads(rawData)
- searchResults = jsonData["responseData"]["results"]
- for data in searchResults:
- title = data["title"]
- print(title)
- link = data["url"]
- if link:
- full = link
- return('I found: %s <br> %s' % (title, full))
- break
- ##Connecting Crap
- #This is what will be printed on your python console when event called
- #ini pesan yg keluar ketika BOT nya aktif
- def onConnect(self, room):
- print ("[INFO] Reconnected to : "+room.name)
- room.setSilent(False)#new code for flood ban
- self.setNameColor("FF0000")
- self.setFontColor("FF0000")
- self.setFontFace("Georgia")
- self.setFontSize(12)
- self.enableBg()
- self.enableRecording()
- room.message("|| MAZE NOW ON-LINE || a BOT by |wildanchuan|")
- def onReconnect(self, room):
- print("Reconnected")
- room.message("|AMACCHI NOW RECONNECT||ムmムくくサェ れ㊤メ ㊤れしェれも| *waves*")
- def onDisconnect(self, room):
- print("Disconnected")
- room.message("|AMACCHI NOW DISCONECTED||ムmムくくサェ れ㊤メ ㊤れしェれも| *waves*")
- ##Ignore this, you dont need to worry about this
- #Well, you can actually take a little time to look at it and learn something
- def onMessage(self, room, user, message):
- #### Comenzi fara prefix
- ## ini perintah yang ga pake tanda " / " bisa di edit
- if message.body.startswith("@"+"wildanchuan"):
- if user.name == "wildanchuan": ##user name ini bisa di ganti sesuai nick kamu
- room.message("papa Mavok ya")
- else:
- room.message("Jika tidak di jawab mohon maaf. karena papa sering sibuk."+" @"+user.name)
- if message.body.startswith("edo tensei"):
- room.message("@AkenoIO @animeh4ckerIO @rokibkyujuroku @tsutsukaakushi @PutraDaiki @OtakuGamers04 @cranel1 @HCSama2012 @Shiokage @Kyosuke003 @DutaKun @Yukki111 @HasegawaRyuga @budhydarmaone @YukisunaYokagami @ToyotomiHedoyoshi @Akamx @clonerxyz @FiveFa @Koinyan @ketela35 @WildanChuan @coeg95 @Thelorgorenk @ShamanTheBeater @ArthuroDragnell @shintarou99")
- if message.body.startswith("@"+"mazechuan"):
- if user.name == "wildanchuan":
- room.message("toustano, masta ? @"+"wildanchuan")
- else:
- room.message("nani..? " +" @"+user.name)
- if message.body.startswith("maze"):
- if user.name == "wildanchuan":
- room.message("Tousta no masta..")
- else:
- room.message("tousta no, aniki..?" +" @"+user.name)
- if message.body.startswith("kerja bagus"):
- if user.name == "wildanchuan":
- room.message("arigato gozaimasu papa~")
- else:
- room.message("sankyu nee~")
- if message.body.startswith("test"):
- if user.name == "wildanchuan":
- room.message("Maze TEST SUCCES")
- else:
- room.message("SUCCES Coeg" +" @"+user.name)
- if message.body.startswith("gua "):
- jawab = ["nggak","bisa jadi","tentu","siapa ya?","jones ya ?"]
- room.message(random.choice(jawab)+" @"+user.name)
- if message.body.startswith("gue "):
- jawab = ["nggak","bisa jadi","tentu","siapa ya?","jones ya ?"]
- room.message(random.choice(jawab)+" @"+user.name)
- if message.body.startswith("woi"):
- room.message("awas IMPOTEN ntar" +" @"+user.name)
- if message.body.startswith("credit"):
- room.message("Editor : wildanchuan")
- room.message("script : pak shaman")
- room.message("moder : pak thelor")
- room.message("special thanks : pak cloner" +" @"+user.name)
- if message.body.startswith("sepi"):
- room.message("Slow,Maze here" +" @"+user.name)
- if message.body.startswith("pagi"):
- room.message("selamat pagi :)" +" @"+user.name)
- if message.body.startswith("siang"):
- room.message("selamat siang :)" +" @"+user.name)
- if message.body.startswith("malam"):
- room.message("selamat malam :)" +" @"+user.name)
- if message.body.startswith("ohayo"):
- room.message("hai, ohayo" +" @"+user.name)
- if message.body.startswith("konbanwa"):
- room.message("hai, konbawa :v" +" @"+user.name)
- if message.body.startswith("oyasumi"):
- room.message("hai, oyasumi :v" +" @"+user.name)
- if message.body.startswith("konichiwa"):
- room.message("hai, konichiwa :)" +" @"+user.name)
- if message.body.startswith("link"):
- room.message("kore.. http://ust.chatango.com/um/w/i/wildanchuan/img/l_41.jpg")
- if message.body.startswith("jam"):
- if user.name == "wildanchuan":
- room.message(strftime("%H:%M:%S", localtime()))
- else:
- room.message("Ga punya JAM ya..?" +" @"+user.name)
- if message.body.startswith("tanggal"):
- if user.name == "wildanchuan":
- room.message(strftime ("Sekarang: %a,%d-%b-%Y ", localtime()))
- else:
- room.message("Ga punya Kalender ya ya..?" +" @"+user.name)
- if message.body.startswith("siapa yang "):
- room.message(random.choice(room.usernames) +" @"+user.name)
- if message.body.startswith("afk"):
- if user.name == "wildanchuan":
- room.message("hati hati papa sayank, salam buat mama")
- else:
- room.message("AFK..?, emang gua pikirin, AFK sono.." +" @"+user.name)
- if message.body.startswith("back"):
- if user.name == "wildanchuan":
- room.message("okairi, papa~sama")
- else:
- room.message("okairi coeg" +" @"+user.name)
- try:
- if room.getLevel(self.user) > 0:
- print(user.name, message.body)
- else:
- print(user.name, message.body)
- if self.user == user: return
- if message.body[0] == "." : ## << yg tanda " - " bisa di ganti sesuka hati
- data = message.body[1:].split(" ", 1)
- if len(data) > 1:
- cmd, args = data[0], data[1]
- else:
- cmd, args = data[0], ""
- ##COMMANDS!
- #Setting up commands for yer bot
- #commands section
- #### Invite
- if cmd == "invite" or cmd == "Invite":
- if len (args) > 0:
- self.pm.message(ch.RoomManager(args),"%s You have a group invite by ! http://%s.chatango.com ." %(owners[0],room.name))
- room.message("Invite on progress %s in Access group. :)" % args)
- else:
- room.message("Sry have problem. :3")
- ##Say
- #Make your bot say what you want
- #ini perintah yg pake " / "
- if cmd == "ev" or cmd == "eval" or cmd == "e":
- ret = eval(args)
- if ret == None:
- room.message("Done.")
- return
- room.message(str(ret))
- elif cmd == "bot":
- jawab = ["BOT v10.1 amacchi version"]
- room.message(random.choice(jawab)+" @"+user.name)
- elif cmd == "help":
- jawab = ["perintah PREFIX amacchi With [.] [rm] [on] [say] [yt] [prof] [img]"]
- room.message(random.choice(jawab)+" @"+user.name)
- ##Check Level
- #This one cmd is tho make your bot say your mod level in the current room you're in
- elif cmd == "mylvl":
- room.message("Your mod level: %i" %(room.getLevel(user)))
- ##shutdon
- elif cmd == "off":
- if user.name == "wildanchuan":
- room.message("Shutting down ...")
- time.sleep(1)
- self.stop()
- else:
- room.message("Only the owner can use this command. mew *h* ")
- ### username list
- elif cmd =="on":
- room.message("User ON-LINE: " + str(room.usercount) + str(room.getUserlist(1))+" .")
- ##lock
- elif cmd == "kunci":
- if user.name == "wildanchuan":
- room.message("maze succes lock")
- room.setSilent(True)
- else:
- room.message("don't have permission *h* ")
- ##unlock
- elif cmd == "buka":
- if user.name == "wildanchuan":
- room.setSilent(False)
- room.message("SUCCES UNLOCK")
- else:
- room.message("MALES ah ah ah..*h*")
- ##bc
- elif cmd == "broadcast":
- if user.name =="wildanchuan":
- for room in self.rooms:
- if args == "": return
- else:
- room.message("Broadcast from - "+user.name + ": "+args, True)
- else:
- room.message("[<b>%s</b>] Only Councill Members are allowed" % "ERROR", False)
- ## Join and Leave Rooms
- if cmd == "join" and len(args) > 1:
- if self.getAccess(user) >= 0 or user.name in room.ownername and self.getAccess(user) < 0 or user.name in room.ownername:
- if args not in self.roomnames:
- room.message("*Joins <b>%s</b>*" % args, True)
- self.joinRoom(args)
- else:
- room.message("I'm there already :|")
- else:
- room.message("You mere mortals can never do that !!")
- ## leave
- if cmd == "leave":
- if self.getAccess(user) > 0 or room.getLevel(user) == 0:
- if args:
- if self.getAccess(user) > 0:
- room.message("i've left <b>%s</b>" % args, True)
- self.leaveRoom(args)
- else: return
- if not args:
- room.message("Okay, I'm leaving this place")
- self.leaveRoom(room.name)
- else:
- room.message("You mere mortals can never do that !!")
- #nama Room
- elif cmd == "rm":
- room.message("<b>%s</b> You ON-line In The <b>%s</b>" % (user.name.title(), room.name) + " the owner is <b>%s</b> " % str(room.ownername), True)
- #yutub
- if cmd == "yt" or cmd == "ytb":
- room.message(tube(args),True)
- #gogel
- elif cmd == "gis" and len(args) > 0:
- if room.name == "khususmeme":
- room.message("showing Google images here :|")
- else:
- try:
- search = args.split()
- import urllib.request
- with urllib.request.urlopen("http://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=%s" % "+".join(search)) as url:
- udict = url.read().decode()
- a = re.finditer('"unescapedUrl":"(.+?)","url":"', udict)
- matches = []
- for match in a:
- match = str(match.group(1))
- matches.append(match)
- link = random.choice(matches)
- try:
- link = link.replace("https", "http")
- except:
- print("Random choice isn't SSL.")
- if args: room.message("%s I found: %s" % (user.name), link), True
- except Exception as e:
- room.message("%s I'm sorry, I was unable to find anything for search term: %s :|" % (user.name), args), True
- print(e)
- #say a~
- elif cmd == "say":
- if args:
- room.message(args+"")
- else:
- room.message("Baka yaroo :v")
- ##List Mods
- #List of Mods and Owner name in the current room you're in
- elif cmd == "mods":
- room.message(", ".join(room.modnames + [room.ownername]))
- #### Seen
- elif cmd == "invitegroup" or cmd == "ig":
- if len (args) > 0:
- self.pm.message(ch.RoomManager(args),"%s You have group invite! check this Chatango Group http://%s.chatango.com ." %(room.ownername[0],room.name))
- room.message("Youre invite %s now is in Accest Group. :)" % args)
- else:
- room.message("MALES")
- ##DANCE!!!!
- #Dance ? Of Course !!! ^_^
- elif cmd == "dance":
- for i, msg in enumerate(dancemoves):
- self.setTimeout(i / 2, room.message, msg)
- #### Pm
- elif cmd == "pm" or cmd == "Pm" or cmd == "PM" or cmd == "Private Message":
- data = args.split(" ", 1)
- if len(data) > 1:
- name , args = data[0], data[1]
- self.pm.message(ch.User(name), "[Pesan Penting] By - "+ user.name +" : "+args+" ")
- room.message("SUCCES SEND MESSAGE")
- #### Invite
- elif cmd == "invite" or cmd == "Invite":
- if len (args) > 0:
- self.pm.message(ch.RoomManager(args),"%s You have a group invite by ! http://%s.chatango.com ." %(owners[0],room.name))
- room.message("Invite on progress %s in Access group. :)" % args)
- else:
- room.message("Sry have problem. :3")
- #### Profile
- elif cmd == "prof" or cmd == "profile" or cmd == "Prof" or cmd == "Profile":
- try:
- args=args.lower()
- stuff=str(urlreq.urlopen("http://"+args+".chatango.com").read().decode("utf-8"))
- crap, age = stuff.split('<span class="profile_text"><strong>Age:</strong></span></td><td><span class="profile_text">', 1)
- age, crap = age.split('<br /></span>', 1)
- crap, gender = stuff.split('<span class="profile_text"><strong>Gender:</strong></span></td><td><span class="profile_text">', 1)
- gender, crap = gender.split(' <br /></span>', 1)
- if gender == 'M':
- gender = 'Male'
- elif gender == 'F':
- gender = 'Female'
- else:
- gender = '?'
- crap, location = stuff.split('<span class="profile_text"><strong>Location:</strong></span></td><td><span class="profile_text">', 1)
- location, crap = location.split(' <br /></span>', 1)
- crap,mini=stuff.split("<span class=\"profile_text\"><!-- google_ad_section_start -->",1)
- mini,crap=mini.split("<!-- google_ad_section_end --></span>",1)
- mini=mini.replace("<img","<!")
- picture = '<a href="http://fp.chatango.com/profileimg/' + args[0] + '/' + args[1] + '/' + args + '/full.jpg" style="z-index:59" target="_blank">http://fp.chatango.com/profileimg/' + args[0] + '/' + args[1] + '/' + args + '/full.jpg</a>'
- prodata = '<br/> <a href="http://chatango.com/fullpix?' + args + '" target="_blank">' + picture + '<br/><br/> Age: '+ age + ' <br/> Gender: ' + gender + ' <br/> Location: ' + location + '' '<br/> <a href="http://' + args + '.chatango.com" target="_blank"><u>Chat With User</u></a> ' "<br/><br/> "+ mini
- room.message(prodata,True)
- except:
- room.message(""+args+" doesn't exist o.o ")
- #
- if cmd =="wordtoday" or cmd=="wt":
- if user.name in owners:
- if user.name in wordtodaytime:
- w = json.loads(wordtodaytime[user.name])
- if time.time() < w:
- w = int(w) - int(time.time())
- minute = 60
- hour = minute * 60
- day = hour * 24
- days = int(w / day)
- hours = int((w % day) / hour)
- minutes = int((w % hour) / minute)
- seconds = int(w % minute)
- 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" )
- room.message("You can use wordtoday after <font color='#9999FF'>%s</font> (~^o^)~ "% string,True)
- return
- if urank(user.name) >= 1:
- x=(random.choice(["sadness","happines","yaoi","yuri","horny","nice","bad","bastard","young","lazy","poor","rich","ugly","handshome","beautiful","good","gay","keep calm","arrogant","naughty","special","sweet","tits","areola","pupy","ass","sunny","dizzy","nude","old","lifeless","dying",'death',"impotent","cancer"]))
- room.message("Dear "+sntonick(user.name)+" Your word today is : <b><font color='#FF9966'>"+str(x)+"</font></b>",True)
- wordtodaytime[user.name] = json.dumps(time.time()+1200)
- ##Check if Mod
- #not really important
- elif cmd == "ismod":
- user = ch.User(args)
- if room.getLevel(user) > 0:
- room.message("yesh")
- else:
- room.message("nope")
- except Exception as e:
- try:
- et, ev, tb = sys.exc_info()
- lineno = tb.tb_lineno
- fn = tb.tb_frame.f_code.co_filename
- room.message("[Expectation Failed]kesalahan di sekitar Line %i"(fn, lineno, str(e)))
- return
- except:
- room.message("Undescribeable error detected !!")
- return
- def onFloodWarning(self, room):
- room.reconnect()
- def onJoin(self, room, user):
- print(user.name + " joined the chat!")
- if user.name =="wildanchuan":
- room.message("Masta Wildan now ON-LINE")
- else :
- room.message("@" + user.name + " Telah memasuki room chat")
- def onLeave(self, room, user):
- print(user.name + " leave the chat!")
- room.message("@" + user.name + " Telah keluar dari room chat.!")
- def onUserCountChange(self, room):
- print("jumlah user berubah")
- room.message("jadi,sekarang jumlah user: " + str(room.usercount))
- def onMessageDelete(self, room, user, msg):
- print("MESSAGE DELETED: " + user.name + ": " + msg.body)
- if __name__ == "__main__": TestBot.easy_start()
- #The End!!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement