Advertisement
Thelorgoreng

ExampleBot

Aug 9th, 2015
466
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 12.73 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.  
  56. # implied command?    
  57. # call bot name with command after
  58. # call bot name with command after
  59. #Setting Pretty Colors
  60. #Font setting for your bot
  61.  
  62. class TestBot(ch.RoomManager):
  63.   def onInit(self):
  64.     self.setNameColor("F9F")
  65.     self.setFontColor("F33")
  66.     self.setFontFace("1")
  67.     self.setFontSize(13)
  68.     self.enableBg()
  69.     self.enableRecording()
  70. ##### Pars Def
  71.   def pars(args):
  72.           args=args.lower()
  73.           userlist = roomUsers()
  74.           for name in userlist:
  75.             if args in name:return name  
  76. ##Connecting Crap
  77. #This is what will be printed on your python console when event called
  78.  
  79.   def onConnect(self, room):
  80.     print("Connected")
  81.  
  82.   def onReconnect(self, room):
  83.     print("Reconnected")
  84.  
  85.   def onDisconnect(self, room):
  86.     print("Disconnected")
  87.  
  88.  
  89. ##Ignore this, you dont need to worry about this
  90. #Well, you can actually take a little time to look at it and learn something
  91.   def onMessage(self, room, user, message):
  92.   #### Comenzi fara prefix
  93.    if message.body.startswith("test"):
  94.      room.message("Test request granted :v")
  95.    if message.body.startswith("woi"):
  96.      room.message("Apa njay? :v :)")
  97.    if message.body.startswith("sepi"):
  98.      room.message("I'am here. :)")
  99.    if message.body.startswith("siang"):
  100.      room.message("Hello, siang :)")
  101.    if message.body.startswith("malam"):
  102.      room.message("Hello, malam :)")
  103.    if message.body.startswith("konbanwa"):
  104.      room.message("Hello, konbanwa")
  105.    if message.body.startswith("oyasumi"):
  106.      room.message("Hello, oyasumi :v")
  107.    if message.body.startswith("konichiwa"):
  108.      room.message("Hello, konichiwa :)")
  109.    if message.body.startswith("jam"):
  110.       room.message(strftime("%H:%M:%S", localtime()))      
  111.    if message.body.startswith("tanggal"):
  112.      room.message(strftime ("HARI: %a,%d-%b-%Y ", localtime()))
  113.    if message.body.startswith("siapa yang "):
  114.      room.message(random.choice(room.usernames))
  115.    if message.body.startswith("lol"):
  116.      room.message("Yea lol  @"+user.name+".")
  117.      room.message(random.choice(jawab)+" @"+user.name)
  118. ##COMMANDS!
  119. #Setting up commands for yer bot
  120.  #commands section
  121. #### Invite
  122.      if message.body[0] == "/":
  123.       data = message.body[1:].split(" ", 1)
  124.       if len(data) > 1:
  125.         cmd, args = data[0], data[1]
  126.       else:
  127.         cmd, args = data[0], ""
  128.       if cmd == "invite" or cmd == "Invite":
  129.         if len (args) > 0:
  130.             self.pm.message(ch.RoomManager(args),"%s You have a group invite by ! http://%s.chatango.com ." %(owners[0],room.name))
  131.             room.message("Invite on progress %s in Access group. :)" % args)
  132.         else:
  133.             room.message("Sry have problem. :3")
  134. ##You may want/need to evaluate something about your bot.
  135.       if cmd == "ev" or cmd == "eval" or cmd == "e":
  136.           ret = eval(args)
  137.           if ret == None:
  138.             room.message("Done.")
  139.             return
  140.           room.message(str(ret))
  141.      
  142.         ##Say
  143.         #Make your bot say what you want
  144.  
  145.       elif cmd == "afk":
  146.         jawab = ["See u"]
  147.         room.message(random.choice(jawab)+" @"+user.name)
  148.       elif cmd == "crunch":
  149.         jawab = ["https://31.media.tumblr.com/50dcec4f797eb86ea483558695c874f1/tumblr_nqru66BNYc1u8lwqgo1_500.gif"]
  150.         room.message(random.choice(jawab)+" @"+user.name)
  151.       elif cmd == "nja":
  152.         jawab = ["Njaa ne ^^"]
  153.         room.message(random.choice(jawab)+" @"+user.name)
  154.       elif cmd == "coeghd":
  155.         jawab = ["anda kenapa?"]
  156.         room.message(random.choice(jawab)+" @"+user.name)
  157.       elif cmd == ":v":
  158.         jawab = ["emoticon dewa"]
  159.         room.message(random.choice(jawab)+" @"+user.name)
  160.       elif cmd == "lebaran":
  161.         jawab = ["minal aidzin wal faizin kk"]
  162.         room.message(random.choice(jawab)+" @"+user.name)
  163.       elif cmd == "gue tamvan gak ?":
  164.         jawab = ["kaga","tamvan","jelek","biasa aja"]
  165.         room.message(random.choice(jawab)+" @"+user.name)
  166.       elif cmd == "hmm":
  167.         jawab = ["maho detcted"]
  168.         room.message(random.choice(jawab)+" @"+user.name)
  169.       elif cmd == "konbanwa":
  170.         jawab = ["tidur sana jangan ngalong :v"]
  171.         room.message(random.choice(jawab)+" @"+user.name)
  172.       elif cmd == "naruto":
  173.         jawab = ["adalah anime yang selalu flash back"]
  174.         room.message(random.choice(jawab)+" @"+user.name)
  175.       elif cmd == "bnp":
  176.         jawab = ["erorr forbidden access denied"]
  177.         room.message(random.choice(jawab)+" @"+user.name)
  178.         ##Random User
  179.         #What's this for ? this one cmd will make your boy say the name of a random user in a room
  180.       if cmd == "randomuser":
  181.         room.message(random.choice(room.usernames))
  182.  
  183.         ##Check Level
  184.         #This one cmd is tho make your bot say your mod level in the current room you're in
  185.       elif cmd == "mylvl":
  186.         room.message("Your mod level: %i" %(room.getLevel(user)))
  187.  
  188.         ##List Mods
  189.         #List of Mods and Owner name in the current room you're in
  190.       elif cmd == "mods":
  191.         room.message(", ".join(room.modnames + [room.ownername]))
  192.         #### Seen
  193.       elif cmd == "invitegroup" or cmd == "ig":
  194.         if len (args) > 0:
  195.          self.pm.message(ch.RoomManager(args),"%s You have group invite! check this Chatango Group http://%s.chatango.com ." %(room.ownername[0],room.name))
  196.          room.message("Youre invite %s now is in Accest Group. :)" % args)
  197.         else:
  198.           room.message("gak mau ah nginvite dia")
  199.         ##DANCE!!!!
  200.         #Dance ? Of Course !!! ^_^
  201.       elif cmd == "dance":
  202.         for i, msg in enumerate(dancemoves):
  203.           self.setTimeout(i / 2, room.message, msg)
  204.                #### Pm
  205.       elif cmd == "pm" or cmd == "Pm" or cmd == "PM" or cmd == "Private Message":
  206.         data = args.split(" ", 1)
  207.         if len(data) > 1:
  208.           name , args = data[0], data[1]
  209.           self.pm.message(ch.User(name), "[Private.Message] By - "+user.name+" : "+args+" ")
  210.           room.message("Has been sent to "+name+"")
  211.         #### Invite
  212.       elif cmd == "invite" or cmd == "Invite":
  213.         if len (args) > 0:
  214.             self.pm.message(ch.RoomManager(args),"%s You have a group invite by ! http://%s.chatango.com ." %(owners[0],room.name))
  215.             room.message("Invite on progress %s in Access group. :)" % args)
  216.         else:
  217.             room.message("Sry have problem. :3")
  218.         #### Profile
  219.       elif cmd == "prof" or cmd == "profile" or cmd == "Prof" or cmd == "Profile":
  220.         try:
  221.           args=args.lower()
  222.           stuff=str(urlreq.urlopen("http://"+args+".chatango.com").read().decode("utf-8"))
  223.           crap, age = stuff.split('<span class="profile_text"><strong>Age:</strong></span></td><td><span class="profile_text">', 1)
  224.           age, crap = age.split('<br /></span>', 1)
  225.           crap, gender = stuff.split('<span class="profile_text"><strong>Gender:</strong></span></td><td><span class="profile_text">', 1)
  226.           gender, crap = gender.split(' <br /></span>', 1)
  227.           if gender == 'M':
  228.               gender = 'Male'
  229.           elif gender == 'F':
  230.               gender = 'Female'
  231.           else:
  232.               gender = '?'
  233.           crap, location = stuff.split('<span class="profile_text"><strong>Location:</strong></span></td><td><span class="profile_text">', 1)
  234.           location, crap = location.split(' <br /></span>', 1)
  235.           crap,mini=stuff.split("<span class=\"profile_text\"><!-- google_ad_section_start -->",1)
  236.           mini,crap=mini.split("<!-- google_ad_section_end --></span>",1)
  237.           mini=mini.replace("<img","<!")
  238.           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>'
  239.           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
  240.           room.message(prodata,True)
  241.         except:
  242.           room.message(""+args+" doesn't exist o.o ")
  243.         #
  244.         if cmd =="wordtoday" or cmd=="wt":
  245.             if user.name in owners:
  246.               if user.name in wordtodaytime:
  247.                 w = json.loads(wordtodaytime[user.name])
  248.                 if time.time() < w:
  249.                   w = int(w) - int(time.time())
  250.                   minute = 60
  251.                   hour = minute * 60
  252.                   day = hour * 24
  253.                   days =  int(w / day)
  254.                   hours = int((w % day) / hour)
  255.                   minutes = int((w % hour) / minute)
  256.                   seconds = int(w % minute)
  257.                   string = ""
  258.                   if days > 0:
  259.                     string += str(days) + " " + (days == 1 and "day" or "days" ) + ", "
  260.                   if len(string) > 0 or hours > 0:
  261.                     string += str(hours) + " " + (hours == 1 and "hour" or "hours" ) + ", "
  262.                   if len(string) > 0 or minutes > 0:
  263.                     string += str(minutes) + " " + (minutes == 1 and "minute" or "minutes" ) + ", "
  264.                   string += str(seconds) + " " + (seconds == 1 and "second" or "seconds" )
  265.                   room.message("You can use wordtoday after <font color='#9999FF'>%s</font>  (~^o^)~ "% string,True)
  266.                   return
  267.               if urank(user.name) >= 1:
  268.                 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"]))
  269.                 room.message("Dear "+sntonick(user.name)+" Your word today is : <b><font color='#FF9966'>"+str(x)+"</font></b>",True)
  270.                 wordtodaytime[user.name] = json.dumps(time.time()+1200)
  271.  
  272.         ##Check if Mod
  273.         #not really important
  274.       elif cmd == "ismod":
  275.         user = ch.User(args)
  276.         if room.getLevel(user) > 0:
  277.           room.message("yesh")
  278.         else:
  279.           room.message("nope")
  280.         return
  281.  
  282.   ##Other Crap here, Dont worry about it
  283.  
  284.   def onFloodWarning(self, room):
  285.     room.reconnect()
  286.  
  287.   def onJoin(self, room, user):
  288.    print(user.name + " joined the chat!")
  289.  
  290.   def onLeave(self, room, user):
  291.    print(user.name + " left the chat!")
  292.  
  293.   def onUserCountChange(self, room):
  294.     print("users: " + str(room.usercount))
  295.  
  296.   def onMessageDelete(self, room, user, msg):
  297.     print("MESSAGE DELETED: " + user.name + ": " + msg.body)
  298.  
  299.  
  300. if __name__ == "__main__": TestBot.easy_start()
  301.  
  302.     #The End!!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement