Thelorgoreng

For kantaisenkan

Oct 2nd, 2015
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 14.97 KB | None | 0 0
  1. ############################################################################
  2. ############################################################################
  3. ####    Getting Started Bot                                     ############
  4. ####    File            = ExampleBot.py                         ############    
  5. ####    Originaly by    = clonerxyz                             ############
  6. ####    Edited by       = Thelorgorenk                          ############
  7. ####    you can PM for info about making a chatango             ############
  8. ####    bot in http://thelorgorenk.chatango.com, and you can    ############
  9. ####    and you can also chat in :                              ############
  10. ####            http://khususme.chatango.com                    ############
  11. ####    Last update:                                            ############
  12. ####            3.21 AM August, 1 2015 by Thelorgorenk          ############
  13. ############################################################################
  14. ############################################################################
  15. ##Importing Random Crap xD
  16. #here you can see that you're importing ch library
  17.  
  18. import ch
  19. import random
  20. import sys
  21. import json
  22. import time
  23. import re
  24. if sys.version_info[0] > 2:
  25.   import urllib.request as urlreq
  26. else:
  27.   import urllib2 as urlreq
  28. from time import localtime, strftime
  29. wordtodaytime = dict()
  30. ##Dance moves!
  31. #kinda useless
  32.  
  33. dancemoves = [
  34.   "(>^.^)>",
  35.   "(v^.^)v",
  36. ]
  37. song = [
  38.   "Dirimu, dirimulah! Orang yang beriku senyum ini",
  39. "Jika kita bisa membuat air mata yang bersinar, itu 'kan 'jadi bintang jatuh",
  40. "Tanganmu t'lah terluka, tapi jangan pernah lepaskannya lagi",
  41. "Dari langit yang terpenuhi keinginan, hari esok 'kan segera datang",
  42.  
  43. "Cahya yang membimbingku adalah dirimu",
  44. "Dan aku pun ditarik karenanya",
  45. "Sebelum kusadarim kita mulai sebrangi jalan itu",
  46. "Sekaranglah saatnya! Jikalau kita hanya bisa bersinar di sini",
  47. ]
  48.  
  49. bete = [
  50. "kunci",
  51. ]
  52. pagi = [
  53. "ohayou oni-chan",
  54. ]
  55. whitelist = []
  56. f = open("whitelist.txt", "r") #read-only
  57. print("[INF]Loading Players...")
  58. time.sleep(1)
  59. for name in f.readlines():
  60.   if len(name.strip())>0: whitelist.append(name.strip())
  61. f.close()
  62. # implied command?    
  63. # call bot name with command after
  64. # call bot name with command after
  65. #Setting Pretty Colors
  66. #Font setting for your bot
  67. def tube(args):
  68.   try:
  69.     search = args.split()
  70.     url = urlreq.urlopen("https://www.googleapis.com/youtube/v3/search?q=%s&part=snippet&key=AIzaSyBSnh-sIjd97_FmQVzlyGbcaYXuSt_oh84" % "+".join(search))
  71.     udict = url.read().decode('utf-8')
  72.     data = json.loads(udict)
  73.     rest = []
  74.     for f in data["items"]:
  75.       rest.append(f)
  76.  
  77.     d = random.choice(rest)
  78.     link = "http://www.youtube.com/watch?v=" + d["id"]["videoId"]
  79.     videoid = d["id"]["videoId"]
  80.     title = d["snippet"]["title"]
  81.     uploader = d["snippet"]["channelTitle"]
  82.     descript = d["snippet"]['description']
  83.     count    = d["snippet"]["publishedAt"]
  84.     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])
  85.   except Exception as e:
  86.     return str(e)
  87. class TestBot(ch.RoomManager):
  88.   def onInit(self):
  89.     self.setNameColor("F9F")
  90.     self.setFontColor("F33")
  91.     self.setFontFace("1")
  92.     self.setFontSize(13)
  93.     self.enableBg()
  94.     self.enableRecording()
  95. ##### Pars Def
  96.   def pars(args):
  97.           args=args.lower()
  98.           userlist = roomUsers()
  99.           for name in userlist:
  100.             if args in name:return name  
  101. ##Connecting Crap
  102. #This is what will be printed on your python console when event called
  103.  
  104.   def onConnect(self, room):
  105.     print("Connected")
  106.  
  107.   def onReconnect(self, room):
  108.     print("Reconnected")
  109.  
  110.   def onDisconnect(self, room):
  111.     print("Disconnected")
  112.  
  113.  
  114. ##Ignore this, you dont need to worry about this
  115. #Well, you can actually take a little time to look at it and learn something
  116.   def onMessage(self, room, user, message):
  117.   #### Comenzi fara prefix
  118.    if message.body.startswith("/wl me"):
  119.       if user.name not in whitelist:
  120.         whitelist.append(user.name)
  121.         room.message(user.name+" can use me now.")
  122.       else:
  123.         room.message("You're already in whitelist :|")
  124.    if message.body.startswith("test"):
  125.      room.message("Test request granted :)")
  126.    if message.body.startswith("bot"):
  127.      room.message("What's upp B)")
  128.    if message.body.startswith("woi"):
  129.      room.message("Apa njay? ngefans ye :v")
  130.    if message.body.startswith("kamfret lo"):
  131.      room.message("coeg lo")
  132.    if message.body.startswith("lalala"):
  133.      room.message("lululululululul :v")
  134.    if message.body.startswith("beliin makanan"):
  135.      room.message("Anjrit. Beli ndiri sono!")
  136.    if message.body.startswith("afk"):
  137.      room.message("See ya later bro B)")
  138.    if message.body.startswith("back"):
  139.      room.message("Yo, bro~ Welcome back B)")
  140.    if message.body.startswith("off"):
  141.      room.message("Jaa nee~ ")
  142.    if message.body.startswith("sepi"):
  143.      room.message("bakaa T-T lupa ya kalo ada aku disini :)")
  144.    if message.body.startswith("siang"):
  145.      room.message("Siang bro B)")
  146.    if message.body.startswith("ohayou"):
  147.      room.message("ohayou :)")
  148.    if message.body.startswith("malam"):
  149.      room.message("Malam bro B)")
  150.    if message.body.startswith("konbanwa"):
  151.      room.message("konbanwa :)")
  152.    if message.body.startswith("oyasumi"):
  153.      room.message("Oyasumi :)")
  154.    if message.body.startswith("konnichiwa"):
  155.      room.message("Konnichiwa :)")
  156.    if message.body.startswith("jam"):
  157.      room.message(strftime("%H:%M:%S", localtime()))      
  158.    if message.body.startswith("tanggal"):
  159.      room.message(strftime ("HARI: %a,%d-%b-%Y ", localtime()))
  160.    if message.body.startswith("siapa yang "):
  161.      room.message(random.choice(room.usernames))
  162.    if message.body.startswith("lol"):
  163.      room.message("Yea lol  @"+user.name+".")
  164.      room.message(random.choice(jawab)+" @"+user.name)
  165. ##COMMANDS!
  166. #Setting up commands for yer bot
  167.  #commands section
  168. #### Invite
  169.      if message.body[0] == "/":
  170.       data = message.body[1:].split(" ", 1)
  171.       if len(data) > 1:
  172.         cmd, args = data[0], data[1]
  173.       else:
  174.         cmd, args = data[0], ""
  175.         if user.name not in whitelist: return
  176.  
  177.       if cmd == "yt":
  178.         room.message(tube(args),True)
  179.       if cmd == "invite" or cmd == "Invite":
  180.         if len (args) > 0:
  181.             self.pm.message(ch.RoomManager(args),"%s You have a group invite by ! http://%s.chatango.com ." %(owners[0],room.name))
  182.             room.message("Invite on progress %s in Access group. :)" % args)
  183.         else:
  184.             room.message("Sry have problem. :3")
  185. ##You may want/need to evaluate something about your bot.
  186.      
  187.       if cmd == "ev" or cmd == "eval" or cmd == "e":
  188.           ret = eval(args)
  189.           if ret == None:
  190.             room.message("Done.")
  191.             return
  192.           room.message(str(ret))
  193.      
  194.         ##Say
  195.         #Make your bot say what you want
  196.  
  197.       elif cmd == "afk":
  198.         jawab = ["See u"]
  199.         room.message(random.choice(jawab)+" @"+user.name)
  200.       elif cmd == "crunch":
  201.         jawab = ["https://31.media.tumblr.com/50dcec4f797eb86ea483558695c874f1/tumblr_nqru66BNYc1u8lwqgo1_500.gif"]
  202.         room.message(random.choice(jawab)+" @"+user.name)
  203.       elif cmd == "nja":
  204.         jawab = ["Njaa ne ^^"]
  205.         room.message(random.choice(jawab)+" @"+user.name)
  206.       elif cmd == "coeghd":
  207.         jawab = ["anda kenapa?"]
  208.         room.message(random.choice(jawab)+" @"+user.name)
  209.       elif cmd == ":v":
  210.         jawab = ["emoticon dewa"]
  211.         room.message(random.choice(jawab)+" @"+user.name)
  212.       elif cmd == "lebaran":
  213.         jawab = ["minal aidzin wal faizin kk"]
  214.         room.message(random.choice(jawab)+" @"+user.name)
  215.       elif cmd == "gue tamvan gak ?":
  216.         jawab = ["kaga","tamvan","jelek","biasa aja"]
  217.         room.message(random.choice(jawab)+" @"+user.name)
  218.       elif cmd == "hmm":
  219.         jawab = ["maho detected"]
  220.         room.message(random.choice(jawab)+" @"+user.name)
  221.       elif cmd == "konbanwa":
  222.         jawab = ["tidur sana jangan ngalong :v"]
  223.         room.message(random.choice(jawab)+" @"+user.name)
  224.       elif cmd == "naruto":
  225.         jawab = ["adalah anime yang selalu flash back"]
  226.         room.message(random.choice(jawab)+" @"+user.name)
  227.       elif cmd == "bnp":
  228.         jawab = ["erorr forbidden access denied"]
  229.         room.message(random.choice(jawab)+" @"+user.name)
  230.         ##Random User
  231.         #What's this for ? this one cmd will make your boy say the name of a random user in a room
  232.       if cmd == "randomuser":
  233.         room.message(random.choice(room.usernames))
  234.  
  235.         ##Check Level
  236.         #This one cmd is tho make your bot say your mod level in the current room you're in
  237.       elif cmd == "mylvl":
  238.         room.message("Your mod level: %i" %(room.getLevel(user)))
  239.  
  240.         ##List Mods
  241.         #List of Mods and Owner name in the current room you're in
  242.       elif cmd == "mods":
  243.         room.message(", ".join(room.modnames + [room.ownername]))
  244.         #### Seen
  245.       elif cmd == "invitegroup" or cmd == "ig":
  246.         if len (args) > 0:
  247.          self.pm.message(ch.RoomManager(args),"%s You have group invite! check this Chatango Group http://%s.chatango.com ." %(room.ownername[0],room.name))
  248.          room.message("Youre invite %s now is in Accest Group. :)" % args)
  249.         else:
  250.           room.message("gak mau ah nginvite dia")
  251.         ##DANCE!!!!
  252.         #Dance ? Of Course !!! ^_^
  253.       elif cmd == "dance":
  254.         for i, msg in enumerate(dancemoves):
  255.           self.setTimeout(i / 2, room.message, msg)
  256.                #### Pm
  257.       elif cmd == "pm" or cmd == "Pm" or cmd == "PM" or cmd == "Private Message":
  258.         data = args.split(" ", 1)
  259.         if len(data) > 1:
  260.           name , args = data[0], data[1]
  261.           self.pm.message(ch.User(name), "[Private.Message] By - "+user.name+" : "+args+" ")
  262.           room.message("Has been sent to "+name+"")
  263.         #### Invite
  264.       elif cmd == "invite" or cmd == "Invite":
  265.         if len (args) > 0:
  266.             self.pm.message(ch.RoomManager(args),"%s You have a group invite by ! http://%s.chatango.com ." %(owners[0],room.name))
  267.             room.message("Invite on progress %s in Access group. :)" % args)
  268.         else:
  269.             room.message("Sry have problem. :3")
  270.         #### Profile
  271.       elif cmd == "prof" or cmd == "profile" or cmd == "Prof" or cmd == "Profile":
  272.         try:
  273.           args=args.lower()
  274.           stuff=str(urlreq.urlopen("http://"+args+".chatango.com").read().decode("utf-8"))
  275.           crap, age = stuff.split('<span class="profile_text"><strong>Age:</strong></span></td><td><span class="profile_text">', 1)
  276.           age, crap = age.split('<br /></span>', 1)
  277.           crap, gender = stuff.split('<span class="profile_text"><strong>Gender:</strong></span></td><td><span class="profile_text">', 1)
  278.           gender, crap = gender.split(' <br /></span>', 1)
  279.           if gender == 'M':
  280.               gender = 'Male'
  281.           elif gender == 'F':
  282.               gender = 'Female'
  283.           else:
  284.               gender = '?'
  285.           crap, location = stuff.split('<span class="profile_text"><strong>Location:</strong></span></td><td><span class="profile_text">', 1)
  286.           location, crap = location.split(' <br /></span>', 1)
  287.           crap,mini=stuff.split("<span class=\"profile_text\"><!-- google_ad_section_start -->",1)
  288.           mini,crap=mini.split("<!-- google_ad_section_end --></span>",1)
  289.           mini=mini.replace("<img","<!")
  290.           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>'
  291.           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
  292.           room.message(prodata,True)
  293.         except:
  294.           room.message(""+args+" doesn't exist o.o ")
  295.         #
  296.         if cmd =="wordtoday" or cmd=="wt":
  297.             if user.name in owners:
  298.               if user.name in wordtodaytime:
  299.                 w = json.loads(wordtodaytime[user.name])
  300.                 if time.time() < w:
  301.                   w = int(w) - int(time.time())
  302.                   minute = 60
  303.                   hour = minute * 60
  304.                   day = hour * 24
  305.                   days =  int(w / day)
  306.                   hours = int((w % day) / hour)
  307.                   minutes = int((w % hour) / minute)
  308.                   seconds = int(w % minute)
  309.                   string = ""
  310.                   if days > 0:
  311.                     string += str(days) + " " + (days == 1 and "day" or "days" ) + ", "
  312.                   if len(string) > 0 or hours > 0:
  313.                     string += str(hours) + " " + (hours == 1 and "hour" or "hours" ) + ", "
  314.                   if len(string) > 0 or minutes > 0:
  315.                     string += str(minutes) + " " + (minutes == 1 and "minute" or "minutes" ) + ", "
  316.                   string += str(seconds) + " " + (seconds == 1 and "second" or "seconds" )
  317.                   room.message("You can use wordtoday after <font color='#9999FF'>%s</font>  (~^o^)~ "% string,True)
  318.                   return
  319.               if urank(user.name) >= 1:
  320.                 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"]))
  321.                 room.message("Dear "+sntonick(user.name)+" Your word today is : <b><font color='#FF9966'>"+str(x)+"</font></b>",True)
  322.                 wordtodaytime[user.name] = json.dumps(time.time()+1200)
  323.  
  324.         ##Check if Mod
  325.         #not really important
  326.       elif cmd == "ismod":
  327.         user = ch.User(args)
  328.         if room.getLevel(user) > 0:
  329.           room.message("yesh")
  330.         else:
  331.           room.message("nope")
  332.         return
  333.  
  334.   ##Other Crap here, Dont worry about it
  335.  
  336.   def onFloodWarning(self, room):
  337.     room.reconnect()
  338.  
  339.   def onJoin(self, room, user):
  340.    print(user.name + " joined the chat!")
  341.  
  342.   def onLeave(self, room, user):
  343.    print(user.name + " left the chat!")
  344.  
  345.   def onUserCountChange(self, room):
  346.     print("users: " + str(room.usercount))
  347.  
  348.   def onMessageDelete(self, room, user, msg):
  349.     print("MESSAGE DELETED: " + user.name + ": " + msg.body)
  350.  
  351.  
  352. if __name__ == "__main__": TestBot.easy_start()
  353.  
  354.     #The End!!
Advertisement
Add Comment
Please, Sign In to add comment