Advertisement
hanseel

Untitled

Jan 16th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 54.12 KB | None | 0 0
  1. ##############################################################################################################################################
  2.  
  3.  
  4.  
  5. #################################################################################################################
  6. import ch
  7. import random
  8. import sys
  9. import re
  10. import json
  11. import time
  12. import datetime
  13. import os
  14. import urllib
  15.  
  16. ##Dance moves!
  17. #kinda useless
  18.  
  19. dancemoves = [
  20. "(>^.^)>",
  21. "(v^.^)v",
  22. "v(^.^v)",
  23. "<(^.^<)"
  24. ]
  25. from xml.etree import cElementTree as ET
  26. if sys.version_info[0] > 2:
  27. import urllib.request as urlreq
  28. else:
  29. import urllib2 as urlreq
  30.  
  31. botname = 'Ficent'
  32. password = 'allvhan785'
  33.  
  34. ##nick names
  35. def sntonick(username):
  36. user = username.lower()
  37. if user in nicks:
  38. nick = json.loads(nicks[user])
  39. return nick
  40. else:
  41. return user
  42.  
  43. #### Returns the number of seconds since the program started.
  44. ################################################################
  45. def getUptime():
  46. # do return startTime if you just want the process start time
  47. return time.time() - startTime
  48.  
  49. def reboot():
  50. output = ("rebooting server . . .")
  51. os.popen("sudo -S reboot")
  52. return output
  53.  
  54. #### SYSTEM UPTIME
  55. def uptime():
  56.  
  57. total_seconds = float(getUptime())
  58.  
  59. # Helper vars:
  60. MINUTE = 60
  61. HOUR = MINUTE * 60
  62. DAY = HOUR * 24
  63.  
  64. # Get the days, hours, etc:
  65. days = int( total_seconds / DAY )
  66. hours = int( ( total_seconds % DAY ) / HOUR )
  67. minutes = int( ( total_seconds % HOUR ) / MINUTE )
  68. seconds = int( total_seconds % MINUTE )
  69.  
  70. # Build up the pretty string (like this: "N days, N hours, N minutes, N seconds")
  71. string = ""
  72. if days > 0:
  73. string += str(days) + " " + (days == 1 and "day" or "days" ) + ", "
  74. if len(string) > 0 or hours > 0:
  75. string += str(hours) + " " + (hours == 1 and "hour" or "hours" ) + ", "
  76. if len(string) > 0 or minutes > 0:
  77. string += str(minutes) + " " + (minutes == 1 and "minute" or "minutes" ) + ", "
  78. string += str(seconds) + " " + (seconds == 1 and "second" or "seconds" )
  79.  
  80. return string;
  81.  
  82. ## DEFINITIONS
  83. dictionary = dict()
  84. f = open("definitions.txt", "r")
  85. for line in f.readlines():
  86. try:
  87. if len(line.strip())>0:
  88. word, definition, name = json.loads(line.strip())
  89. dictionary[word] = json.dumps([definition, name])
  90. except:
  91. print("[ERROR]Cant load definition: %s" % line)
  92. f.close()
  93. ##nicks
  94. nicks=dict()#empty list
  95. f=open ("nicks.txt","r")#r=read w=right
  96. for line in f.readlines():#loop through eachlinimporte and read each line
  97. try:#try code
  98. if len(line.strip())>0:#strip the whitespace checkgreater than 0
  99. user , nick = json.loads(line.strip())
  100. nicks[user] = json.dumps(nick)
  101. except:
  102. print("[Error]Can't load nick %s" % line)
  103. f.close()
  104. ##Rooms
  105. rooms = []
  106. f = open("rooms.txt", "r") # read-only
  107. for name in f.readlines():
  108. if len(name.strip())>0: rooms.append(name.strip())
  109. f.close()
  110. ##Champion
  111. Champion = []
  112. try:
  113. file = open("Champion.txt", "r")
  114. for name in file.readlines():
  115. if len(name.strip()) > 0:
  116. Champion.append(name.strip())
  117. print("[INFO]Owners loaded...")
  118. file.close()
  119. except:
  120. print("[ERROR]no file named Champion")
  121. print("2 second to read the error")
  122. time.sleep(2)
  123. exit()
  124. time.sleep(1)
  125.  
  126. ###Hero
  127. Hero = []
  128. try:
  129. file = open("Hero.txt", "r")
  130. for name in file.readlines():
  131. if len(name.strip()) > 0:
  132. Hero.append(name.strip())
  133. print("[INFO]Hero loaded...")
  134. file.close()
  135. except:
  136. print("[ERROR]no file named Hero")
  137. print("2 second to read the error")
  138. time.sleep(2)
  139. exit()
  140. time.sleep(1)
  141.  
  142. ###Chief
  143. Chief = []
  144. try:
  145. file = open("Chief.txt", "r")
  146. for name in file.readlines():
  147. if len(name.strip()) > 0:
  148. Chief.append(name.strip())
  149. print("[INFO]Chief loaded...")
  150. file.close()
  151. except:
  152. print("[ERROR]no file named Chief")
  153. print("2 second to read the error")
  154. time.sleep(2)
  155. exit()
  156. time.sleep(1)
  157.  
  158. ##Guardian
  159. Guardian = []
  160. try:
  161. file = open("Guardian.txt", "r")
  162. for name in file.readlines():
  163. if len(name.strip()) > 0:
  164. Guardian.append(name.strip())
  165. print("[INFO]Guardian loaded...")
  166. file.close()
  167. except:
  168. print("[ERROR]no file named Guardian")
  169. print("2 second to read the error")
  170. time.sleep(2)
  171. exit()
  172. time.sleep(1)
  173. ##Initial
  174. Initial = []
  175. try:
  176. file = open("Initial.txt", "r")
  177. for name in file.readlines():
  178. if len(name.strip()) > 0:
  179. Initial.append(name.strip())
  180. print("[INFO]Initial loaded...")
  181. file.close()
  182. except:
  183. print("[ERROR]no file named Initial")
  184. print("2 second to read the error")
  185. time.sleep(2)
  186. exit()
  187. time.sleep(1)
  188.  
  189.  
  190. #Dlist
  191. dlist = []
  192. f = open("dlist.txt", "r") # read-onlyimport
  193. for name in f.readlines():
  194. if len(name.strip())>0: dlist.append(name.strip())
  195. f.close()
  196. #END#
  197. #SN TRY
  198. sn = dict()
  199. try:
  200. f = open('note.txt','r')
  201. sn = eval(f.read())
  202. f.close()
  203. except:pass
  204.  
  205. ## Send Notes
  206. sasaran = dict()
  207. f = open ("notes.txt", "r") #read-only
  208. for line in f.readlines():
  209. try:
  210. if len(line.strip())>0:
  211. to, body, sender = json.loads(line.strip())
  212. sasaran[to] = json.dumps([body, sender])
  213. except:
  214. print("[Error] Notes load fails : %s" % line)
  215. f.close()
  216. # SN Notifs
  217. notif = []
  218. f = open("notif.txt", "r")
  219. for name in f.readlines():
  220. if len(name.strip())>0: notif.append(name.strip())
  221. f.close
  222.  
  223. blacklist = []
  224. f = open("blacklist.txt", "r")
  225. for name in f.readlines():
  226. if len(name.strip())>0: blacklist.append(name.strip())
  227. f.close()
  228.  
  229. def tube(args):
  230. """
  231. #In case you don't know how to use this function
  232. #type this in the python console:
  233. >>> tube("pokemon dash")
  234. #and this function would return this thing:
  235. {'title': 'TAS (DS) Pokémon Dash - Regular Grand Prix', 'descriptions': '1st round Grand Prix but few mistake a first time. Next Hard Grand Prix will know way and few change different Pokémon are more faster and same course Cup.', 'uploader': 'EddieERL', 'link': 'http://www.youtube.com/watch?v=QdvnBmBQiGQ', 'videoid': 'QdvnBmBQiGQ', 'viewcount': '2014-11-04T15:43:15.000Z'}
  236. """
  237. search = args.split()
  238. url = urlreq.urlopen("https://www.googleapis.com/youtube/v3/search?q=%s&part=snippet&key=AIzaSyBSnh-sIjd97_FmQVzlyGbcaYXuSt_oh84" % "+".join(search))
  239. udict = url.read().decode('utf-8')
  240. data = json.loads(udict)
  241. rest = []
  242. for f in data["items"]:
  243. rest.append(f)
  244.  
  245. d = random.choice(rest)
  246. link = "http://www.youtube.com/watch?v=" + d["id"]["videoId"]
  247. videoid = d["id"]["videoId"]
  248. title = d["snippet"]["title"]
  249. uploader = d["snippet"]["channelTitle"]
  250. descript = d["snippet"]['description']
  251. count = d["snippet"]["publishedAt"]
  252. return "Result: %s <br/><br/><br/><br/><br/><br/><br/><br/><font color='#ffcc00'><b>%s</b></font><br/><font color='#ff0000'><b>Uploader</b></font>:<b> %s</b><br/><font color='#ff0000'><b>Uploaded on</b></font>: %s<br/><font color='#ff0000'><b>Descriptions</b></font>:<i> %s ...</i><br/> " % (link, title, uploader, count, descript[:200])
  253.  
  254. def gs(args):
  255. args = args.split()
  256. headers = {}
  257. headers['User-Agent'] = "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.27 Safari/537.17"
  258. req = urllib.request.Request("https://www.google.com.br/search?q=" + "+".join(args), headers = headers)
  259. resp = urllib.request.urlopen(req).read().decode("utf-8").replace('\n','').replace('\r','').replace('\t','').replace('http://','gs:').replace('https://','gs:')
  260. anjay = re.findall('<h3 class="r">(.*?)</h3>', resp)
  261. setter = list()
  262. la = "".join(anjay)
  263. a = re.findall('<a href="gs:(.*?)" onmousedown="(.*?)">(.*?)</a>', la)
  264. q = 1
  265. for link, fak, title in a:
  266. setter.append("<br/>(%s) %s : http://%s" % (q, title.capitalize(), link))
  267. q += 1
  268. return "".join(setter[0:4])
  269.  
  270. def saveRank():
  271. f = open("Champion.txt","w")
  272. f.write("\n".join(Champion))
  273. f.close()
  274. f = open("Hero.txt","w")
  275. f.write("\n".join(Hero))
  276. f.close()
  277. f = open("Chief.txt","w")
  278. f.write("\n".join(Chief))
  279. f.close()
  280. f = open("Guardian.txt","w")
  281. f.write("\n".join(Guardian))
  282. f.close()
  283.  
  284. def gis(cari):
  285. argss = cari
  286. args = argss.split()
  287. headers = {}
  288. headers['User-Agent'] = "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.27 Safari/537.17"
  289. req = urllib.request.Request("https://www.google.com.br/search?hl=en&authuser=0&site=imghp&tbm=isch&source=hp&biw=1366&bih=623&q=" + "+".join(args), headers = headers)
  290. resp = urllib.request.urlopen(req).read().decode("utf-8").replace('\n','').replace('\r','').replace('\t','').replace('http://','gis:').replace('https://','gis:').replace('.jpg','.jpg:end').replace('.gif','.gif:end').replace('.png','.png:end')
  291. anjay = re.findall('<div class="rg_meta">(.*?)</div>', resp)
  292. setter = list()
  293. la = "".join(anjay)
  294. a = re.findall('"ou":"gis:(.*?):end","ow"', la)
  295. q = 1
  296. for result in a:
  297. if ".jpg" in result or ".gif" in result or ".png" in result:
  298. if "vignette" not in result and "mhcdn.net" not in result and "alicdn.com" not in result and "gambardanfoto.com" not in result and "squarespace.com" not in result and "polyvore.com" not in result and "wikia.nocookie" not in result and "blogspot.com" not in result and "wordpress.com" not in result and "minionnation.co.uk" not in result and "twimg.com" not in result and "ohmymag.com" not in result and "waterfrontcinema.co.uk" not in result and "funmobility.netdna-ssl.com" not in result and "images-amazon.com" not in result and "upload.wikimedia.org" not in result:
  299. setter.append('(%s) http://%s' % (q, result))
  300. q += 1
  301. return "<br/>"+"<br/>".join(setter[0:4])
  302.  
  303.  
  304.  
  305.  
  306. ##Setting Pretty Colors
  307.  
  308. class TestBot(ch.RoomManager):
  309.  
  310. def onInit(self):
  311. self.setNameColor("000099")
  312. self.setFontColor("000099")
  313. self.setFontFace("1")
  314. self.setFontSize(11)
  315. self.enableBg()
  316. self.enableRecording()
  317.  
  318. ##Connecting Crap
  319.  
  320. def onConnect(self, room):
  321. print("Connected")
  322.  
  323. def onReconnect(self, room):
  324. print("Reconnected")
  325.  
  326. def onDisconnect(self, room):
  327. print("Disconnected")
  328.  
  329. #################################################################
  330. ### Get user access from the file, and retun lvl of access number
  331. #################################################################
  332. def getAccess(self, user):
  333. if user.name in Champion: return 5 # Champion
  334. elif user.name in Hero: return 4 # Hero
  335. elif user.name in Chief: return 3 # Chief
  336. elif user.name in Guardian: return 2 # Guardian
  337. elif user.name in Initial: return 1 # Initial
  338. elif user.name in dlist: return 0
  339. else: return 0
  340.  
  341.  
  342.  
  343. ##Ignore this, you dont need to worry about this
  344. #Well, you can actually take a little time to look at it and learn something
  345.  
  346.  
  347. def onMessage(self, room, user, message):
  348. try:
  349. msgdata = message.body.split(" ",1)
  350. if len(msgdata) > 1:
  351. cmd, args = msgdata[0], msgdata[1]
  352. else:
  353. cmd, args = msgdata[0],""
  354. cmd=cmd.lower()
  355. global lockdown
  356. global newnum
  357. print(user.name+" - "+message.body)
  358. if user.name in notif:
  359. room.message(user.name+", you got ("+str(len(sn[user.name]))+") messages unread. Do irn to read them")
  360. notif.remove(user.name)
  361. if user == self.user: return
  362. if "cen" == message.body:
  363. if self.getAccess(user) >= 5 or room.getLevel(user) > 0 and not user.name in blacklist:
  364. room.message ("Yes, milord.")
  365. if "bot" == message.body:
  366. if self.getAccess(user) >= 1 or room.getLevel(user) > 0 and not user.name in blacklist:
  367. room.message (random.choice(["i'm here "+sntonick(user.name)+ " ^.^ "]),True)
  368. if "malam" == message.body:
  369. if self.getAccess(user) >= 1 or room.getLevel(user) > 0 and not user.name in blacklist:
  370. room.message("Selamat malam"+ " ^^ ")
  371. if "icyie" == message.body:
  372. if self.getAccess(user) >= 1 or room.getLevel(user) > 0 and not user.name in blacklist:
  373. room.message("Hai @"+sntonick(user.name)+ " ^^ ")
  374. if "afk" == message.body:
  375. if self.getAccess(user) >= 1 or room.getLevel(user) > 0 and not user.name in blacklist:
  376. room.message("Sampai jumpa lagi @"+sntonick(user.name)+ " *waves* ")
  377. if "back" == message.body:
  378. if self.getAccess(user) >= 1 or room.getLevel(user) > 0 and not user.name in blacklist:
  379. room.message("Wellcome Back @"+sntonick(user.name)+ " :) ")
  380. if "pagi" == message.body:
  381. if self.getAccess(user) >= 1 or room.getLevel(user) > 0 and not user.name in blacklist:
  382. room.message("Selamat pagi"+ " :) ")
  383. if "siang" == message.body:
  384. if self.getAccess(user) >= 1 or room.getLevel(user) > 0 and not user.name in blacklist:
  385. room.message("Selamat siang "+sntonick(user.name)+ " ^o^ "),True
  386. if "sore" == message.body:
  387. if self.getAccess(user) >= 1 or room.getLevel(user) > 0 and not user.name in blacklist:
  388. room.message("Selamat sore"+ " ^^ ")
  389. if "Bro" == message.body:
  390. if self.getAccess(user) >= 1 or room.getLevel(user) > 0 and not user.name in blacklist:
  391. room.message("Gak perlu manggil manggil"+ " :@ ")
  392. if "afk" in message.body:
  393. if self.getAccess(user) >= 1 or room.getLevel(user) > 0 and not user.name in blacklist:
  394. room.message (random.choice(["mata ashita "+sntonick(user.name)+" :) ",] ),True)
  395. if "brb" in message.body:
  396. if self.getAccess(user) >= 1 or room.getLevel(user) > 0 and not user.name in blacklist:
  397. room.message (random.choice(["Bye "+sntonick(user.name)+" :) ",]),True)
  398. if message.body == "": return
  399. if message.body[0] in ["-"]:
  400. data = message.body[1:].split(" ", 1)
  401. if len(data) > 1:
  402. cmd, args = data[0], data[1]
  403. else:
  404. cmd, args = data[0], ""
  405.  
  406.  
  407.  
  408. ##check access and ignore
  409. if self.getAccess(user) == 0: return
  410. def pars(args):
  411. args=args.lower()
  412. for name in room.usernames:
  413. if args in name:return name
  414. def roompars(args):
  415. args = args.lower()
  416. for name in self.roomnames:
  417. if args in name:return name
  418. def roomUsers():
  419. usrs = []
  420. gay = []
  421. prop = 0
  422. prop = prop + len(room._userlist) - 1
  423. for i in room._userlist:
  424. i = str(i)
  425. usrs.append(i)
  426. while prop >= 0:
  427. j = usrs[prop].replace("<User: ", "")
  428. i = j.replace(">", "")
  429. gay.append(i)
  430. prop = prop - 1
  431. return gay
  432.  
  433. def getParticipant(arg):
  434. rname = self.getRoom(arg)
  435. usrs = []
  436. gay = []
  437. finale = []
  438. prop = 0
  439. prop = prop + len(rname._userlist) - 1
  440. for i in rname._userlist:
  441. i = str(i)
  442. usrs.append(i)
  443. while prop >= 0:
  444. j = usrs[prop].replace("<User: ", "")
  445. i = j.replace(">", "")
  446. gay.append(i)
  447. prop = prop - 1
  448. for j in gay:
  449. if j not in finale:
  450. finale.append(j)
  451. return finale
  452.  
  453.  
  454. #Find
  455. if cmd == "find" and len(args) > 0:
  456. name = args.split()[0].lower()
  457. if not ch.User(name).roomnames:
  458. room.message("aku tidak tau")
  459. else:
  460. room.message("kamu dapat menemukan %s Di %s" % (args, ", ".join(ch.User(name).roomnames)),True)
  461.  
  462. ##cmds
  463. if cmd == "cmds":
  464. if user.name in Champion and not user.name in Hero and not user.name in Guardian and not user.name in Chief and not user.name in Initial:
  465. room.message("<br/>"+user.name+" Rank 5 [Champion] "+"<br/>"+" Perintah[ > ] :<br/>wl , gs(Google search) , yt(Youtube) , Google Image Search (GIS) , df(define) , udf(undefine) , fax , bc , say , sn(sendnote) , rn(readnote) , mods , join , leave , delete , mydict, nick , staff , setnick , mynick , seenick , profile , Profile pict/pfpic , rank , myrank , find , ranker , tea , Jones , blacklist (bl) , unblacklist (ubl) , Clear , setrank , ban , unban ",True)
  466. if user.name in Hero and not user.name in Champion and not user.name in Chief and not user.name in Guardian and not user.name in Initial:
  467. room.message("<br/>"+user.name+" Rank 4 [Hero] "+"<br/>"+" Perintah[ > ] :<br/>wl , gs(Google search) , yt(Youtube) , Google Image Search (GIS) , df(define) , udf(undefine) , fax , bc , say , sn(sendnote) , rn(readnote) , mods , join , leave , delete , mydict, nick , staff , setnick , mynick , seenick , profile , Profile pict/pfpic , rank , myrank , find , ranker , tea , jones , Clear , myIp , ban , unban ",True)
  468. if user.name in Chief and not user.name in Champion and not user.name in Guardian and not user.name in Hero and not user.name in Initial:
  469. room.message("<br/>"+user.name+" Rank 3 [Chief] "+"<br/>"+" Perintah[ > ] :<br/>wl , gs(Google search) , yt(Youtube) , Google Image Search (GIS) , df(define) , udf(undefine) , fax , bc , say , sn(sendnote) , rn(readnote) , mods , join , leave , delete , mydict, nick , staff , setnick , mynick , seenick , profile , Profile pict/pfpic , rank , myrank , find , ranker , tea , MyIp ,",True)
  470. if user.name in Guardian and not user.name in Champion and not user.name in Chief and not user.name in Hero and not user.name in Initial:
  471. room.message("<br/>"+user.name+" Rank 2 [Guardian] "+"<br/>"+" Perintah[ > ] :<br/>wl , gs(Google search) , yt(Youtube) , Google Image Search (GIS) , df(define) , udf(undefine) , fax , bc , say , sn(sendnote) , rn(readnote) , mods , join , leave , delete , mydict, nick , staff , setnick , mynick , seenick , profile , Profile pict/pfpic , rank , myrank , find , ranker , MyIp ,",True)
  472. if user.name in Initial and not user.name in Champion and not user.name in Hero and not user.name in Chief and not user.name in pembantu:
  473. room.message("<br/>"+user.name+" Rank 1 [initial] "+"<br/>"+" Perintah[ > ] :<br/>wl , gs(Google search) , yt(Youtube) , Google Image Search (GIS) , df(define) , udf(undefine) , fax , bc , say , sn(sendnote) , rn(readnote) , mods , mydict, nick , staff , setnick , mynick , seenick , profile , Profile pict/pfpic , rank , myrank , find , ranker , MyIp ,",True)
  474.  
  475. ##Setnick
  476. if cmd == "setnick":
  477. if self.getAccess(user) < 5:return
  478. try:
  479. if args:
  480. user, nick = args.split(" ",1)
  481. nicks[user]=json.dumps(nick)
  482. room.message("Berhasil diSimpan")
  483. f = open("nicks.txt","w")
  484. for user in nicks:
  485. nick = json.loads(nicks[user])
  486. f.write(json.dumps([user,nick])+"\n")
  487. f.close()
  488. else:
  489. room.message("Who?")
  490. except:
  491. room.message("The nick please")
  492.  
  493.  
  494. ##Setrank
  495. if cmd == "setrank":
  496. if self.getAccess(user) < 5:return
  497. try:
  498. if len(args) >= 4:
  499. name = args
  500. if pars(name) == None:
  501. name = name
  502. elif pars(name) != None:
  503. name = pars(name)
  504. name, rank = args.lower().split(" ", 1)
  505. if rank == "5":
  506. Champion.append(name)
  507. f = open("champion.txt", "w")
  508. f.write("\n".join(champion))
  509. f.close()
  510. room.message("Sukses")
  511. if name in Hero:
  512. Hero.remove(name)
  513. f = open("Hero.txt", "w")
  514. f.write("\n".join(Hero))
  515. f.close()
  516. if name in Chief:
  517. Chief.remove(name)
  518. f = open("Chief.txt", "w")
  519. f.write("\n".join(Chief))
  520. f.close()
  521. if name in Initial:
  522. Initial.remove(name)
  523. f = open("Initial.txt", "w")
  524. f.write("\n".join(Initial))
  525. f.close()
  526. if rank == "4":
  527. Hero.append(name)
  528. f = open("Hero.txt", "w")
  529. f.write("\n".join(Hero))
  530. f.close()
  531. room.message("Sukses")
  532. if name in Chief:
  533. Chief.remove(name)
  534. f = open("Chief.txt", "w")
  535. f.write("\n".join(Chief))
  536. f.close()
  537. if name in Guardian:
  538. Guardian.remove(name)
  539. f = open("Guardian.txt", "w")
  540. f.write("\n".join(Guardian))
  541. f.close()
  542. if name in Initial:
  543. Initial.remove(name)
  544. f = open("Initial.txt", "w")
  545. f.write("\n".join(Initial))
  546. f.close()
  547. if rank == "3":
  548. Chief.append(name)
  549. f = open("Chief.txt", "w")
  550. f.write("\n".join(Chief))
  551. f.close()
  552. room.message("Sukses")
  553. if name in Champion:
  554. Champion.remove(name)
  555. f = open("Champion.txt", "w")
  556. f.write("\n".join(Champion))
  557. f.close()
  558. if name in Hero:
  559. Hero.remove(name)
  560. f = open("Hero.txt", "w")
  561. f.write("\n".join(Hero))
  562. f.close()
  563. if name in Initial:
  564. Initial.remove(name)
  565. f = open("Initial.txt", "w")
  566. f.write("\n".join(Initial))
  567. f.close()
  568. if rank == "2":
  569. Guardian.append(name)
  570. f = open("Guardian.txt", "w")
  571. f.write("\n".join(Guardian))
  572. f.close()
  573. room.message("Sukses")
  574. if name in Champion:
  575. Champion.remove(name)
  576. f = open("Champion.txt", "w")
  577. f.write("\n".join(Champion))
  578. f.close()
  579. if name in Hero:
  580. Hero.remove(name)
  581. f = open("Hero.txt", "w")
  582. f.write("\n".join(Hero))
  583. f.close()
  584. if name in Initial:
  585. Initial.remove(name)
  586. f = open("Initial.txt", "w")
  587. f.write("\n".join(Initial))
  588. f.close()
  589. if rank == "1":
  590. Initial.append(name)
  591. f = open("Initial.txt", "w")
  592. f.write("\n".join(Initial))
  593. f.close()
  594. room.message("Sukses")
  595. if name in Champion:
  596. Champion.remove(name)
  597. f = open("Champion.txt", "w")
  598. f.write("\n".join(Champion))
  599. f.close()
  600. if name in Hero:
  601. Hero.remove(name)
  602. f = open("Hero.txt", "w")
  603. f.write("\n".join(Hero))
  604. f.close()
  605. if name in Guardian:
  606. Guardian.remove(name)
  607. f = open("Guardian.txt", "w")
  608. f.write("\n".join(Guardian))
  609. f.close()
  610.  
  611. except:
  612. room.message("something wrong")
  613.  
  614. # clear
  615. elif cmd == "clear":
  616. if room.getLevel(self.user) > 0:
  617. if self.getAccess(user) >= 5 or room.getLevel(user) == 2:
  618. room.clearall(),
  619. room.clearUser(ch.User(random.choice(room.usernames))),
  620. room.clearUser(ch.User(random.choice(room.usernames))),
  621. room.clearUser(ch.User(random.choice(room.usernames))),
  622. room.clearUser(ch.User(random.choice(room.usernames))),
  623. room.clearUser(ch.User(random.choice(room.usernames))),
  624. room.clearUser(ch.User(random.choice(room.usernames))),
  625. room.clearUser(ch.User(random.choice(room.usernames))),
  626. room.clearUser(ch.User(random.choice(room.usernames))),
  627. room.clearUser(ch.User(random.choice(room.usernames))),
  628. room.clearUser(ch.User(random.choice(room.usernames))),
  629. room.clearUser(ch.User(random.choice(room.usernames))),
  630. room.clearUser(ch.User(random.choice(room.usernames))),
  631. room.clearUser(ch.User(random.choice(room.usernames))),
  632. room.clearUser(ch.User(random.choice(room.usernames))),
  633. room.clearUser(ch.User(random.choice(room.usernames))),
  634. room.clearUser(ch.User(random.choice(room.usernames))),
  635. room.clearUser(ch.User(random.choice(room.usernames))),
  636. room.clearUser(ch.User(random.choice(room.usernames))),
  637. room.clearUser(ch.User(random.choice(room.usernames))),
  638. room.clearUser(ch.User(random.choice(room.usernames))),
  639. room.clearUser(ch.User(random.choice(room.usernames))),
  640. room.clearUser(ch.User(random.choice(room.usernames))),
  641. room.clearUser(ch.User(random.choice(room.usernames))),
  642. room.clearUser(ch.User(random.choice(room.usernames))),
  643. room.clearUser(ch.User(random.choice(room.usernames))),
  644. room.clearUser(ch.User(random.choice(room.usernames))),
  645. room.clearUser(ch.User(random.choice(room.usernames))),
  646. room.clearUser(ch.User(random.choice(room.usernames))),
  647. room.clearUser(ch.User(random.choice(room.usernames))),
  648. room.clearUser(ch.User(random.choice(room.usernames))),
  649. room.clearUser(ch.User(random.choice(room.usernames))),
  650. room.clearUser(ch.User(random.choice(room.usernames))),
  651. room.clearUser(ch.User(random.choice(room.usernames))),
  652. room.clearUser(ch.User(random.choice(room.usernames))),
  653. room.clearUser(ch.User(random.choice(room.usernames))),
  654. else: room.message("Only rank 4+ or the room owner can do this")
  655. else:
  656. room.message("aku bukan mods disini :|")
  657. ##delete chat
  658. elif (cmd == "delete" or cmd == "dl" or cmd == "del"):
  659. if room.getLevel(self.user) > 0:
  660. if self.getAccess(user) >= 1 or room.getLevel(user) > 0:
  661. name = args.split()[0].lower()
  662. room.clearUser(ch.User(name))
  663. else:room.message("kamu tidak bisa melakukannya!!")
  664. else:
  665. room.message("aku bukan mods disini :|")
  666.  
  667. ##fax
  668. if cmd == "fax":
  669. if self.getAccess(user) >= 1:
  670. if len(args) > 1:
  671. try:
  672. target, body = args.split(" ", 1)
  673. if user.name in room.modnames or user.name in room.ownername or self.getAccess(user) > 2:
  674. if target in self.roomnames:
  675. if room.name == "dai-tenshi":
  676. self.getRoom(target).message("Fax from <b>%s</b> [via <font color='#ff0000'><b>%s</b></font> Fax] - <font color='#3300FF'>%s</font>" % (sntonick(user.name), "Heaven", body), True)
  677. room.message("[<b>%s</b>] Fax Sent" % "INF", True)
  678. else:
  679. self.getRoom(target).message("Fax from <b>%s</b> [via <font color='#ff0000'><b>%s</b></font> Fax] - <font color='#3300FF'>%s</font>" % (sntonick(user.name), room.name, body), True)
  680. room.message("[<b>%s</b>] Fax Sent" % "INF", True)
  681. else:
  682. room.message("[<b>%s</b>] There's no Fax Service in <font color='#ff0000'><b>%s</b></font> :|" % ("ERROR", target), True)
  683. else:
  684. room.message("You mere mortals can never do that !!")
  685. self.setTimeout(int(3), room.message, "*Aims Colt. Python Revolver at <b>%s</b> and shot him dead*" % user.name, True)
  686. except:
  687. room.message("Gagal !!")
  688.  
  689. ## Broadcast
  690. if cmd == "broadcast" or cmd == "Broadcast" or cmd == "Shout" or cmd == "shout" or cmd == "Bc" or cmd == "Bc":
  691. if user.name in Champion: #Only rank 4+ can Broadcast a Message
  692. for room in self.rooms:
  693. if args == "": return
  694. else:
  695. room.message("Broadcast de la - "+user.name + ": "+args, True)
  696. else:
  697. room.message("[<b>%s</b>] Only Admins Members are allowed" % "ERROR", True)
  698.  
  699.  
  700. ####ban
  701. if cmd == "ban" or cmd == "Ban" or cmd == "Interzicere" or cmd == "interzicere":
  702. if user.name in Champion:
  703. name = args
  704. if user.name in Champion:
  705. room.message("Njet >_>")
  706. return
  707. if name in room.usernames:
  708. room.banUser(ch.User(name))
  709. room.message("<b>%s</b> is banned" % (name), True)
  710. self.pm.message(ch.User(name.lower()), "You have been banned from %s by %s. " % (room.name, user.name))
  711. else:
  712. room.message("i don't see "+name+" here :|")
  713.  
  714.  
  715. ####Unban
  716. elif cmd == "unban" or cmd == "ub" or cmd == "UnBan" or cmd == "Unban" or cmd == "Scoate Interzicerea" or cmd == "Scoate interzicerea":
  717. if user.name in Champion:
  718. name = args
  719. if user.name in Champion: return
  720. room.unban(ch.User(name))
  721. room.message("<b>%s</b> is unbanned" % (name), True)
  722. self.pm.message(ch.User(name.lower()), "You have been unbanned from %s by %s. Please behave lik a Punk!!" % (room.name, user.name))
  723. else:
  724. room.message("You mere mortals can never do that !!")
  725.  
  726.  
  727. ##Ranker
  728. if cmd == "ranker":
  729. room.message("<br/><f x120000FF='0'><b>Champion:</b></f> %s<br/><f x12FF0000='0'><b>Hero:</b><br/><f x120000FF='0'><b>Chief:</b></f> %s</f> %s<br/><f x12FF00FF='0'><b>Guardian:</b></f>%s" % (", ".join(Champion), ", ".join(Hero), ", ".join(Chief), ", ".join(Guardian)),True)
  730. ##staff
  731. if cmd == "staff":
  732. room.message("<br/><f x120000FF='0'><b>Owner:</b></f> %s<br/><f x12FF0000='0'><b>Admin:</b></f> %s" % (", ".join(Champion), ", ".join(Hero)),True)
  733.  
  734. #### Rooms
  735. elif cmd == "rooms" or cmd == "Rooms":
  736. j = []
  737. for i in self.roomnames:
  738. j.append(i+'[%s]' % str(self.getRoom(i).usercount))
  739. j.sort()
  740. room.message("I'm Playing In "+'[%s] rooms: '%(len(self.roomnames))+", ".join(j))
  741.  
  742.  
  743. #### Credits
  744. elif cmd == "credits" or cmd == "Credits" or cmd == "Creators":
  745.  
  746. room.message('<font color="#FFCC00">%s</font>Credits: ||<font color="#DC1620"><b>%s</b></font>[<font color="#ff0000"><b>%s</b></font>] ||<font color="#f033FF">%s</font>[Coding Tutors] ||<font color="#00CC00">%s</font>[Fellow Bot Maker] ||<font color="#CC00FF">%s</font>[Trusted Test Subjects]' % ("||", "alvanCrystallenz"), True)
  747.  
  748. #### LoveMeter
  749. elif cmd == "lovemeter" or cmd == "lm" or cmd == "LoveMeter" or cmd == "Love Meter" or cmd == "Lovem":
  750. try:
  751. user2, user3 = args.split(" and ", 1)
  752. moter = random.randint(6,100)
  753. try:
  754. user1 = args.lower()
  755. if user1 in lomet:
  756. meter = json.loads(lomet[user1])
  757. meter = str(meter)
  758. room.message("I Gaze upon the stars... *Closes my eyes and concentrates*. And again, <b>%s</b> and <b>%s</b>, their love meter is <b>%s</b>%s ,, that is the answer of fate ;)" % (user2, user3, str(meter), "%"), True)
  759. else:
  760. moter = str(moter)
  761. lomet[user1] = json.dumps(moter)
  762. room.message("I Gaze upon the stars... *Closes my eyes and concentrates*. Gotcha, <b>%s</b> and <b>%s</b>, their love meter is <b>%s</b>%s ,, that is the answer of fate ;)" % (user2, user3, moter, "%"), True)
  763. except:
  764. room.message("Fail !!")
  765. except:
  766. room.message("Fail !! You must do as the fate desires !")
  767.  
  768. #### Tea
  769. elif cmd == "tea" or cmd == "Tea":
  770. if not args == "":
  771. if args in Champion:
  772. room.message("*Pour heavenly tea to my master's cup*")
  773. if args == "bot":
  774. room.message("*Sips my tea*")
  775. else:
  776. room.message("*Pour tea to "+sntonick(args)+"'s cup*", True)
  777. else:
  778. if user.name in Champion:
  779. room.message("*Pour heavenly tea to my master's cup*")
  780. else:
  781. room.message("*Pour tea to "+sntonick(user.name)+"'s cup*", True)
  782.  
  783. ###Google search and Google image search
  784. if cmd == "gs":
  785. room.message("Search Google for : ( <f x11FF0000='1'>"+args+" <f x11FFFFFF='1'> ) <br/><br/>"+gs(args),True)
  786.  
  787. if cmd == "gis":
  788. room.message("Search Google image for : ( <f x11FF0000='1'>"+args+" <f x11FFFFFF='1'> ) <br/><br/>"+gis(args),True)
  789.  
  790. #### Jones >.<
  791. elif cmd == "jones" or cmd == "Jones":
  792. if len(args)>0:
  793. obv = ["what do you want ?","what do you want?","what do you want","what do you desire ?","what do you desire","what do you desire?","what do you wish for?","what do you wish for ?","what do you wish for"]
  794. insult = ["fuck you","fook you","damn you","i hate you","kiss my ass"]
  795. jelas = ["apa maumu ?","apa maumu?","Apa maumu","apa maumu","mau lo apa ?","mau lo apa?","mau lo apa","lu mau apa?","lu mau apa ?","lu mau apa"]
  796. if args in obv:
  797. room.message(random.choice(["I want a girlfriend :)","I want you >:)","I need a whore","I want a lover","Your Anus !!","Your tits !","I want your soul >:3","Gimme a gun","Your money :|","Give me your money !!!"]))
  798. if args in jelas:
  799. room.message(random.choice(["Tidakkah jelas ? gue mau jablay !","Gue butuh cewek broh","hadehh dia pake nanya,, gue mau cewek"]))
  800. if args in insult:
  801. room.message(random.choice(["Well, Fuck you too","oh shit whatever >_>","Stfu and kiss my arse !!"]))
  802. else:
  803. if args in obv or args in insult or args in jelas: return
  804. room.message(random.choice(["yes","no","maybe","not likely","I'm too depressed right now ,try asking again later","It's a secret ;)","Still, i'm not.","True","Better not tell you now.","It is certain.","Certainly :)","I'm not sure >_>","Yes, I'am"]))
  805. else:
  806. room.message("This is The Mighty Jones command. You must ask a question for The Mighty Jones to answer...(EXAMPLE: 'jones Am I doing this right o.O ???)")
  807.  
  808.  
  809.  
  810.  
  811.  
  812. #### Profile picture
  813. if cmd == "pfpic" or cmd == "PfPic" or cmd == "ProfilePic" or cmd == "profilepic":
  814. link = "http://fp.chatango.com/profileimg/%s/%s/%s/full.jpg" % (args[0], args[1], args)
  815. room.message(link)
  816.  
  817. ##Eval
  818. if cmd == "ev" or cmd == "eval" or cmd == "e":
  819. if self.getAccess(user) == 5:
  820. ret = eval(args)
  821. if ret == None:
  822. room.message("Done.")
  823. return
  824. room.message(str(ret))
  825.  
  826. ##Say
  827. if cmd == "say":
  828. room.message(args)
  829.  
  830. ##Random User
  831. if cmd == "randomuser":
  832. room.message(random.choice(room.usernames))
  833.  
  834.  
  835.  
  836.  
  837. ##Check if Mod
  838. #not really important
  839. elif cmd == "ismod":
  840. user = ch.User(args)
  841. if room.getLevel(user) > 0:
  842. room.message("yesh")
  843. else:
  844. room.message("nope")
  845.  
  846. ## Youtube
  847. elif cmd == "youtube" or cmd == "yt":
  848. if args:
  849. room.message(tube(args),True)
  850.  
  851. ## Broadcast
  852. elif cmd=="bc" and self.getAccess(user) > 1:
  853. r = room.name
  854. l = "http://ch.besaba.com/mty.htm?"+r+"+"
  855. for room in self.rooms:
  856. room.message("[<font color='#6699CC'><b>Broadcast</b></font>] from - "+sntonick(user.name)+ " : <font color='#33FF33'><i>"+args+"<i></font>", True)
  857. ###### Define
  858. elif cmd == "define" or cmd == "df" and len(args) > 0:
  859. try:
  860. try:
  861. word, definition = args.split(" as ",1)
  862. word = word.lower()
  863. except:
  864. word = args
  865. definition = ""
  866. if len(word.split()) > 5:
  867. room.message("Fail")
  868. return
  869. elif len(definition) > 0:
  870. if word in dictionary:
  871. room.message("%s defined already" % user.name.capitalize())
  872. else:
  873. dictionary[word] = json.dumps([definition, user.name])
  874. f =open("definitions.txt", "w")
  875. for word in dictionary:
  876. definition, name = json.loads(dictionary[word])
  877. f.write(json.dumps([word, definition, name])+"\n")
  878. f.close
  879. room.message("Definition Saved")
  880. else:
  881. if word in dictionary:
  882. definition, name = json.loads(dictionary[word])
  883. room.message("<br/>ID : %s<br/>Keyword : %s<br/>Definition:<br/>%s" % (name, word, definition),True)
  884. else:
  885. room.message(args+" is not defined")
  886. except:
  887. room.message("something wrong")
  888.  
  889. ##Rank
  890.  
  891. elif cmd == "rank":
  892. if not args:
  893. if user.name in Champion and not user.name in Initial:
  894. room.message(user.name+" Kamu Rank 5 [Champion] ",True)
  895. elif user.name in Hero and not user.name in Initial and not user.name in champion and not user.name in Chief and not user.name in Guardian:
  896. room.message(user.name+" Kamu Rank 4 [Hero] ",True)
  897. elif user.name in Chief and not user.name in Initial and not user.name in Guardian and not user.name in Hero and not user.name in Champion:
  898. room.message(user.name+" Kamu Rank 3 [Chief] ",True)
  899. elif user.name in Guardian and not user.name in Initial and not user.name in Champion and not user.name in Hero and not user.name in Chief:
  900. room.message(user.name+" Kamu Rank 2 [Guardian]",True)
  901. elif user.name in Initial and not user.name in Champion:
  902. room.message(user.name+" Kamu Rank 1 [Initial]",True)
  903. elif user.name not in Initial and not user.name not in Guardian and not user.name in Chief and user.name not in Hero and user.name not in Champion:
  904. room.message(user.name+" Kamu Belum terdaftar",True)
  905.  
  906.  
  907. ##### Whitelist
  908. elif cmd == "wl" and self.getAccess(user) >= 1:
  909. name = args
  910. if name not in Initial and name not in Champion and name not in Hero and name not in Chief and name not in Guardian and name not in blacklist:
  911. room.message("Sukses")
  912. Initial.append(name)
  913. f = open("Initial.txt","w")
  914. f.write("\n".join(Initial))
  915. f.close
  916. else:
  917. room.message("User tersebut sudah terdaftar")
  918.  
  919. ###blacklist
  920. elif cmd == "bl" and self.getAccess(user) >= 3:
  921. name = args
  922. if name not in Initial and name not in Champion and name not in Hero and name not in Chief and name not in Guardian and name not in Initial:
  923. room.message("Done")
  924. blacklist.append(name)
  925. f = open("blacklist.txt","w")
  926. f.write("\n".join(blacklist))
  927. f.close
  928. else:
  929. room.message("User tersebut sudah di blacklist")
  930.  
  931. ##ubl
  932. if cmd == "ubl" and self.getAccess(user) >= 3:
  933. try:
  934. if args in blacklist:
  935. blacklist.remove(args)
  936. f = open("blacklist.txt","w")
  937. f.write("\n".join(blacklist))
  938. f.close()
  939. room.message("Sukses")
  940. except:
  941. room.message("Gagal")
  942.  
  943. ##uwl
  944. if cmd == "uwl" and self.getAccess(user) >= 3:
  945. try:
  946. if args in Owners:
  947. Champion.remove(args)
  948. f = open("Champion.txt","w")
  949. f.write("\n".join(Champion))
  950. f.close()
  951. room.message("Sukses")
  952. if args in admin:
  953. admin.remove(args)
  954. f = open("admin.txt","w")
  955. f.write("\n".join(admin))
  956. f.close()
  957. room.message("Sukses")
  958. if args in archknight:
  959. archknight.remove(args)
  960. f = open("archknight.txt","w")
  961. f.write("\n".join(archknight))
  962. f.close()
  963. room.message("Sukses")
  964. if args in Initial:
  965. Initial.remove(args)
  966. f = open("Initial.txt","w")
  967. f.write("\n".join(Initial))
  968. f.close()
  969. room.message("Sukses")
  970. except:
  971. room.message("Gagal")
  972.  
  973.  
  974. ##Dictionary
  975. if cmd == "mydict":
  976. arr = []
  977. for i in dictionary:
  978. if user.name in dictionary[i]:
  979. arr.append(i)
  980. if len(arr) > 0:
  981. room.message("You have defined <b>"+str(len(arr))+"</b> words in your dictionary :<i> %s"% (', '.join(sorted(arr))), True)
  982. else:
  983. room.message("kamu tidak memiliki dictionary.")
  984.  
  985. ###Undefine
  986. if cmd == "udf" and len(args) > 0:
  987. try:
  988. word = args
  989. if word in dictionary:
  990. definition, name = json.loads(dictionary[word])
  991. if name == user.name or self.getAccess(user) >= 3:
  992. del dictionary[word]
  993. f =open("definitions.txt", "w")
  994. for word in dictionary:
  995. definition, name = json.loads(dictionary[word])
  996. f.write(json.dumps([word, definition, name])+"\n")
  997. f.close
  998. room.message(args+" has been removed from Definition database")
  999. return
  1000. else:
  1001. room.message("<b>%s</b> you can not remove this define only masters or the person who defined the word may remove definitions" % user.name, True)
  1002. return
  1003. else:
  1004. room.message("<b>%s</b> is not yet defined you can define it by typing <b>define %s: meaning</b>" % args, True)
  1005. except:
  1006. room.message("Gagal")
  1007. return
  1008.  
  1009. ##See dict
  1010.  
  1011. elif cmd == "sdf" or cmd == "seedict":
  1012. if not args:
  1013. room.message("Whose dict do you want to see ?")
  1014. return
  1015. args = args.lower()
  1016. if pars(args) == None:
  1017. args = args.lower()
  1018. if pars(args) != None:
  1019. args = pars(args)
  1020. arr = []
  1021. for i in dictionary:
  1022. if args in dictionary[i]:
  1023. arr.append(i)
  1024. if len(arr) > 0:
  1025. room.message("<b>"+args.title()+"</b> have defined <b>"+str(len(arr))+"</b> words in his dictionary :<i> %s"% (', '.join(sorted(arr))), True)
  1026. else:
  1027. room.message(args.title()+" defined nothing.")
  1028.  
  1029. ##SeeNick
  1030.  
  1031. if cmd == "seenick":
  1032. try:
  1033. if args in nicks:
  1034. room.message(args+" Nick Dia : "+sntonick(args)+"", True)
  1035. else:
  1036. room.message(args+" Belum membuat nick di aku :|")
  1037. except:
  1038. return
  1039.  
  1040. ###Profile
  1041.  
  1042. elif cmd=="prof" or cmd == "profile":
  1043. try:
  1044. args=args.lower()
  1045. stuff=str(urlreq.urlopen("http://"+args+".chatango.com").read().decode("utf-8"))
  1046. crap, age = stuff.split('<span class="profile_text"><strong>Age:</strong></span></td><td><span class="profile_text">', 1)
  1047. age, crap = age.split('<br /></span>', 1)
  1048. crap, gender = stuff.split('<span class="profile_text"><strong>Gender:</strong></span></td><td><span class="profile_text">', 1)
  1049. gender, crap = gender.split(' <br /></span>', 1)
  1050. if gender == 'M':
  1051. gender = 'Male'
  1052. elif gender == 'F':
  1053. gender = 'Female'
  1054. else:
  1055. gender = '?'
  1056. crap, location = stuff.split('<span class="profile_text"><strong>Location:</strong></span></td><td><span class="profile_text">', 1)
  1057. location, crap = location.split(' <br /></span>', 1)
  1058. crap,mini=stuff.split("<span class=\"profile_text\"><!-- google_ad_section_start -->",1)
  1059. mini,crap=mini.split("<!-- google_ad_section_end --></span>",1)
  1060. mini=mini.replace("<img","<!")
  1061. 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>'
  1062. 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
  1063. room.message(prodata,True)
  1064. except:
  1065. room.message(""+args+" doesn't exist o.o ")
  1066. elif cmd=="mini":
  1067. try:
  1068. args=args.lower()
  1069. stuff=str(urlreq.urlopen("http://"+args+".chatango.com").read().decode("utf-8"))
  1070. crap,mini=stuff.split("<span class=\"profile_text\"><!-- google_ad_section_start -->",1)
  1071. mini,crap=mini.split("<!-- google_ad_section_end --></span>",1)
  1072. mini=mini.replace("<img","<!")
  1073. prodata = '<br/>'+mini
  1074. room.message(prodata,True)
  1075. except:
  1076. room.message(""+args+" doesn't exist o.o ")
  1077.  
  1078. ##bg image
  1079.  
  1080. if cmd == "bgimg":
  1081. try:
  1082. args=args.lower()
  1083. picture = '<a href="http://st.chatango.com/profileimg/' + args[0] + '/' + args[1] + '/' + args + '/msgbg.jpg" style="z-index:59" target="_blank">http://fp.chatango.com/profileimg/' + args[0] + '/' + args[1] + '/' + args + '/msgbg.jpg</a>'
  1084. prodata = '<br/>'+picture
  1085. room.message("<br/>"+"User ID : "+args+"<br/>Background :"+prodata,True)
  1086. except:
  1087. room.message(""+args+" doesn't exist:'v")
  1088.  
  1089.  
  1090.  
  1091.  
  1092. ### Private Messages
  1093. elif cmd=="pm":
  1094. data = args.split(" ", 1)
  1095. if len(data) > 1:
  1096. name , args = data[0], data[1]
  1097. self.pm.message(ch.User(name), "[Private.Message] By - "+user.name+" : "+args+" ")
  1098. room.message("Sent to "+name+"")
  1099. ### Sentnote
  1100. elif cmd == "inbox":
  1101. if user.name in sn:
  1102. mesg = len(sn[user.name])
  1103. room.message("["+str(mesg)+"] messages in your inbox. To read it, do irn")
  1104. else:
  1105. sn.update({user.name:[]})
  1106. mesg = len(sn[user.name])
  1107. room.message("["+str(mesg)+"] messages in your inbox. To read it, do irn")
  1108.  
  1109.  
  1110. #send notes
  1111. elif cmd == "sn" or cmd == "sendnote":
  1112. args.lower()
  1113. untuk, pesan = args.split(" ", 1)
  1114. if untuk[0] == "+":
  1115. untuk = untuk[1:]
  1116. else:
  1117. if pars(untuk) == None:
  1118. room.message("Who is "+untuk+" ??")
  1119. return
  1120. untuk = pars(untuk)
  1121. if untuk in sn:
  1122. sn[untuk].append([user.name, pesan, time.time()])
  1123. if untuk not in notif:
  1124. notif.append(untuk)
  1125. else:pass
  1126. else:
  1127. sn.update({untuk:[]})
  1128. sn[untuk].append([user.name, pesan, time.time()])
  1129. if untuk not in notif:
  1130. notif.append(untuk)
  1131. else:pass
  1132. room.message('Sent to %s'% (untuk)+"'s inbox" , True)
  1133.  
  1134.  
  1135.  
  1136. #Read Notes
  1137. elif cmd =="rn" or cmd =="readnote":
  1138. if user.name not in sn:
  1139. sn.update({user.name:[]})
  1140. user=user.name.lower()
  1141. if len(sn[user]) > 0:
  1142. messg = sn[user][0]
  1143. dari, pesen, timey = messg
  1144. timey = time.time() - int(timey)
  1145. minute = 60
  1146. hour = minute * 60
  1147. day = hour * 24
  1148. days = int(timey / day)
  1149. hours = int((timey % day) / hour)
  1150. minutes = int((timey % hour) / minute)
  1151. seconds = int(timey % minute)
  1152. string = ""
  1153. if days > 0:
  1154. string += str(days) + " " + (days == 1 and "day" or "days" ) + ", "
  1155. if len(string) > 0 or hours > 0:
  1156. string += str(hours) + " " + (hours == 1 and "hour" or "hours" ) + ", "
  1157. if len(string) > 0 or minutes > 0:
  1158. string += str(minutes) + " " + (minutes == 1 and "minute" or "minutes" ) + ", "
  1159. string += str(seconds) + " " + (seconds == 1 and "second" or "seconds" )
  1160. room.message("[<font color='#6699CC'><b>Private Message</b></font>] from - "+sntonick(dari)+" : "+pesen+" (<font color='#9999FF'>"+string+" ago </font>)", True)
  1161. try:
  1162. del sn[user][0]
  1163. notif.remove(user)
  1164. except:pass
  1165. else:room.message('%s'%(user)+" you don't have any messages in your inbox" , True)
  1166. ###### leave + room
  1167. elif cmd == "leave" and self.getAccess(user) >=1:
  1168. if not args:args=room.name
  1169. self.leaveRoom(args)
  1170. room.message("Baik aku out "+args+" ...")
  1171. print("[SAVE] SAVING Rooms...")
  1172. f = open("rooms.txt", "w")
  1173. f.write("\n".join(self.roomnames))
  1174. f.close()
  1175.  
  1176. ###### join room + roomname
  1177.  
  1178. if cmd == "join" and len(args) > 1:
  1179. if self.getAccess (user) >= 1:
  1180. if args not in self.roomnames:
  1181. room.message("Baik aku join ke "+args+" ...")
  1182. self.joinRoom(args)
  1183. else:
  1184. room.message("aku sudah ada disana ...")
  1185. print("[SAVE] SAVING Rooms...")
  1186. f = open("rooms.txt", "w")
  1187. f.write("\n".join(self.roomnames))
  1188. f.close()
  1189. elif cmd == "userlist":
  1190. if args == "":
  1191. usrs = []
  1192. gay = []
  1193. finale = []
  1194. prop = 0
  1195. prop = prop + len(room._userlist) - 1
  1196. for i in room._userlist:
  1197. i = str(i)
  1198. usrs.append(i)
  1199. while prop >= 0:
  1200. j = usrs[prop].replace("<User: ", "")
  1201. i = j.replace(">", "")
  1202. gay.append(i)
  1203. prop = prop - 1
  1204. for i in gay:
  1205. if i not in finale:
  1206. finale.append(i)
  1207. if len(finale) > 40:
  1208. room.message("<font color='#9999FF'><b>40</b></font> of <b>%s</b> users in this room: %s"% (len(finale), ", ".join(finale[:41])), True)
  1209. if len(finale) <=40 :
  1210. room.message("Current <b>%s</b> users of this room: %s"% (len(finale),", ".join(finale)), True)
  1211. if args != "":
  1212. if args not in self.roomnames:
  1213. room.message("I'm not there.")
  1214. return
  1215. users = getParticipant(str(args))
  1216. if len(users) > 40:
  1217. room.message("<font color='#9999FF'><b>40</b></font> of <b>%s</b> current users in <b>%s</b>: %s"% (len(users), args.title(), ", ".join(users[:41])), True)
  1218. if len(users) <=40:
  1219. room.message("Current <b>%s</b> users in <b>%s</b>: %s"% (len(users), args.title(), ", ".join(users)), True)
  1220. ##### bot rooms
  1221. elif cmd == "rooms" :
  1222. j = []
  1223. for i in self.roomnames:
  1224. j.append(i+'[%s]' % str(self.getRoom(i).usercount))
  1225. j.sort()
  1226. room.message("aku bermain Di "+'[%s] rooms: '%(len(self.roomnames))+", ".join(j))
  1227. ## Mods
  1228. elif cmd == "mods":
  1229. args = args.lower()
  1230. if args == "":
  1231. room.message("<font color='#ffffff'><b>Room</b>: "+room.name+" <br/><b>Owner</b>: <u>"+ (room.ownername) +"</u> <br/><b>Mods</b>: "+", ".join(room.modnames), True)
  1232. return
  1233. if args in self.roomnames:
  1234. modask = self.getRoom(args).modnames
  1235. owner = self.getRoom(args).ownername
  1236. room.message("<font color='#ffffff'><b>Room</b>: "+args+" <br/><b>Owner</b>: <u>"+ (owner) +"</u> <br/><b>Mods</b>: "+", ".join(modask), True)
  1237.  
  1238.  
  1239. ####nick
  1240. elif cmd == "nick":
  1241. ## if user.name in reg or user.name in friends or user.name in trusted or user.name in Champion:
  1242. if args:
  1243. nick = args
  1244. user = user.name
  1245. nicks[user] = json.dumps(nick)
  1246. room.message(user +' sip sekarang kamu tak panggil '+str(args)+'', True)
  1247. try:
  1248. print("[SAVING] NICKS...")
  1249. f = open("nicks.txt", "w")
  1250. for user in nicks:
  1251. nick = json.loads(nicks[user])
  1252. f.write(json.dumps([user,nick]) + "\n")
  1253. except:
  1254. room.message("Gagal membuat Nick baru..");return
  1255. else:
  1256. room.message('Ketik >nick <spasi> nama yang di inginkan', True)
  1257.  
  1258.  
  1259. ##mynick
  1260. elif cmd == "mynick" :
  1261. user=user.name.lower()
  1262. if user in nicks :
  1263. nick = json.loads(nicks[user])
  1264. room.message(user+" is nicked : "+nick,True)
  1265. else:
  1266. room.message("Belum membuat Nick di saya :D ", True)
  1267.  
  1268.  
  1269. except Exception as e:
  1270. try:
  1271. et, ev, tb = sys.exc_info()
  1272. lineno = tb.tb_lineno
  1273. fn = tb.tb_frame.f_code.co_filename
  1274. room.message("[Expectation Failed] %s Line %i - %s"% (fn, lineno, str(e)))
  1275. return
  1276. except:
  1277. room.message("Undescribeable error detected !!")
  1278. return
  1279.  
  1280.  
  1281. #### MyIp
  1282. if cmd =="myip" or cmd == "MyIp" or cmd == "MyIP" or cmd == "My IP Adress":
  1283. try:
  1284. room.message("Your I.P. address is : "+message.ip)
  1285. except:
  1286. room.message("IP lookup failed , bot is not a mod in this chat.")
  1287.  
  1288.  
  1289.  
  1290.  
  1291. ##Other Crap here, Dont worry about it
  1292.  
  1293. def onFloodWarning(self, room):
  1294. room.reconnect()
  1295.  
  1296. def onJoin(self, room, user):
  1297. print(user.name + " joined the chat!")
  1298.  
  1299. def onLeave(self, room, user):
  1300. print(user.name + " left the chat!")
  1301.  
  1302. def onUserCountChange(self, room):
  1303. print("users: " + str(room.usercount))
  1304.  
  1305.  
  1306.  
  1307.  
  1308. if __name__ == "__main__":
  1309. TestBot.easy_start(rooms, botname, password)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement