Advertisement
Thelorgoreng

Chatango bot commands :)

Aug 1st, 2015
1,462
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 12.86 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 cmd == "invite" or cmd == "Invite":
  123.         if len (args) > 0:
  124.             self.pm.message(ch.RoomManager(args),"%s You have a group invite by ! http://%s.chatango.com ." %(owners[0],room.name))
  125.             room.message("Invite on progress %s in Access group. :)" % args)
  126.         else:
  127.             room.message("Sry have problem. :3")
  128. ##You may want/need to evaluate something about your bot.
  129.       if cmd == "ev" or cmd == "eval" or cmd == "e":
  130.           ret = eval(args)
  131.           if ret == None:
  132.             room.message("Done.")
  133.             return
  134.           room.message(str(ret))
  135.      
  136.         ##Say
  137.         #Make your bot say what you want
  138.  
  139.       elif cmd == "afk":
  140.         jawab = ["See u"]
  141.         room.message(random.choice(jawab)+" @"+user.name)
  142.       elif cmd == "crunch":
  143.         jawab = ["https://31.media.tumblr.com/50dcec4f797eb86ea483558695c874f1/tumblr_nqru66BNYc1u8lwqgo1_500.gif"]
  144.         room.message(random.choice(jawab)+" @"+user.name)
  145.       elif cmd == "nja":
  146.         jawab = ["Njaa ne ^^"]
  147.         room.message(random.choice(jawab)+" @"+user.name)
  148.       elif cmd == "coeghd":
  149.         jawab = ["anda kenapa?"]
  150.         room.message(random.choice(jawab)+" @"+user.name)
  151.       elif cmd == ":v":
  152.         jawab = ["emoticon dewa"]
  153.         room.message(random.choice(jawab)+" @"+user.name)
  154.       elif cmd == "lebaran":
  155.         jawab = ["minal aidzin wal faizin kk"]
  156.         room.message(random.choice(jawab)+" @"+user.name)
  157.       elif cmd == "gue tamvan gak ?":
  158.         jawab = ["kaga","tamvan","jelek","biasa aja"]
  159.         room.message(random.choice(jawab)+" @"+user.name)
  160.       elif cmd == "hmm":
  161.         jawab = ["maho detcted"]
  162.         room.message(random.choice(jawab)+" @"+user.name)
  163.       elif cmd == "konbanwa":
  164.         jawab = ["tidur sana jangan ngalong :v"]
  165.         room.message(random.choice(jawab)+" @"+user.name)
  166.       elif cmd == "naruto":
  167.         jawab = ["adalah anime yang selalu flash back"]
  168.         room.message(random.choice(jawab)+" @"+user.name)
  169.       elif cmd == "bnp":
  170.         jawab = ["erorr forbidden access denied"]
  171.         room.message(random.choice(jawab)+" @"+user.name)
  172.         ##Random User
  173.         #What's this for ? this one cmd will make your boy say the name of a random user in a room
  174.       if cmd == "randomuser":
  175.         room.message(random.choice(room.usernames))
  176.  
  177.         ##Check Level
  178.         #This one cmd is tho make your bot say your mod level in the current room you're in
  179.       elif cmd == "mylvl":
  180.         room.message("Your mod level: %i" %(room.getLevel(user)))
  181.  
  182.         ##List Mods
  183.         #List of Mods and Owner name in the current room you're in
  184.       elif cmd == "mods":
  185.         room.message(", ".join(room.modnames + [room.ownername]))
  186.         #### Seen
  187.       elif cmd == "invitegroup" or cmd == "ig":
  188.         if len (args) > 0:
  189.          self.pm.message(ch.RoomManager(args),"%s You have group invite! check this Chatango Group http://%s.chatango.com ." %(room.ownername[0],room.name))
  190.          room.message("Youre invite %s now is in Accest Group. :)" % args)
  191.         else:
  192.           room.message("gak mau ah nginvite dia")
  193.         ##DANCE!!!!
  194.         #Dance ? Of Course !!! ^_^
  195.       elif cmd == "dance":
  196.         for i, msg in enumerate(dancemoves):
  197.           self.setTimeout(i / 2, room.message, msg)
  198.                #### Pm
  199.       elif cmd == "pm" or cmd == "Pm" or cmd == "PM" or cmd == "Private Message":
  200.         data = args.split(" ", 1)
  201.         if len(data) > 1:
  202.           name , args = data[0], data[1]
  203.           self.pm.message(ch.User(name), "[Private.Message] By - "+user.name+" : "+args+" ")
  204.           room.message("Has been sent to "+name+"")
  205.         #### Invite
  206.       elif cmd == "invite" or cmd == "Invite":
  207.         if len (args) > 0:
  208.             self.pm.message(ch.RoomManager(args),"%s You have a group invite by ! http://%s.chatango.com ." %(owners[0],room.name))
  209.             room.message("Invite on progress %s in Access group. :)" % args)
  210.         else:
  211.             room.message("Sry have problem. :3")
  212.         #### Profile
  213.       elif cmd == "prof" or cmd == "profile" or cmd == "Prof" or cmd == "Profile":
  214.         try:
  215.           args=args.lower()
  216.           stuff=str(urlreq.urlopen("http://"+args+".chatango.com").read().decode("utf-8"))
  217.           crap, age = stuff.split('<span class="profile_text"><strong>Age:</strong></span></td><td><span class="profile_text">', 1)
  218.           age, crap = age.split('<br /></span>', 1)
  219.           crap, gender = stuff.split('<span class="profile_text"><strong>Gender:</strong></span></td><td><span class="profile_text">', 1)
  220.           gender, crap = gender.split(' <br /></span>', 1)
  221.           if gender == 'M':
  222.               gender = 'Male'
  223.           elif gender == 'F':
  224.               gender = 'Female'
  225.           else:
  226.               gender = '?'
  227.           crap, location = stuff.split('<span class="profile_text"><strong>Location:</strong></span></td><td><span class="profile_text">', 1)
  228.           location, crap = location.split(' <br /></span>', 1)
  229.           crap,mini=stuff.split("<span class=\"profile_text\"><!-- google_ad_section_start -->",1)
  230.           mini,crap=mini.split("<!-- google_ad_section_end --></span>",1)
  231.           mini=mini.replace("<img","<!")
  232.           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>'
  233.           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
  234.           room.message(prodata,True)
  235.         except:
  236.           room.message(""+args+" doesn't exist o.o ")
  237.         #
  238.         if cmd =="wordtoday" or cmd=="wt":
  239.             if user.name in owners:
  240.               if user.name in wordtodaytime:
  241.                 w = json.loads(wordtodaytime[user.name])
  242.                 if time.time() < w:
  243.                   w = int(w) - int(time.time())
  244.                   minute = 60
  245.                   hour = minute * 60
  246.                   day = hour * 24
  247.                   days =  int(w / day)
  248.                   hours = int((w % day) / hour)
  249.                   minutes = int((w % hour) / minute)
  250.                   seconds = int(w % minute)
  251.                   string = ""
  252.                   if days > 0:
  253.                     string += str(days) + " " + (days == 1 and "day" or "days" ) + ", "
  254.                   if len(string) > 0 or hours > 0:
  255.                     string += str(hours) + " " + (hours == 1 and "hour" or "hours" ) + ", "
  256.                   if len(string) > 0 or minutes > 0:
  257.                     string += str(minutes) + " " + (minutes == 1 and "minute" or "minutes" ) + ", "
  258.                   string += str(seconds) + " " + (seconds == 1 and "second" or "seconds" )
  259.                   room.message("You can use wordtoday after <font color='#9999FF'>%s</font>  (~^o^)~ "% string,True)
  260.                   return
  261.               if urank(user.name) >= 1:
  262.                 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"]))
  263.                 room.message("Dear "+sntonick(user.name)+" Your word today is : <b><font color='#FF9966'>"+str(x)+"</font></b>",True)
  264.                 wordtodaytime[user.name] = json.dumps(time.time()+1200)
  265.  
  266.         ##Check if Mod
  267.         #not really important
  268.       elif cmd == "ismod":
  269.         user = ch.User(args)
  270.         if room.getLevel(user) > 0:
  271.           room.message("yesh")
  272.         else:
  273.           room.message("nope")
  274.    except Exception as e:
  275.       try:
  276.         et, ev, tb = sys.exc_info()
  277.         lineno = tb.tb_lineno
  278.         fn = tb.tb_frame.f_code.co_filename
  279.         room.message("[Expectation Failed] %s Line %i - %s"% (fn, lineno, str(e)))
  280.         return
  281.       except:
  282.         room.message("Undescribeable error detected !!")
  283.         return
  284.  
  285.   ##Other Crap here, Dont worry about it
  286.  
  287.   def onFloodWarning(self, room):
  288.     room.reconnect()
  289.  
  290.   def onJoin(self, room, user):
  291.    print(user.name + " joined the chat!")
  292.  
  293.   def onLeave(self, room, user):
  294.    print(user.name + " left the chat!")
  295.  
  296.   def onUserCountChange(self, room):
  297.     print("users: " + str(room.usercount))
  298.  
  299.   def onMessageDelete(self, room, user, msg):
  300.     print("MESSAGE DELETED: " + user.name + ": " + msg.body)
  301.  
  302.  
  303. if __name__ == "__main__": TestBot.easy_start()
  304.  
  305.     #The End!!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement