Advertisement
Thelorgoreng

Buat sekki ( chatango bot )

Sep 3rd, 2015
697
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 33.80 KB | None | 0 0
  1. ############################################################################
  2. ############################################################################
  3. ####    Getting Started Bot                                     ############
  4. ####    File            = ExampleBot.py                         ############    
  5. ####    Originaly by    = TryHardHusky                          ############
  6. ####    Edited by       = 0rX                                   ############
  7. ####    you can PM for info about making a chatango             ############
  8. ####    bot in http://0rx.chatango.com, and you can             ############
  9. ####    and you can also chat in :                              ############
  10. ####            http://monosekai.chatango.com                   ############
  11. ####    Last update:                                            ############
  12. ####            3.21 AM July, 5 2015 by 0rx                     ############
  13. ############################################################################
  14. ############################################################################
  15. ##Importing Random Crap xD
  16. #here you can see that you're importing ch library
  17.  
  18. import ch
  19. import subprocess
  20. import re
  21. import random
  22. import math
  23. import json
  24. from random import randint
  25. import os.path
  26. import sys
  27. import cgi
  28. import urllib.request
  29. import os
  30. import traceback
  31. import urllib
  32. import http.client
  33. from urllib import parse, request
  34. from html.parser import HTMLParser
  35. import datetime
  36. import socket
  37. import binascii
  38. import winsound
  39. import __future__
  40. import threading
  41. from xml.etree import cElementTree as ET
  42. import time
  43. from datetime import date
  44. import webbrowser,re,urllib.request
  45. #urllib supp
  46. if sys.version_info[0] > 2:
  47.     import urllib.request as urlreq
  48. else:
  49.     import urllib2 as urlreq
  50.  
  51. if sys.version_info[0] > 2:
  52.   import urllib.request as urlreq
  53. else:
  54.   import urllib2 as urlreq
  55. from time import localtime, strftime
  56. wordtodaytime = dict()
  57. ##Dance moves!
  58. #kinda useless
  59. nicks=dict()#empty list
  60. f=open ("Nicks.txt","r")#r=read w=right
  61. print ("[INF]Loading Nicks...")#print
  62. time.sleep(1)
  63. for line in f.readlines():#loop through eachline and read each line
  64.     try:#try code
  65.         if len(line.strip())>0:#strip the whitespace checkgreater than 0
  66.             user , nick = json.loads(line.strip())
  67.             nicks[user] = json.dumps(nick)
  68.     except:
  69.         print("[Error]Can't load nick %s" % line)
  70.        
  71. dancemoves = [
  72.   "(>^.^)>",
  73.   "(v^.^)v",
  74. ]
  75. song = [
  76.   "Dirimu, dirimulah! Orang yang beriku senyum ini",
  77. "Jika kita bisa membuat air mata yang bersinar, itu 'kan 'jadi bintang jatuh",
  78. "Tanganmu t'lah terluka, tapi jangan pernah lepaskannya lagi",
  79. "Dari langit yang terpenuhi keinginan, hari esok 'kan segera datang",
  80.  
  81. "Cahya yang membimbingku adalah dirimu",
  82. "Dan aku pun ditarik karenanya",
  83. "Sebelum kusadarim kita mulai sebrangi jalan itu",
  84. "Sekaranglah saatnya! Jikalau kita hanya bisa bersinar di sini",
  85. ]
  86.  
  87. bete = [
  88. "kunci",
  89. ]
  90. pagi = [
  91. "ohayou oni-chan",
  92. ]
  93. info = [
  94. "======================= sekedar info aja ya master gue si clonerxyz ol  nya >senin s/d sabtu< jam >7 s/d 17< :)  kalo mau liat tutor ke >> mumucontent.blogspot.com/2015/07/make-bot-chat-chatango.html jangan merasa paling jago, di sini kita sama2 belajar :v  kalo ada member baru yang pengen belajar, tolong member yang on di bantu, terutama buat si thelorgorenk shamanthebeater :v ===========================",
  95. ]
  96.  
  97. # implied command?    
  98. # call bot name with command after
  99. # call bot name with command after
  100. def get_cpu_load():
  101.     """ Returns a list CPU Loads"""
  102.     result = []
  103.     cmd = "WMIC CPU GET LoadPercentage "
  104.     response = os.popen(cmd + ' 2>&1','r').read().strip().split("\r\n")
  105.     for load in response[1:]:
  106.        result.append(int(load))
  107.     return result
  108. #Setting Pretty Colors
  109. def saveNicks():
  110.     print("[SAVE] SAVING NICKS...")
  111.     f = open("Nicks.txt", "w")
  112.     for user in nicks:
  113.         nick = json.loads(nicks[user])
  114.         f.write(json.dumps([user, nick])+"\n")
  115.     f.close()
  116.    
  117. def sntonick(username):
  118.     user = username.lower()
  119.     if user in nicks:
  120.         nick = json.loads(nicks[user])
  121.         return nick
  122.     else:
  123.         return user
  124. def detik():
  125.     rawdata = urllib.request.urlopen("http://detik.com").read().decode()
  126.     data = re.findall('<a href="(.*?)" data-category="(.*?)" data-action="(.*?)" data-label="Artikel" ><h2>(.*?)</h2></a>', rawdata)
  127.     newset = list()
  128.     val = 1
  129.     for artikel in data:
  130.         link, title = artikel [0], artikel [3]
  131.         newset.append("[%s] %s - %s" % (val, link , title))
  132.         val += 1
  133.     return "<br/>".join(newset[0:5])
  134. #Font setting for your bot
  135. def tube(args):
  136.   try:
  137.     search = args.split()
  138.     url = urlreq.urlopen("https://www.googleapis.com/youtube/v3/search?q=%s&part=snippet&key=AIzaSyBSnh-sIjd97_FmQVzlyGbcaYXuSt_oh84" % "+".join(search))
  139.     udict = url.read().decode('utf-8')
  140.     data = json.loads(udict)
  141.     rest = []
  142.     for f in data["items"]:
  143.       rest.append(f)
  144.  
  145.     d = random.choice(rest)
  146.     link = "http://www.youtube.com/watch?v=" + d["id"]["videoId"]
  147.     videoid = d["id"]["videoId"]
  148.     title = d["snippet"]["title"]
  149.     uploader = d["snippet"]["channelTitle"]
  150.     descript = d["snippet"]['description']
  151.     count    = d["snippet"]["publishedAt"]
  152.     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])
  153.   except Exception as e:
  154.     return str(e)
  155.  
  156. class TestBot(ch.RoomManager):
  157.   def onInit(self):
  158.     self.setNameColor("F9F")
  159.     self.setFontColor("F33")
  160.     self.setFontFace("1")
  161.     self.setFontSize(14)
  162.     self.enableBg()
  163.     self.enableRecording()
  164. ##### Pars Def
  165.   def pars(args):
  166.           args=args.lower()
  167.           userlist = roomUsers()
  168.           for name in userlist:
  169.             if args in name:return name  
  170. ##Connecting Crap
  171. #This is what will be printed on your python console when event called
  172.  
  173.   def onConnect(self, room):
  174.     print("Connected")
  175.  
  176.   def onReconnect(self, room):
  177.     print("Reconnected")
  178.  
  179.   def onDisconnect(self, room):
  180.     print("Disconnected")
  181.   def onUserCountChange(self, room):
  182.     print(room.name+"USER yang lagi ON >>" + str(room.usercount))
  183.  
  184.   def onLeave(self, room, user):
  185.     print("[+] "+user.name+" yah dia pergi T_T "+room.name)
  186.     if room.usercount >= 20:
  187.       return
  188.     room.message(user.name+" dia pergi ")
  189.  
  190.   def onFloodWarning(self, room):
  191.     room.reconnect()
  192.     room.setSilent(True)
  193.     self.setTimeout(15, room.setSilent, False)
  194.     self.setTimeout(16, room.message, "I'm back.")
  195.     print("[+] Reconnecting...")
  196.  
  197.   def onMessageDelete(self, room, user, msg):
  198.     print("MESSAGE DELETED: " + user.name + ": " + msg.body)
  199.  
  200.   def rpg():
  201.     class Hero:
  202.         def __init__(self, name):
  203.             self.name = name
  204.             self.level = 1
  205.             self.job = "Priest"
  206.             self.title = "Strider of the East"
  207.             if self.job == "Cleric":
  208.                 self.critical = 125
  209.                 self.str = 50
  210.                 self.exp = 254
  211.                 self.max1 = 3154
  212.                 max2 = self.level*self.max1*2/3
  213.                 self.maxHp = int(max2)
  214.             if self.job == "Priest":
  215.                 self.critical = 95
  216.                 self.str = 20
  217.                 self.exp = 254
  218.                 self.max1 = 4478
  219.                 max2 = self.level*self.max1*2/3
  220.                 self.maxHp = int(max2)
  221.             self.health = self.maxHp
  222.  
  223.         def expGauge(self):
  224.             rexp1 = 3500
  225.             rexp2 = self.level*rexp1*2/3
  226.             gauge1 = self.exp/rexp2
  227.             gauge2 = float(gauge1)*100.00
  228.             self.gauge = int(gauge2)
  229.  
  230.         def lvl(self):
  231.             rexp1 = 3500
  232.             rexp2 = self.level*rexp1*2/3
  233.             if self.exp >= rexp2:
  234.                 self.level = self.level+1
  235.                 self.exp = self.exp - rexp2
  236.                 max2 = self.level*self.max1*2/3
  237.                 self.maxHp = int(max2)
  238.                 print("You just leveled up !! Congratulations %s"% self.name)
  239.             else:
  240.                 pass
  241.  
  242.  
  243.         def heal(self):
  244.             if self.health < self.maxHp:
  245.                 if self.job == "Cleric":
  246.                     heal1 = 200
  247.                     heal2 = self.level*heal1*2
  248.                     hell = heal2/3
  249.                     heal3 = int(hell)
  250.                     heal4 = random.randint(heal3,heal2)
  251.                     self.health += heal4
  252.                 if self.job == "Priest":
  253.                     heal1 = 300
  254.                     heal2 = self.level*heal1*2
  255.                     hell = heal2/3
  256.                     heal3 = int(hell)
  257.                     heal4 = random.randint(heal3,heal2)
  258.                     self.health += heal4
  259.                 if self.health > self.maxHp:
  260.                     self.health = self.maxHp
  261.                     print ("hp full")
  262.             else:
  263.                 print ("hp full")
  264.  
  265.         def attack(self):
  266.             atta = player.level*player.str
  267.             atte = atta + (self.critical*self.level)
  268.             atti = atte + atta * 2 / 3
  269.             self.dmg = random.randint(atta,int(atti))
  270.             momon.health -= self.dmg
  271.  
  272.  
  273.  
  274.     class Enemy:
  275.    
  276.         def __init__(self, name):
  277.             self.name = "Zombie"
  278.             self.health = 5000
  279.             self.critical = 35
  280.             self._tasks = set()
  281.  
  282.         def attack(self):
  283.             self.dmg = random.randint(300,500)
  284.             dmg = self.dmg
  285.             miss = "Zombie attacks but misses"
  286.             atks = ("Zombie attacks and dealt %s damage !!"% dmg)
  287.             chose = random.choice([miss,miss,miss,atks,miss,atks,miss])
  288.             if chose == miss:
  289.                 pass
  290.             if chose == atks:
  291.                 print(atks)
  292.                 player.health -= dmg
  293.  
  294.     global war
  295.  
  296.     war = False
  297.  
  298.  
  299.     momon = Enemy("Zombie")
  300.  
  301.     heroname = str(input("Please enter your name: "))
  302.     player = heroname
  303.     if heroname == player:
  304.             player = Hero(heroname)
  305.             print ("Welcome to another world %s !!" %heroname)
  306.  
  307.     opt = ["help","rest","job 1","job 2","hunt","atk","heal","status"]
  308.  
  309.     while True:
  310.         choice = str(input("-->"))
  311.         if not choice in opt:
  312.             print("Fail command !")
  313.         player.expGauge()
  314.         if war == True:
  315.             momon.attack()
  316.             if choice == "atk":
  317.                 if player.health <= 0:
  318.                     player.health = 0
  319.                 if player.health and momon.health > 0:
  320.                     player.attack()
  321.                     if momon.health <= 0 and not player.health <= 0:
  322.                         momon.health = 0
  323.                         print("You won !!!")
  324.                         war = False
  325.                     if player.health <= 0:
  326.                         player.health = 0
  327.                         print("You are dead")
  328.                         war = False
  329.                     if war == True:
  330.                         randex1 = 50
  331.                         randex2 = 200
  332.                         randex = random.randint(randex1,randex2)
  333.                         player.lvl()
  334.                         player.exp = player.exp+randex
  335.                         php = str(player.health)
  336.                         mhp = str(momon.health)
  337.                         print("%s's ~Hp: %s  ~Damage: %s |  %s's ~Hp: %s"% (player.name,php,player.dmg,momon.name,mhp))
  338.             if choice == "heal":
  339.                 player.heal()
  340.                 php = str(player.health)
  341.                 mhp = str(momon.health)
  342.                 if player.health < player.maxHp:
  343.                     print("%s's HP: %s |  %s ~hp: %s"% (player.name,php,momon.name,mhp))
  344.                 else:
  345.                     pass
  346.         else:
  347.             momon.health = 5000
  348.             if choice == "status":
  349.                 apus = ("%s's status :\n~Hp       : %s\n~Level    : %s\n~Job      : %s\n~Title    : %s\n~Exp      : %i%s"% (player.name,player.health,player.level,player.job,player.title,player.gauge,str("%")))
  350.                 print (str(apus))
  351.    
  352.             if choice == "help":
  353.                 print("Here are available commands for you honey: help, rest, job 1, job 2, hunt, atk, heal")
  354.            
  355.             if choice == "rest":
  356.                 player.health = int(player.maxHp)
  357.                 print("%s rests under a big cherry tree and recovers from all his wounds"% player.name)
  358.  
  359.             if choice == "atk":
  360.                 print("%s started a fight with a thug and got trashed"% player.name)
  361.  
  362.             if choice == "job 1":
  363.                     player.job = "Priest"
  364.                     print("You switched your Job and becomes a holy Priest")
  365.             if choice == "job 2":
  366.                     player.job = "Cleric"
  367.                     print("You switched your Job and becomes a Mighty Cleric")
  368.  
  369.             if choice == "hunt":
  370.                 print("You approaches a Zombie and initiates a battle !!")
  371.                 war = True
  372.  
  373.  
  374. ##### Pars Def
  375.   def pars(args):
  376.           args=args.lower()
  377.           userlist = roomUsers()
  378.           for name in userlist:
  379.             if args in name:return name
  380. ##Ignore this, you dont need to worry about this
  381. #Well, you can actually take a little time to look at it and learn something
  382.   def onMessage(self, room, user, message):
  383.   #### Comenzi fara prefix
  384.    if message.body.startswith("test"):
  385.      room.message("Testis accepted")
  386.    if message.body.startswith("hitung"):
  387.      hasil = ai.hitung(message.body)
  388.      if hasil:
  389.          room.message(hasil)
  390.      else:
  391.          room.message("belom di ajarin kalo ngitung itu :v @" + user.name+".")
  392.    if message.body.startswith("@sekkki"):
  393.      room.message("mau ngapain? @"  + user.name+".")
  394.    if message.body.startswith("oh"):
  395.      room.message("iya kaka :D")
  396.    if message.body.startswith("woi"):
  397.      room.message("ga usah teriak-teriak, keles...")
  398.    if message.body.startswith("sepi"):
  399.      room.message("I'm here for you :D")
  400.    if message.body.startswith("siang"):
  401.      room.message("siang juga :)")
  402.    if message.body.startswith("malam"):
  403.      room.message("Good Night :)")
  404.    if message.body.startswith("konbanwa"):
  405.      room.message("Ohayou :v")
  406.    if message.body.startswith("oyasumi"):
  407.      room.message("Mata-nee")
  408.    if message.body.startswith("konichiwa"):
  409.      room.message("iya. Konbanwa :)")
  410.    if message.body.startswith("jam"):
  411.       room.message(strftime("%H:%M:%S", localtime()))      
  412.    if message.body.startswith("tanggal"):
  413.      room.message(strftime ("HARI: %a,%d-%b-%Y ", localtime()))
  414.    if message.body.startswith("siapa yang"):
  415.      room.message(random.choice(room.usernames))
  416.    if message.body.startswith("siapa yang paling cantik "):
  417.      jawab = ["Kepo banget sih","aku lah","saya","ntahlah","susah jawab nya :v"]
  418.      room.message(random.choice(jawab)+" @"+user.name)
  419.    if message.body.startswith("wkkwkwk"):
  420.      room.message("kenapa ketawa sendiri?  @"+user.name+".")
  421.    if message.body.startswith("aku jahat apa baik ?"):
  422.      jawab = ["jahat","siapa ya? ","sok kenal kali sih!!","Ntahlah :3","coegh"]
  423.      room.message(random.choice(jawab)+" @"+user.name)
  424.    if message.body.startswith("kamu makhluk apa cin?"):
  425.      room.message("Ntahlah, aku pun bimbang")
  426.    if message.body.startswith("kamu umur berapa cin"):
  427.      room.message("Lebih muda dari pada kamu :3")
  428.    if message.body.startswith("teks"):
  429.      room.message("<marquee>HALO SELAMAT DATANG >>>>>>>>></marquee>")
  430.    if message.body.startswith("kamu tinggal dimana cin?"):
  431.      room.message("dihatimu :3")  
  432.    if message.body.startswith("kamu udah makan?"):
  433.      jawab = ["belom","beliin dong, kaka","kakak suapin","beliin kue dong","siapa yah ?"]
  434.      room.message(random.choice(jawab)+" @"+user.name)
  435.    if message.body.startswith("hentai?"):
  436.      jawab = ["Hayo.. buka apaan tuh?"]
  437.      room.message(random.choice(jawab)+" @"+user.name)
  438.    if message.body.startswith("kamu make pantsu apa cin?"):
  439.      jawab = ["hijau","pelangi","kuning","merah","biru","hitam","ungu","gambar beruang"]
  440.      room.message(random.choice(jawab)+" @"+user.name)
  441.    if message.body.startswith("bapa kamu"):
  442.      jawab = ["iya ko tau","bukan","siapa ya ?","hem mungkin","siapa yah ?"]
  443.      room.message(random.choice(jawab)+" @"+user.name)
  444.    if message.body.startswith("Rekom anime romance"):
  445.      jawab = ["Clannad, after story, Sukitte ii na you, Aoharu ride, Kaichou wa maid-sama, Nisekoi, InuxBoku,Ore monogatari,Nagi no Asukara, Tonari no Kaibutsu-kun,Isshukan friend,Kamisama Hajimemashita,Special A,Soredemo sekai wa utsukushi,Hen Ouji,Amagami,Kimi ni Todoke,Toradora,sankarea,Golden Time,White Album,Bakemonogatari,Gosick,Hotarubi no Mori e,"]
  446.      room.message(random.choice(jawab)+" @"+user.name)
  447.    if message.body.startswith("Rekom anime harem"):
  448.      jawab = ["Absolute Duo, Asobi ni Iku Yo, Campione, Freezing, High School DxD, Hoshizora E Kakaru Hashi,Kiss X Sis, Kore wa Zombie Desu Ka,Maken-Ki- Nisekoi,Orehura, Imocho,Seikon no Qwaser,Sekirei ,Shinmai Maou no Testament,Sora No Otoshimono,To Love ru,Walkure Romanze,Yamada-kun to 7-nin no Majo,Infinite Stratos,Trinity Seven,Zero no Tsukaima,Strike The Blood,NouCome,Kanojo ga flag wo oraretara,Air Gear, Saenai Heroine no Sodatekata,Mondaiji Tachi,Isuca,Inou Battle wa Nichijou,D-Frag,Mashiro-iro Symphony,CubexCursedxCurious,Sword Art Online,Koi to Senkyo no Chocolate,Date A Live, The World God Only Knows,Hidan no Aria, Hen Ouji,Denpa Kyoushi,Kuusen Madoushi,Grisaia no Kajitsu, Monmusu"]
  449.      room.message(random.choice(jawab)+" @"+user.name)
  450.    if message.body.startswith("gue cantik gak cin?"):
  451.      jawab = ["ga cantik, tapi tamvan :D","siapa ya?","cantik","cantik sih, tapi masih cantikan aku","ga usah sok kenal!"]
  452.      room.message(random.choice(jawab)+" @"+user.name)
  453.    if message.body.startswith("gue tamvan gak cin?"):
  454.      jawab = ["jelek","siapa ya? ","tamvan","tamvan banget, kawin yuk ","Tanyalah pada rumput yang bergoyang"]
  455.      room.message(random.choice(jawab)+" @"+user.name)
  456.    if message.body.startswith("tampan gak dia "):
  457.      jawab = ["jelek","siapa ya? ","tamvan","muka pasaran","biasa aja, sih"]
  458.      room.message(random.choice(jawab)+" @"+user.name)
  459.    if message.body.startswith("soalnya kamu"):
  460.      jawab = ["boleh juga","garing","lagi dong","so swet","siapa yah ?"]
  461.      room.message(random.choice(jawab)+" @"+user.name)
  462.    if message.body.startswith("karena kamu"):
  463.      jawab = ["boleh juga","garing","lagi dong","so swet","nge gombal, ya? "]
  464.      room.message(random.choice(jawab)+" @"+user.name)
  465.    if message.body.startswith("asal kamu dari mana cin?"):
  466.      room.message("aku dari tadi kok")
  467.    if message.body.startswith("yes"):
  468.      room.message("aaa, http://media.giphy.com/media/X3ndlrK6rOCt2/giphy.gif")
  469.    if message.body.startswith("cin"):
  470.      room.message("apaan!, Cindy disini, mau butuh apa? @"+ user.name+".")
  471.    if message.body.startswith("Tsundere"):
  472.      room.message(" W-What ?, http://i173.photobucket.com/albums/w77/omghaet/Index/Biri-Biri.png  @"+ user.name+".")
  473.    if message.body.startswith("Yandere"):
  474.      room.message("Yes!, I'm here, http://vignette2.wikia.nocookie.net/futurediary/images/a/a5/YunoYandereFace.jpg/revision/latest?cb=20120128011750  @"+ user.name+".")
  475.    if message.body.startswith("pagi"):
  476.      for i, msg in enumerate(pagi):
  477.         self.setTimeout(i / 2, room.message, msg)
  478.    if message.body.startswith("bete nih"):
  479.      for i, msg in enumerate(bete):
  480.         self.setTimeout(i / 0.79, room.message, msg)
  481.    if message.body.startswith("nyan"):
  482.       for i, msg in enumerate():
  483.         self.setTimeout(i / 2, room.message, msg)
  484.    if message.body.startswith("afk"):
  485.      if user.name == "sekkki":
  486.       room.message("Mata-Nee kk *waves*")
  487.      else:
  488.       room.message("Njaa  "  + user.name+".")
  489.    if message.body.startswith("kata bijak"):
  490.       room.message(random.choice(["jangan lah berhenti bermimpi karena mimpi bisa itu suatu saat akan menjadi nyata.",
  491.           "berani ambil resiko, kita tidak akan pernah tau apa yang akan terjadi.",
  492.           "jangan pernah lupa dengan orang yang selalu mendukung mu dari belakang.",
  493.           "jangan pernah sekali-kali sombong, karena di atas langit masih ada langit.",
  494.           "To true friendship, how long you've known each other means nothing.",
  495.           "You want weapons? We??re in a library! Books! The best weapons in the world!",
  496.           "mulut lebih tajam dari benda apapun kalu kita salah menggunakan nya.",
  497.           "Dividing an impossibly large task into smaller solvable problems is a programmer??s job.",
  498.           "dunia ini penuh dengan melodi dan harmoni, jangan sekali2 merusak nya dengan keluhan anda :)",
  499.           "Hold hands. That's what you're meant to do. Keep doing that... and don't let go.",
  500.           "cintailah orang yang mencintai anda juga?",
  501.           "jangan pernah malah olahraga",
  502.           "Don't worry if plan A fails, there are 25 more letters in the alphabet.",
  503.           "Life doesn't have any hands, but it can sure give you a slap sometimes.",
  504.           "lihat ke belakang, sewaktu2 jika anda tidak sedang sibuk",
  505.           "Belajar ketika orang lain tidur, bekerja ketika orang lain bermalasan, dan bermimpi ketika orang lain berharap.",
  506.           "Pain has deep roots. The only way to dig it out is to forgive...",
  507.           "Love,after all,always said more about those who felt it then it did about the ones they love.",
  508.           "Memories are funny things.Sometimes they're real ,but other times they change into what we went them to be.",
  509.           "The moment of impact. The moment of impact proves potential for change. Has ripples effects far beyond what we can predict."]))
  510.    if message.body.startswith("quotes"):
  511.       room.message(random.choice(["jangan lah berhenti bermimpi karena mimpi bisa itu suatu saat akan menjadi nyata.",
  512.           "berani ambil resiko, kita tidak akan pernah tau apa yang akan terjadi.",
  513.           "jangan pernah lupa dengan orang yang selalu mendukung mu dari belakang.",
  514.           "jangan pernah sekali-kali sombong, karena di atas langit masih ada langit.",
  515.           "To true friendship, how long you've known each other means nothing.",
  516.           "You want weapons? We??re in a library! Books! The best weapons in the world!",
  517.           "mulut lebih tajam dari benda apapun kalu kita salah menggunakan nya.",
  518.           "Dividing an impossibly large task into smaller solvable problems is a programmer??s job.",
  519.           "dunia ini penuh dengan melodi dan harmoni, jangan sekali2 merusak nya dengan keluhan anda :)",
  520.           "Hold hands. That's what you're meant to do. Keep doing that... and don't let go.",
  521.           "cintailah orang yang mencintai anda juga?",
  522.           "jangan pernah malah olahraga",
  523.           "Don't worry if plan A fails, there are 25 more letters in the alphabet.",
  524.           "Life doesn't have any hands, but it can sure give you a slap sometimes.",
  525.           "lihat ke belakang, sewaktu2 jika anda tidak sedang sibuk",
  526.           "Belajar ketika orang lain tidur, bekerja ketika orang lain bermalasan, dan bermimpi ketika orang lain berharap.",
  527.           "Pain has deep roots. The only way to dig it out is to forgive...",
  528.           "Love,after all,always said more about those who felt it then it did about the ones they love.",
  529.           "Memories are funny things.Sometimes they're real ,but other times they change into what we went them to be.",
  530.           "The moment of impact. The moment of impact proves potential for change. Has ripples effects far beyond what we can predict."]))
  531.    if message.body.startswith("ramalan jodoh"):
  532.      room.message("masukan nama mu dan pasangan mu contoh >> mr.x dan ms.y setelah itu tulis >> ramal")
  533.    if message.body.startswith("gua cocok gak sama"):
  534.       jawab = ["cocok nya sama thelor","gak akan pernah cocok","gak pantes","saling suka :)",]
  535.       room.message(random.choice(jawab)+" @"+user.name)
  536.    if message.body.startswith("brb"):
  537.      if user.name == "sekkki":
  538.       room.message("Hus..Hus..")
  539.      else:
  540.       room.message("sampai ketemu lagi  "  + user.name+".")
  541.    if message.body.startswith("back"):
  542.      if user.name == "sekkki":
  543.       room.message("ngapain kesini ?")
  544.      else:
  545.       room.message("Welcome to Indonesia   "  + user.name+".")
  546.    try:
  547.     if room.getLevel(self.user) > 0:
  548.       print(user.name, message.body)
  549.     else:
  550.       print(user.name, message.body)
  551.     if self.user == user: return
  552.     if message.body[0] == "/" :   ##Here is the Prefix part
  553.       data = message.body[1:].split(" ", 1)
  554.       if len(data) > 1:
  555.         cmd, args = data[0], data[1]
  556.       else:
  557.         cmd, args = data[0], ""
  558.  
  559.  
  560. ##COMMANDS!
  561. #Setting up commands for yer bot
  562.          
  563.  
  564.  
  565.  
  566.  #commands section
  567.  #youtube
  568.      
  569.  
  570.    
  571.  #say
  572.        
  573.       if cmd == "say":
  574.             if args:
  575.               room.message(args)
  576.             else:
  577.               room.message("sariawan males ngomong")  
  578. #### Invite
  579.       if cmd == "invite" or cmd == "Invite":
  580.         if len (args) > 0:
  581.             self.pm.message(ch.RoomManager(args),"%s kalo lagi sepi di room itu mampir aja kemari >>>> http://%s.chatango.com .")
  582.             room.message("Invite on progress %s in Access group. :)" % args)
  583.         else:
  584.             room.message("Sry have problem. :3")
  585. ##You may want/need to evaluate something about your bot.
  586.       if cmd == "ev" or cmd == "eval" or cmd == "e":
  587.           ret = eval(args)
  588.           if ret == None:
  589.             room.message("Done.")
  590.             return
  591.           room.message(str(ret))
  592.  
  593.        #### Google Image Search
  594.      
  595.      
  596.  
  597.         ##Check Level
  598.       elif (cmd == "nick"): ##tambahin sntonick(user.name) faiq, supaya bot nya manggil pake nick ;)
  599.           try:
  600.             if args:
  601.               nicks[user.name]=json.dumps(args)
  602.               room.message (user.name+" <f x12FFCC00='1'>now <f x12334433='1'>will be Called, <f x126666CC='1'> "+args+" :)" ,True)
  603.               saveNicks()
  604.             if args == "":
  605.               room.message("<f x12F00='1'>Type .nick <f x12FFCC00='1'>*Your Nick Here* <f x12334433='1'> .. :)",True)
  606.           except:
  607.             room.message("I'am Failed make a nick for, "+user.name+". :(")
  608.  
  609.       elif cmd == "mynick":
  610.           try:
  611.             if user.name in nicks:
  612.               room.message("<f x12F00='1'>Your nick <f x1233FFFF='1'>right Now is: "+sntonick(user.name)+" .. :)", True)
  613.             else:
  614.               room.message("<f x12000='1'>Type .nick <f x12F00='1'>*Your Nick*",True)
  615.           except:
  616.             return
  617.        
  618.       elif cmd == "detik":
  619.           room.message(detik(),True)
  620.       elif cmd == "cpu":
  621.           room.message(get_cpu_load(),True)
  622.      
  623.         #This one cmd is tho make your bot say your mod level in the current room you're in
  624.       elif cmd == "mylvl":
  625.         room.message("Your mod level: %i" %(room.getLevel(user)))
  626.  
  627.         ##List Mods
  628.         #List of Mods and Owner name in the current room you're in
  629.       elif cmd == "mods":
  630.         room.message(", ".join(room.modnames + [room.ownername]))
  631.         #### Seen
  632.       elif cmd == "gis":
  633.             try:
  634.               import urllib
  635.               url = urllib.request.urlopen("http://ajax.googleapis.com/ajax/services/search/images?v=1.0&q="+urllib.parse.quote(args))
  636.               udict = json.loads(url.read().decode('utf-8'))["responseData"]["results"]
  637.               udict = random.choice(udict)
  638.               img = udict["unescapedUrl"]
  639.               room.message("<font color='#FF0000'><b>"+user.name.title()+"</b></font>,I Found your images:  "
  640.                            +img, True)
  641.             except:
  642.               room.message(args.capitalize()+' is not found Dude!')
  643.       elif cmd == "yt":
  644.           room.message(tube(args),True)
  645.       elif cmd == "invitegroup" or cmd == "ig":
  646.         if len (args) > 0:
  647.          self.pm.message(ch.RoomManager(args),"%s You have group invite! check this Chatango Group http://%s.chatango.com ." %(room.ownername[0],room.name))
  648.          room.message("Youre invite %s now is in Accest Group. :)" % args)
  649.         else:
  650.           room.message("gak mau ah nginvite dia")
  651.         ##DANCE!!!!
  652.         #Dance ? Of Course !!! ^_^
  653.       elif cmd == "dance":
  654.         for i, msg in enumerate(dancemoves):
  655.           self.setTimeout(i / 2, room.message, msg)
  656.                #### Pm
  657.       elif cmd == "pm" or cmd == "Pm" or cmd == "PM" or cmd == "Private Message":
  658.         data = args.split(" ", 1)
  659.         if len(data) > 1:
  660.           name , args = data[0], data[1]
  661.           self.pm.message(ch.User(name), "[Private.Message] By - "+user.name+" : "+args+" ")
  662.           room.message("Has been sent to "+name+"")
  663.         #### Invite
  664.       elif cmd == "invite" or cmd == "Invite":
  665.         if len (args) > 0:
  666.             self.pm.message(ch.RoomManager(args),"%s You have a group invite by ! http://%s.chatango.com ." )
  667.             room.message("Invite on progress %s in Access group. :)" % args)
  668.         else:
  669.             room.message("Sry have problem. :3")
  670.         #### Profile
  671.       elif cmd == "prof" or cmd == "profile" or cmd == "Prof" or cmd == "Profile":
  672.         try:
  673.           args=args.lower()
  674.           stuff=str(urlreq.urlopen("http://"+args+".chatango.com").read().decode("utf-8"))
  675.           crap, age = stuff.split('<span class="profile_text"><strong>Age:</strong></span></td><td><span class="profile_text">', 1)
  676.           age, crap = age.split('<br /></span>', 1)
  677.           crap, gender = stuff.split('<span class="profile_text"><strong>Gender:</strong></span></td><td><span class="profile_text">', 1)
  678.           gender, crap = gender.split(' <br /></span>', 1)
  679.           if gender == 'M':
  680.               gender = 'Male'
  681.           elif gender == 'F':
  682.               gender = 'Female'
  683.           else:
  684.               gender = '?'
  685.           crap, location = stuff.split('<span class="profile_text"><strong>Location:</strong></span></td><td><span class="profile_text">', 1)
  686.           location, crap = location.split(' <br /></span>', 1)
  687.           crap,mini=stuff.split("<span class=\"profile_text\"><!-- google_ad_section_start -->",1)
  688.           mini,crap=mini.split("<!-- google_ad_section_end --></span>",1)
  689.           mini=mini.replace("<img","<!")
  690.           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>'
  691.           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
  692.           room.message(prodata,True)
  693.         except:
  694.           room.message(""+args+" doesn't exist o.o ")
  695.         #
  696.         if cmd =="wordtoday" or cmd=="wt":
  697.             if user.name in owners:
  698.               if user.name in wordtodaytime:
  699.                 w = json.loads(wordtodaytime[user.name])
  700.                 if time.time() < w:
  701.                   w = int(w) - int(time.time())
  702.                   minute = 60
  703.                   hour = minute * 60
  704.                   day = hour * 24
  705.                   days =  int(w / day)
  706.                   hours = int((w % day) / hour)
  707.                   minutes = int((w % hour) / minute)
  708.                   seconds = int(w % minute)
  709.                   string = ""
  710.                   if days > 0:
  711.                     string += str(days) + " " + (days == 1 and "day" or "days" ) + ", "
  712.                   if len(string) > 0 or hours > 0:
  713.                     string += str(hours) + " " + (hours == 1 and "hour" or "hours" ) + ", "
  714.                   if len(string) > 0 or minutes > 0:
  715.                     string += str(minutes) + " " + (minutes == 1 and "minute" or "minutes" ) + ", "
  716.                   string += str(seconds) + " " + (seconds == 1 and "second" or "seconds" )
  717.                   room.message("You can use wordtoday after <font color='#9999FF'>%s</font>  (~^o^)~ "% string,True)
  718.                   return
  719.               if urank(user.name) >= 1:
  720.                 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"]))
  721.                 room.message("Dear "+sntonick(user.name)+" Your word today is : <b><font color='#FF9966'>"+str(x)+"</font></b>",True)
  722.                 wordtodaytime[user.name] = json.dumps(time.time()+1200)
  723.  
  724.         ##Check if Mod
  725.         #not really important
  726.       elif cmd == "ismod":
  727.         user = ch.User(args)
  728.         if room.getLevel(user) > 0:
  729.           room.message("yesh")
  730.         else:
  731.           room.message("nope")
  732.    except Exception as e:
  733.       try:
  734.         et, ev, tb = sys.exc_info()
  735.         lineno = tb.tb_lineno
  736.         fn = tb.tb_frame.f_code.co_filename
  737.         room.message("[Expectation Failed] %s Line %i - %s"% (fn, lineno, str(e)))
  738.         return
  739.       except:
  740.         room.message("Undescribeable error detected !!")
  741.         return
  742.  
  743.   ##Other Crap here, Dont worry about it
  744.  
  745.   def onFloodWarning(self, room):
  746.     room.reconnect()
  747.  
  748.   def onJoin(self, room, user):
  749.    print(user.name + " joined the chat!")
  750.  
  751.   def onLeave(self, room, user):
  752.    print(user.name + " left the chat!")
  753.  
  754.   def onUserCountChange(self, room):
  755.     print("users: " + str(room.usercount))
  756.  
  757.   def onMessageDelete(self, room, user, msg):
  758.     print("MESSAGE DELETED: " + user.name + ": " + msg.body)
  759.  
  760.  
  761. if __name__ == "__main__": TestBot.easy_start()
  762.  
  763.     #The End!!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement