Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
1,251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 47.19 KB | None | 0 0
  1.  
  2. #################################################################################################################
  3. import ch
  4. import random
  5. import sys
  6. import re
  7. import json
  8. import time
  9. import datetime
  10. import os
  11. import urllib
  12. from xml.etree import cElementTree as ET
  13. if sys.version_info[0] > 2:
  14. import urllib.request as urlreq
  15. else:
  16. import urllib2 as urlreq
  17.  
  18. botname = 'bot name' ##isi idnya
  19. password = 'bot pass' ##isi paswordnya
  20.  
  21. ##nick names
  22. def sntonick(username):
  23. user = username.lower()
  24. if user in nicks:
  25. nick = json.loads(nicks[user])
  26. return nick
  27. else:
  28. return user
  29.  
  30. #### Returns the number of seconds since the program started.
  31. ################################################################
  32. def getUptime():
  33. # do return startTime if you just want the process start time
  34. return time.time() - startTime
  35.  
  36. def reboot():
  37. output = ("rebooting server . . .")
  38. os.popen("sudo -S reboot")
  39. return output
  40.  
  41. #### SYSTEM UPTIME
  42. def uptime():
  43.  
  44. total_seconds = float(getUptime())
  45.  
  46. # Helper vars:
  47. MINUTE = 60
  48. HOUR = MINUTE * 60
  49. DAY = HOUR * 24
  50.  
  51. # Get the days, hours, etc:
  52. days = int( total_seconds / DAY )
  53. hours = int( ( total_seconds % DAY ) / HOUR )
  54. minutes = int( ( total_seconds % HOUR ) / MINUTE )
  55. seconds = int( total_seconds % MINUTE )
  56.  
  57. # Build up the pretty string (like this: "N days, N hours, N minutes, N seconds")
  58. string = ""
  59. if days > 0:
  60. string += str(days) + " " + (days == 1 and "day" or "days" ) + ", "
  61. if len(string) > 0 or hours > 0:
  62. string += str(hours) + " " + (hours == 1 and "hour" or "hours" ) + ", "
  63. if len(string) > 0 or minutes > 0:
  64. string += str(minutes) + " " + (minutes == 1 and "minute" or "minutes" ) + ", "
  65. string += str(seconds) + " " + (seconds == 1 and "second" or "seconds" )
  66.  
  67. return string;
  68.  
  69. ## DEFINITIONS
  70. dictionary = dict()
  71. f = open("definitions.txt", "r")
  72. for line in f.readlines():
  73. try:
  74. if len(line.strip())>0:
  75. word, definition, name = json.loads(line.strip())
  76. dictionary[word] = json.dumps([definition, name])
  77. except:
  78. print("[ERROR]Cant load definition: %s" % line)
  79. f.close()
  80. ##nicks
  81. nicks=dict()#empty list
  82. f=open ("nicks.txt","r")#r=read w=right
  83. for line in f.readlines():#loop through eachlinimporte and read each line
  84. try:#try code
  85. if len(line.strip())>0:#strip the whitespace checkgreater than 0
  86. user , nick = json.loads(line.strip())
  87. nicks[user] = json.dumps(nick)
  88. except:
  89. print("[Error]Can't load nick %s" % line)
  90. f.close()
  91. ##Rooms
  92. rooms = []
  93. f = open("rooms.txt", "r") # read-only
  94. for name in f.readlines():
  95. if len(name.strip())>0: rooms.append(name.strip())
  96. f.close()
  97. ##owners
  98. owners = []
  99. try:
  100. file = open("owners.txt", "r")
  101. for name in file.readlines():
  102. if len(name.strip()) > 0:
  103. owners.append(name.strip())
  104. print("[INFO]Owners loaded...")
  105. file.close()
  106. except:
  107. print("[ERROR]no file named owners")
  108. print("2 second to read the error")
  109. time.sleep(2)
  110. exit()
  111. time.sleep(1)
  112.  
  113. ###admin
  114. admin = []
  115. try:
  116. file = open("admin.txt", "r")
  117. for name in file.readlines():
  118. if len(name.strip()) > 0:
  119. admin.append(name.strip())
  120. print("[INFO]Admin loaded...")
  121. file.close()
  122. except:
  123. print("[ERROR]no file named admin")
  124. print("2 second to read the error")
  125. time.sleep(2)
  126. exit()
  127. time.sleep(1)
  128. ##archknight
  129. archknight = []
  130. try:
  131. file = open("archknight.txt", "r")
  132. for name in file.readlines():
  133. if len(name.strip()) > 0:
  134. archknight.append(name.strip())
  135. print("[INFO]archknight loaded...")
  136. file.close()
  137. except:
  138. print("[ERROR]no file named archknight")
  139. print("2 second to read the error")
  140. time.sleep(2)
  141. exit()
  142. time.sleep(1)
  143. ##whitelist
  144. whitelist = []
  145. try:
  146. file = open("whitelist.txt", "r")
  147. for name in file.readlines():
  148. if len(name.strip()) > 0:
  149. whitelist.append(name.strip())
  150. print("[INFO]whitelist loaded...")
  151. file.close()
  152. except:
  153. print("[ERROR]no file named whitelist")
  154. print("2 second to read the error")
  155. time.sleep(2)
  156. exit()
  157. time.sleep(1)
  158.  
  159. #END#
  160. #Dlist
  161. dlist = []
  162. f = open("dlist.txt", "r") # read-onlyimport
  163. for name in f.readlines():
  164. if len(name.strip())>0: dlist.append(name.strip())
  165. f.close()
  166. #END#
  167. #SN TRY
  168. sn = dict()
  169. try:
  170. f = open('note.txt','r')
  171. sn = eval(f.read())
  172. f.close()
  173. except:pass
  174.  
  175. ## Send Notes
  176. sasaran = dict()
  177. f = open ("notes.txt", "r") #read-only
  178. for line in f.readlines():
  179. try:
  180. if len(line.strip())>0:
  181. to, body, sender = json.loads(line.strip())
  182. sasaran[to] = json.dumps([body, sender])
  183. except:
  184. print("[Error] Notes load fails : %s" % line)
  185. f.close()
  186. # SN Notifs
  187. notif = []
  188. f = open("notif.txt", "r")
  189. for name in f.readlines():
  190. if len(name.strip())>0: notif.append(name.strip())
  191. f.close
  192.  
  193. blacklist = []
  194. f = open("blacklist.txt", "r")
  195. for name in f.readlines():
  196. if len(name.strip())>0: blacklist.append(name.strip())
  197. f.close()
  198.  
  199. def tube(args):
  200. """
  201. #In case you don't know how to use this function
  202. #type this in the python console:
  203. >>> tube("pokemon dash")
  204. #and this function would return this thing:
  205. {'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'}
  206. """
  207. search = args.split()
  208. url = urlreq.urlopen("https://www.googleapis.com/youtube/v3/search?q=%s&part=snippet&key=AIzaSyBSnh-sIjd97_FmQVzlyGbcaYXuSt_oh84" % "+".join(search))
  209. udict = url.read().decode('utf-8')
  210. data = json.loads(udict)
  211. rest = []
  212. for f in data["items"]:
  213. rest.append(f)
  214.  
  215. d = random.choice(rest)
  216. link = "http://www.youtube.com/watch?v=" + d["id"]["videoId"]
  217. videoid = d["id"]["videoId"]
  218. title = d["snippet"]["title"]
  219. uploader = d["snippet"]["channelTitle"]
  220. descript = d["snippet"]['description']
  221. count = d["snippet"]["publishedAt"]
  222. 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])
  223.  
  224. def gs(args):
  225. args = args.split()
  226. headers = {}
  227. headers['User-Agent'] = "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.27 Safari/537.17"
  228. req = urllib.request.Request("https://www.google.co.id/search?q=" + "+".join(args), headers = headers)
  229. resp = urllib.request.urlopen(req).read().decode("utf-8").replace('\n','').replace('\r','').replace('\t','').replace('http://','gs:').replace('https://','gs:')
  230. anjay = re.findall('<h3 class="r">(.*?)</h3>', resp)
  231. setter = list()
  232. la = "".join(anjay)
  233. a = re.findall('<a href="gs:(.*?)" onmousedown="(.*?)">(.*?)</a>', la)
  234. q = 1
  235. for link, fak, title in a:
  236. setter.append('<br/>[%s] %s : http://%s' % (q, title.capitalize(), link))
  237. q += 1
  238. return "<br/><br/>".join(setter[0:4])
  239.  
  240.  
  241. def saveRank():
  242. f = open("owners.txt","w")
  243. f.write("\n".join(owners))
  244. f.close()
  245. f = open("admin.txt","w")
  246. f.write("\n".join(admin))
  247. f.close()
  248. f = open("archknight.txt","w")
  249. f.write("\n".join(archknight))
  250. f.close()
  251. f = open("whitelist.txt","w")
  252. f.write("\n".join(whitelist))
  253. f.close()
  254.  
  255. def googleSearch(search):
  256. try:
  257. encoded = urllib.parse.quote(search)
  258. rawData = urllib.request.urlopen("http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q="+encoded).read().decode("utf-8")
  259. jsonData = json.loads(rawData)
  260. searchResults = jsonData["responseData"]["results"]
  261. full = []
  262. val = 1
  263. for data in searchResults:
  264. if "youtube" in data["url"]:
  265. data["url"] = "http://www.youtube.com/watch?v="+data["url"][35:]
  266. full.append("<br/>"+"(<b>%s</b> %s -> %s" % (val, data["title"], data['url']))
  267. val = val + 1
  268. return '<br/>'.join(full).replace('https://','http://')
  269. except Exception as e:
  270. return str(e)
  271.  
  272.  
  273.  
  274.  
  275. ##Setting Pretty Colors
  276.  
  277. class TestBot(ch.RoomManager):
  278.  
  279. def onInit(self):
  280. self.setNameColor("000099")
  281. self.setFontColor("000099")
  282. self.setFontFace("1")
  283. self.setFontSize(11)
  284. self.enableBg()
  285. self.enableRecording()
  286.  
  287. ##Connecting Crap
  288.  
  289. def onConnect(self, room):
  290. print("Connected")
  291.  
  292. def onReconnect(self, room):
  293. print("Reconnected")
  294.  
  295. def onDisconnect(self, room):
  296. print("Disconnected")
  297.  
  298. #################################################################
  299. ### Get user access from the file, and retun lvl of access number
  300. #################################################################
  301. def getAccess(self, user):
  302. if user.name in owners: return 4 # Owners
  303. elif user.name in admin: return 3 # Admins
  304. elif user.name in archknight: return 2 # Arch Knight
  305. elif user.name in whitelist: return 1
  306. elif user.name in dlist: return 0
  307. else: return 0
  308.  
  309. ##Ignore this, you dont need to worry about this
  310. #Well, you can actually take a little time to look at it and learn something
  311.  
  312. def onMessage(self, room, user, message):
  313. try:
  314. msgdata = message.body.split(" ",1)
  315. if len(msgdata) > 1:
  316. cmd, args = msgdata[0], msgdata[1]
  317. else:
  318. cmd, args = msgdata[0],""
  319. cmd=cmd.lower()
  320. global lockdown
  321. global newnum
  322. print(user.name+" - "+message.body)
  323. if user.name in notif:
  324. room.message(user.name+", you got ("+str(len(sn[user.name]))+") messages unread. Do irn to read them")
  325. notif.remove(user.name)
  326. if user == self.user: return
  327. if message.body == "": return
  328. if message.body[0] in [":"]:
  329. data = message.body[1:].split(" ", 1)
  330. if len(data) > 1:
  331. cmd, args = data[0], data[1]
  332. else:
  333. cmd, args = data[0], ""
  334.  
  335.  
  336.  
  337. ##check access and ignore
  338. if self.getAccess(user) == 0: return
  339. def pars(args):
  340. args=args.lower()
  341. for name in room.usernames:
  342. if args in name:return name
  343. def roompars(args):
  344. args = args.lower()
  345. for name in self.roomnames:
  346. if args in name:return name
  347. def roomUsers():
  348. usrs = []
  349. gay = []
  350. prop = 0
  351. prop = prop + len(room._userlist) - 1
  352. for i in room._userlist:
  353. i = str(i)
  354. usrs.append(i)
  355. while prop >= 0:
  356. j = usrs[prop].replace("<User: ", "")
  357. i = j.replace(">", "")
  358. gay.append(i)
  359. prop = prop - 1
  360. return gay
  361.  
  362. def getParticipant(arg):
  363. rname = self.getRoom(arg)
  364. usrs = []
  365. gay = []
  366. finale = []
  367. prop = 0
  368. prop = prop + len(rname._userlist) - 1
  369. for i in rname._userlist:
  370. i = str(i)
  371. usrs.append(i)
  372. while prop >= 0:
  373. j = usrs[prop].replace("<User: ", "")
  374. i = j.replace(">", "")
  375. gay.append(i)
  376. prop = prop - 1
  377. for j in gay:
  378. if j not in finale:
  379. finale.append(j)
  380. return finale
  381.  
  382. except:pass
  383. try:
  384. msgdata = message.body.split(" ",1)
  385. if len(msgdata) > 1:
  386. cmd, args = msgdata[0], msgdata[1]
  387. else:
  388. cmd, args = msgdata[0],""
  389. cmd=cmd.lower()
  390. global lockdown
  391. global newnum
  392. print(user.name+" - "+message.body)
  393. if user.name in notif:
  394. room.message(user.name+", you got ("+str(len(sn[user.name]))+") messages unread. Do irn to read them")
  395. notif.remove(user.name)
  396. if user == self.user: return
  397. if "angel" == message.body:
  398. if self.getAccess(user) >= 1 or room.getLevel(user) > 0 and not user.name in blacklist:
  399. room.message (random.choice(["yes "+sntonick(user.name)+ " ? "]),True)
  400. if "malam" == message.body:
  401. if self.getAccess(user) >= 1 or room.getLevel(user) > 0 and not user.name in blacklist:
  402. room.message("Malam Kk Cantik"+ " ;) ")
  403. if "pagi" == message.body:
  404. if self.getAccess(user) >= 1 or room.getLevel(user) > 0 and not user.name in blacklist:
  405. room.message("Pagi Juga Kk"+ " *waves* ")
  406. if "siang" == message.body:
  407. if self.getAccess(user) >= 1 or room.getLevel(user) > 0 and not user.name in blacklist:
  408. room.message("Ganbatte Kk "+sntonick(user.name)+ " ~d "),True
  409. if "sore" == message.body:
  410. if self.getAccess(user) >= 1 or room.getLevel(user) > 0 and not user.name in blacklist:
  411. room.message("Selamat sore"+ " ^o^ ")
  412. if "afk" in message.body:
  413. if self.getAccess(user) >= 1 or room.getLevel(user) > 0 and not user.name in blacklist:
  414. room.message (random.choice(["See ya "+sntonick(user.name)+" :) ",]),True)
  415. if "bye" in message.body:
  416. if self.getAccess(user) >= 1 or room.getLevel(user) > 0 and not user.name in blacklist:
  417. room.message (random.choice(["Bye *waves* "+sntonick(user.name)+" :) ",]),True)
  418. if "off" in message.body:
  419. if self.getAccess(user) >= 1 or room.getLevel(user) > 0 and not user.name in blacklist:
  420. room.message (random.choice(["See ya "+sntonick(user.name)+" :) ",]),True)
  421. if "test" in message.body:
  422. if self.getAccess(user) >= 1 or room.getLevel(user) > 0 and not user.name in blacklist:
  423. room.message (random.choice(["Succes :) "+sntonick(user.name)+" :) ",]),True)
  424. if "kai" in message.body:
  425. if self.getAccess(user) >= 1 or room.getLevel(user) > 0 and not user.name in blacklist:
  426. room.message (random.choice(["Yes *waves* "+sntonick(user.name)+" :) ",]),True)
  427. if "brb" in message.body:
  428. if self.getAccess(user) >= 1 or room.getLevel(user) > 0 and not user.name in blacklist:
  429. room.message (random.choice(["Bye "+sntonick(user.name)+" :) ",]),True)
  430. if message.body == "": return
  431. if message.body[0] in ["$"]:
  432. data = message.body[1:].split(" ", 1)
  433. if len(data) > 1:
  434. cmd, args = data[0], data[1]
  435. else:
  436. cmd, args = data[0], ""
  437.  
  438. #Find
  439. if cmd == "find" and len(args) > 0:
  440. name = args.split()[0].lower()
  441. if not ch.User(name).roomnames:
  442. room.message("aku tidak tau")
  443. else:
  444. room.message("kamu dapat menemukan %s Di %s" % (args, ", ".join(ch.User(name).roomnames)),True)
  445.  
  446. ##cmds
  447. if cmd == "cmds":
  448. if user.name in owners and not user.name in admin and not user.name in archknight and not user.name in whitelist:
  449. room.message("<br/>"+user.name+" Rank 4 [Owner] "+"<br/>"+" Perintah[ > ] :<br/>wl , gs(Google search) , yt(Youtube) , df(define) , udf(undefine) , fax , bc , sn(sendnote) , rn(readnote) , join , leave , mydict, nick , staff , setnick , mynick , seenick , profile , rank , myrank , ranker ,",True)
  450. if user.name in admin and not user.name in owners and not user.name in archknight and not user.name in whitelist:
  451. room.message("<br/>"+user.name+" Rank 3 [Admin] "+"<br/>"+" Perintah[ > ] :<br/>wl , gs(Google search) , yt(Youtube) , df(define) , udf(undefine) , fax , bc , sn(sendnote) , rn(readnote) , join , leave , mydict, nick , staff , setnick , mynick , seenick , profile , rank , myrank , ranker ,",True)
  452. if user.name in archknight and not user.name in owners and not user.name in admin and not user.name in whitelist:
  453. room.message("<br/>"+user.name+" Rank 2 [Archknight] "+"<br/>"+" Perintah[ > ] :<br/>wl , gs(Google search) , yt(Youtube) , df(define) , udf(undefine) , fax , bc , sn(sendnote) , rn(readnote) , join , leave , mydict, nick , staff , setnick , mynick , seenick , profile , rank , myrank , ranker ,",True)
  454. if user.name in whitelist and not user.name in owners and not user.name in admin and not user.name in archknight:
  455. room.message("<br/>"+user.name+" Rank 1 [Whitelist] "+"<br/>"+" Perintah[ > ] :<br/>wl , gs(Google search) , yt(Youtube) , df(define) , udf(undefine) , fax , bc , sn(sendnote) , rn(readnote) , join , leave , mydict, nick , staff , setnick , mynick , seenick , profile , rank , myrank , ranker ,",True)
  456.  
  457. ###Setrank
  458. if cmd == "setrank":
  459. if self.getAccess(user) < 4:return
  460. try:
  461. if len(args) >= 3:
  462. name = args
  463. if pars(name) == None:
  464. name = name
  465. elif pars(name) != None:
  466. name = pars(name)
  467. name, rank = args.lower().split(" ", 1)
  468. if rank == "4":
  469. owners.append(name)
  470. f = open("owners.txt", "w")
  471. f.write("\n".join(owners))
  472. f.close()
  473. room.message("Sukses ;) ")
  474. if name in admin:
  475. admin.remove(name)
  476. f = open("admin.txt", "w")
  477. f.write("\n".join(admin))
  478. f.close()
  479. if name in archknight:
  480. archknight.remove(name)
  481. f = open("archknight.txt", "w")
  482. f.write("\n".join(archknight))
  483. f.close()
  484. if name in whitelist:
  485. whitelist.remove(name)
  486. f = open("whitelist.txt", "w")
  487. f.write("\n".join(whitelist))
  488. f.close()
  489. if rank == "3":
  490. admin.append(name)
  491. f = open("admin.txt", "w")
  492. f.write("\n".join(admin))
  493. f.close()
  494. room.message("Sukses ;) ")
  495. if name in owners:
  496. owners.remove(name)
  497. f = open("owners.txt", "w")
  498. f.write("\n".join(owners))
  499. f.close()
  500. if name in archknight:
  501. archknight.remove(name)
  502. f = open("archknight.txt", "w")
  503. f.write("\n".join(archknight))
  504. f.close()
  505. if name in whitelist:
  506. whitelist.remove(name)
  507. f = open("whitelist.txt", "w")
  508. f.write("\n".join(whitelist))
  509. f.close()
  510. if rank == "2":
  511. archknight.append(name)
  512. f = open("archknight.txt", "w")
  513. f.write("\n".join(archknight))
  514. f.close()
  515. room.message("Sukses ;) ")
  516. if name in owners:
  517. owners.remove(name)
  518. f = open("owners.txt", "w")
  519. f.write("\n".join(owners))
  520. f.close()
  521. if name in admin:
  522. admin.remove(name)
  523. f = open("admin.txt", "w")
  524. f.write("\n".join(admin))
  525. f.close()
  526. if name in whitelist:
  527. whitelist.remove(name)
  528. f = open("whitelist.txt", "w")
  529. f.write("\n".join(whitelist))
  530. f.close()
  531. if rank == "1":
  532. whitelist.append(name)
  533. f = open("whitelist.txt", "w")
  534. f.write("\n".join(whitelist))
  535. f.close()
  536. room.message("Sukses ;) ")
  537. if name in owners:
  538. owners.remove(name)
  539. f = open("owners.txt", "w")
  540. f.write("\n".join(owners))
  541. f.close()
  542. if name in admin:
  543. admin.remove(name)
  544. f = open("admin.txt", "w")
  545. f.write("\n".join(admin))
  546. f.close()
  547. if name in archknight:
  548. archknight.remove(name)
  549. f = open("archknight.txt", "w")
  550. f.write("\n".join(archknight))
  551. f.close()
  552.  
  553. except:
  554. room.message("something wrong")
  555.  
  556. ##Setnick
  557. if cmd == "setnick":
  558. if self.getAccess(user) < 4:return
  559. try:
  560. if args:
  561. user, nick = args.split(" ",1)
  562. nicks[user]=json.dumps(nick)
  563. room.message("Sukses")
  564. f = open("nicks.txt","w")
  565. for user in nicks:
  566. nick = json.loads(nicks[user])
  567. f.write(json.dumps([user,nick])+"\n")
  568. f.close()
  569. else:
  570. room.message("Who?")
  571. except:
  572. room.message("The nick please")
  573.  
  574.  
  575.  
  576.  
  577. # clear
  578. elif cmd == "clear":
  579. if room.getLevel(self.user) > 0:
  580. if self.getAccess(user) >= 4 or room.getLevel(user) == 2:
  581. room.clearall(),
  582. room.clearUser(ch.User(random.choice(room.usernames))),
  583. room.clearUser(ch.User(random.choice(room.usernames))),
  584. room.clearUser(ch.User(random.choice(room.usernames))),
  585. room.clearUser(ch.User(random.choice(room.usernames))),
  586. room.clearUser(ch.User(random.choice(room.usernames))),
  587. room.clearUser(ch.User(random.choice(room.usernames))),
  588. room.clearUser(ch.User(random.choice(room.usernames))),
  589. room.clearUser(ch.User(random.choice(room.usernames))),
  590. room.clearUser(ch.User(random.choice(room.usernames))),
  591. room.clearUser(ch.User(random.choice(room.usernames))),
  592. room.clearUser(ch.User(random.choice(room.usernames))),
  593. room.clearUser(ch.User(random.choice(room.usernames))),
  594. room.clearUser(ch.User(random.choice(room.usernames))),
  595. room.clearUser(ch.User(random.choice(room.usernames))),
  596. room.clearUser(ch.User(random.choice(room.usernames))),
  597. room.clearUser(ch.User(random.choice(room.usernames))),
  598. room.clearUser(ch.User(random.choice(room.usernames))),
  599. room.clearUser(ch.User(random.choice(room.usernames))),
  600. room.clearUser(ch.User(random.choice(room.usernames))),
  601. room.clearUser(ch.User(random.choice(room.usernames))),
  602. room.clearUser(ch.User(random.choice(room.usernames))),
  603. room.clearUser(ch.User(random.choice(room.usernames))),
  604. room.clearUser(ch.User(random.choice(room.usernames))),
  605. room.clearUser(ch.User(random.choice(room.usernames))),
  606. room.clearUser(ch.User(random.choice(room.usernames))),
  607. room.clearUser(ch.User(random.choice(room.usernames))),
  608. room.clearUser(ch.User(random.choice(room.usernames))),
  609. room.clearUser(ch.User(random.choice(room.usernames))),
  610. room.clearUser(ch.User(random.choice(room.usernames))),
  611. room.clearUser(ch.User(random.choice(room.usernames))),
  612. room.clearUser(ch.User(random.choice(room.usernames))),
  613. room.clearUser(ch.User(random.choice(room.usernames))),
  614. room.clearUser(ch.User(random.choice(room.usernames))),
  615. room.clearUser(ch.User(random.choice(room.usernames))),
  616. room.clearUser(ch.User(random.choice(room.usernames))),
  617. else: room.message("Only rank 4+ or the room owner can do this")
  618. else:
  619. room.message("aku bukan mods disini :|")
  620.  
  621. ##delete chat
  622. elif (cmd == "delete" or cmd == "dl" or cmd == "del"):
  623. if room.getLevel(self.user) > 0:
  624. if self.getAccess(user) >= 1 or room.getLevel(user) > 0:
  625. name = args.split()[0].lower()
  626. room.clearUser(ch.User(name))
  627. else:room.message("kamu tidak bisa melakukannya!!")
  628. else:
  629. room.message("aku bukan mods disini :|")
  630.  
  631. ##fax
  632. if cmd == "fax":
  633. if self.getAccess(user) >= 1:
  634. if len(args) > 1:
  635. try:
  636. target, body = args.split(" ", 1)
  637. if user.name in room.modnames or user.name in room.ownername or self.getAccess(user) > 2:
  638. if target in self.roomnames:
  639. if room.name == "dai-tenshi":
  640. 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)
  641. room.message("[<b>%s</b>] Fax Sent" % "INF", True)
  642. else:
  643. 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)
  644. room.message("[<b>%s</b>] Fax Sent" % "INF", True)
  645. else:
  646. room.message("[<b>%s</b>] There's no Fax Service in <font color='#ff0000'><b>%s</b></font> :|" % ("ERROR", target), True)
  647. else:
  648. room.message("You mere mortals can never do that !!")
  649. self.setTimeout(int(3), room.message, "*Aims Colt. Python Revolver at <b>%s</b> and shot him dead*" % user.name, True)
  650. except:
  651. room.message("Gagal !!")
  652.  
  653.  
  654.  
  655. if cmd == "ban":
  656. if args in five or args in six or args in seven:
  657. room.message("<f x10808080='1'>It is not possible to ban the user <f x10F8498A='1'>"+args+"<f x10808080='1'> because its rank is high", True)
  658. else:
  659. if room.getLevel(self.user) == 1 :
  660. if self.getAccess(room, user) >= 4:
  661. room.banUser(ch.User(args))
  662. room.message("<f x10808080='1'>The user <f x10808080='1'>"+args+"<f x10808080='1'> has been banned", True)
  663. else:
  664. room.message("<f x10808080='1'>You do not have rank to ban.", True)
  665. else:
  666. room.message("<f x10808080='1'>I'm no have rank in the chat to unban.", True)
  667.  
  668. if cmd == "unban":
  669. if self.getAccess(room, user) >= 4:
  670. if room.getLevel(self.user) == 1 :
  671. if args == "": return
  672. if ch.User(args) not in room._getBanlist():
  673. room.message("<f x10808080='1'>The user <f x10F8498A='1'>"+args+"<f x10808080='1'> is not banned.", True)
  674. if ch.User(args) in room._getBanlist():
  675. room.unban(ch.User(args))
  676. room.message("<f x10808080='1'>Has removed banned from <f x10F8498A='1'>"+args+"<f x10808080='1'>, do not abuse the rule again, it prevents ban", True)
  677. else:
  678. room.message("<f x10808080='1'>I'm no have rank in the chat to unban", True)
  679. else:
  680. room.message("<f x10808080='1'>You do not have rank for unban", True)
  681.  
  682. ##Ranker
  683. if cmd == "ranker":
  684. room.message("<br/><f x120000FF='0'><b>Owner:</b></f> %s<br/><f x12FF0 00='0'><b>Admin:</b></f> %s<br/><f x12FF00FF='0'><b>ArchKnight:</b></f>%s" % (", ".join(owners), ", ".join(admin), ", ".join(archknight)),True)
  685. ##staff
  686. if cmd == "staff":
  687. room.message("<br/><f x120000FF='0'><b>Owner:</b></f> %s<br/><f x12FF0000='0'><b>Admin:</b></f> %s" % (", ".join(owners), ", ".join(admin)),True)
  688.  
  689.  
  690. ##GS
  691. if cmd == "gs":
  692. room.message(gs(args),True)
  693.  
  694. if cmd == "pic":
  695. link = "http://fp.chatango.com/profileimg/%s/%s/%s/full.jpg" % (args[0], args[1], args)
  696. room.message("<br/>"+"User ID : "+args+""+"<br/>Profile Picture :<br/>"+link,True)
  697. ##Eval
  698. if cmd == "ev" or cmd == "eval" or cmd == "e":
  699. if self.getAccess(user) == 4:
  700. ret = eval(args)
  701. if ret == None:
  702. room.message("Done.")
  703. return
  704. room.message(str(ret))
  705.  
  706. ##Say
  707. if cmd == "say":
  708. room.message(args)
  709.  
  710. ##Random User
  711. if cmd == "randomuser":
  712. room.message(random.choice(room.usernames))
  713.  
  714.  
  715.  
  716.  
  717. ##Check if Mod
  718. #not really important
  719. elif cmd == "ismod":
  720. user = ch.User(args)
  721. if room.getLevel(user) > 0:
  722. room.message("yesh")
  723. else:
  724. room.message("nope")
  725.  
  726. ## Youtube
  727. elif cmd == "youtube" or cmd == "yt":
  728. if args:
  729. room.message(tube(args),True)
  730.  
  731. ## Broadcast
  732. elif cmd=="bc" and self.getAccess(user) > 1:
  733. r = room.name
  734. l = "http://ch.besaba.com/mty.htm?"+r+"+"
  735. for room in self.rooms:
  736. room.message("[<font color='#6699CC'><b>Broadcast</b></font>] from - "+sntonick(user.name)+ " : <font color='#33FF33'><i>"+args+"<i></font>", True)
  737. ###### Define
  738. elif cmd == "define" or cmd == "df" and len(args) > 0:
  739. try:
  740. try:
  741. word, definition = args.split(" as ",1)
  742. word = word.lower()
  743. except:
  744. word = args
  745. definition = ""
  746. if len(word.split()) > 4:
  747. room.message("Fail")
  748. return
  749. elif len(definition) > 0:
  750. if word in dictionary:
  751. room.message("%s defined already" % user.name.capitalize())
  752. else:
  753. dictionary[word] = json.dumps([definition, user.name])
  754. f =open("definitions.txt", "w")
  755. for word in dictionary:
  756. definition, name = json.loads(dictionary[word])
  757. f.write(json.dumps([word, definition, name])+"\n")
  758. f.close
  759. room.message("Definition Saved")
  760. else:
  761. if word in dictionary:
  762. definition, name = json.loads(dictionary[word])
  763. room.message("<br/>ID : %s<br/>Keyword : %s<br/>Definition:<br/>%s" % (name, word, definition),True)
  764. else:
  765. room.message(args+" is not defined")
  766. except:
  767. room.message("something wrong")
  768.  
  769. elif cmd == "rank":
  770. if not args:
  771. if user.name in owners and not user.name in whitelist:
  772. room.message(user.name+" Kamu Rank 4 [Owner] ",True)
  773. elif user.name in admin and not user.name in whitelist and not user.name in archknight and not user.name in owner:
  774. room.message(user.name+" Kamu Rank 3 [Admin] ",True)
  775. elif user.name in archknight and not user.name in whitelist and not user.name in owners and not user.name in admin:
  776. room.message(user.name+" Kamu Rank 2 [Arckhnight]",True)
  777. elif user.name in whitelist and not user.name in owners:
  778. room.message(user.name+" Kamu Rank 1 [Whitelist]",True)
  779. elif user.name not in whitelist and not user.name not in archknight and user.name not in admin and user.name not in owners:
  780. room.message(user.name+" Kamu Belum terdaftar",True)
  781. if args:
  782. sss = args
  783. if sss in owners:
  784. room.message(sss.title()+" Rank Dia 4 [Owner] ",True)
  785. if sss in admin:
  786. room.message(sss.title()+" Rank Dia 3 [Admin] ",True)
  787. if sss in archknight:
  788. room.message(sss.title()+" Rank Dia 2 [Arckhnight] ",True)
  789. if sss in whitelist:
  790. room.message(sss.title()+" rank Dia 1 [Whitelist] ",True)
  791. if sss not in owners and sss not in admin and sss not in archknight and sss not in whitelist:
  792. room.message(sss.title()+" Tidak ada rank :) ")
  793.  
  794.  
  795. ##### Whitelist
  796. elif cmd == "wl" and self.getAccess(user) >= 1:
  797. name = args
  798. if name not in whitelist and name not in owners and name not in admin and name not in archknight and name not in blacklist:
  799. room.message("Sukses")
  800. whitelist.append(name)
  801. f = open("whitelist.txt","w")
  802. f.write("\n".join(whitelist))
  803. f.close
  804. else:
  805. room.message("User tersebut sudah terdaftar")
  806.  
  807. ###blacklist
  808. elif cmd == "bl" and self.getAccess(user) >= 3:
  809. name = args
  810. if name not in whitelist and name not in owners and name not in admin and name not in archknight:
  811. room.message("Done")
  812. blacklist.append(name)
  813. f = open("blacklist.txt","w")
  814. f.write("\n".join(blacklist))
  815. f.close
  816. else:
  817. room.message("User tersebut sudah di blacklist")
  818.  
  819. ##ubl
  820. if cmd == "ubl" and self.getAccess(user) >= 3:
  821. try:
  822. if args in blacklist:
  823. blacklist.remove(args)
  824. f = open("blacklist.txt","w")
  825. f.write("\n".join(blacklist))
  826. f.close()
  827. room.message("Sukses")
  828. except:
  829. room.message("Gagal")
  830.  
  831. ##uwl
  832. if cmd == "uwl" and self.getAccess(user) >= 3:
  833. try:
  834. if args in owners:
  835. owners.remove(args)
  836. f = open("owners.txt","w")
  837. f.write("\n".join(owners))
  838. f.close()
  839. room.message("Sukses")
  840. if args in admin:
  841. admin.remove(args)
  842. f = open("admin.txt","w")
  843. f.write("\n".join(admin))
  844. f.close()
  845. room.message("Sukses")
  846. if args in archknight:
  847. archknight.remove(args)
  848. f = open("archknight.txt","w")
  849. f.write("\n".join(archknight))
  850. f.close()
  851. room.message("Sukses")
  852. if args in whitelist:
  853. whitelist.remove(args)
  854. f = open("whitelist.txt","w")
  855. f.write("\n".join(whitelist))
  856. f.close()
  857. room.message("Sukses")
  858. except:
  859. room.message("Gagal")
  860.  
  861. if cmd== "sbg":
  862. if self.getAccess(user) >= 3:
  863. if len(args) > 0:
  864. if args == "on":
  865. room.setBgMode(1)
  866. room.message("Background On")
  867. return
  868. if args == "off":
  869. room.setBgMode(0)
  870. room.message("Background Off")
  871. elif cmd == "mydict":
  872. arr = []
  873. for i in dictionary:
  874. if user.name in dictionary[i]:
  875. arr.append(i)
  876. if len(arr) > 0:
  877. room.message("You have defined <b>"+str(len(arr))+"</b> words in your dictionary :<i> %s"% (', '.join(sorted(arr))), True)
  878. else:
  879. room.message("kamu tidak memiliki dictionary.")
  880.  
  881.  
  882.  
  883. if cmd == "udf" and len(args) > 0:
  884. try:
  885. word = args
  886. if word in dictionary:
  887. definition, name = json.loads(dictionary[word])
  888. if name == user.name or self.getAccess(user) >= 3:
  889. del dictionary[word]
  890. f =open("definitions.txt", "w")
  891. for word in dictionary:
  892. definition, name = json.loads(dictionary[word])
  893. f.write(json.dumps([word, definition, name])+"\n")
  894. f.close
  895. room.message(args+" has been removed from Definition database")
  896. return
  897. else:
  898. 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)
  899. return
  900. else:
  901. room.message("<b>%s</b> is not yet defined you can define it by typing <b>define %s: meaning</b>" % args, True)
  902. except:
  903. room.message("Gagal")
  904. return
  905.  
  906. elif cmd == "sdf" or cmd == "seedict":
  907. if not args:
  908. room.message("Whose dict do you want to see ?")
  909. return
  910. args = args.lower()
  911. if pars(args) == None:
  912. args = args.lower()
  913. if pars(args) != None:
  914. args = pars(args)
  915. arr = []
  916. for i in dictionary:
  917. if args in dictionary[i]:
  918. arr.append(i)
  919. if len(arr) > 0:
  920. room.message("<b>"+args.title()+"</b> have defined <b>"+str(len(arr))+"</b> words in his dictionary :<i> %s"% (', '.join(sorted(arr))), True)
  921. else:
  922. room.message(args.title()+" defined nothing.")
  923.  
  924. if cmd == "seenick":
  925. try:
  926. if args in nicks:
  927. room.message(args+" Nick Dia : "+sntonick(args)+"", True)
  928. else:
  929. room.message(args+" Belum membuat nick di aku :|")
  930. except:
  931. return
  932.  
  933. elif cmd=="prof" or cmd == "profile":
  934. try:
  935. args=args.lower()
  936. stuff=str(urlreq.urlopen("http://"+args+".chatango.com").read().decode("utf-8"))
  937. crap, age = stuff.split('<span class="profile_text"><strong>Age:</strong></span></td><td><span class="profile_text">', 1)
  938. age, crap = age.split('<br /></span>', 1)
  939. crap, gender = stuff.split('<span class="profile_text"><strong>Gender:</strong></span></td><td><span class="profile_text">', 1)
  940. gender, crap = gender.split(' <br /></span>', 1)
  941. if gender == 'M':
  942. gender = 'Male'
  943. elif gender == 'F':
  944. gender = 'Female'
  945. else:
  946. gender = '?'
  947. crap, location = stuff.split('<span class="profile_text"><strong>Location:</strong></span></td><td><span class="profile_text">', 1)
  948. location, crap = location.split(' <br /></span>', 1)
  949. crap,mini=stuff.split("<span class=\"profile_text\"><!-- google_ad_section_start -->",1)
  950. mini,crap=mini.split("<!-- google_ad_section_end --></span>",1)
  951. mini=mini.replace("<img","<!")
  952. 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>'
  953. 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
  954. room.message(prodata,True)
  955. except:
  956. room.message(""+args+" doesn't exist o.o ")
  957. elif cmd=="mini":
  958. try:
  959. args=args.lower()
  960. stuff=str(urlreq.urlopen("http://"+args+".chatango.com").read().decode("utf-8"))
  961. crap,mini=stuff.split("<span class=\"profile_text\"><!-- google_ad_section_start -->",1)
  962. mini,crap=mini.split("<!-- google_ad_section_end --></span>",1)
  963. mini=mini.replace("<img","<!")
  964. prodata = '<br/>'+mini
  965. room.message(prodata,True)
  966. except:
  967. room.message(""+args+" doesn't exist o.o ")
  968.  
  969. if cmd == "bgimg":
  970. try:
  971. args=args.lower()
  972. 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>'
  973. prodata = '<br/>'+picture
  974. room.message("<br/>"+"User ID : "+args+"<br/>Background :"+prodata,True)
  975. except:
  976. room.message(""+args+" doesn't exist:'v")
  977.  
  978.  
  979.  
  980.  
  981. ### Private Messages
  982. elif cmd=="pm":
  983. data = args.split(" ", 1)
  984. if len(data) > 1:
  985. name , args = data[0], data[1]
  986. self.pm.message(ch.User(name), "[Private.Message] By - "+user.name+" : "+args+" ")
  987. room.message("Sent to "+name+"")
  988. ### Sentnote
  989. elif cmd == "inbox":
  990. if user.name in sn:
  991. mesg = len(sn[user.name])
  992. room.message("["+str(mesg)+"] messages in your inbox. To read it, do irn")
  993. else:
  994. sn.update({user.name:[]})
  995. mesg = len(sn[user.name])
  996. room.message("["+str(mesg)+"] messages in your inbox. To read it, do irn")
  997.  
  998.  
  999. #send notes
  1000. elif cmd == "sn" or cmd == "sendnote":
  1001. args.lower()
  1002. untuk, pesan = args.split(" ", 1)
  1003. if untuk[0] == "+":
  1004. untuk = untuk[1:]
  1005. else:
  1006. if pars(untuk) == None:
  1007. room.message("Who is "+untuk+" ??")
  1008. return
  1009. untuk = pars(untuk)
  1010. if untuk in sn:
  1011. sn[untuk].append([user.name, pesan, time.time()])
  1012. if untuk not in notif:
  1013. notif.append(untuk)
  1014. else:pass
  1015. else:
  1016. sn.update({untuk:[]})
  1017. sn[untuk].append([user.name, pesan, time.time()])
  1018. if untuk not in notif:
  1019. notif.append(untuk)
  1020. else:pass
  1021. room.message('Sent to %s'% (untuk)+"'s inbox" , True)
  1022.  
  1023.  
  1024.  
  1025. #Read Notes
  1026. elif cmd =="rn" or cmd =="readnote":
  1027. if user.name not in sn:
  1028. sn.update({user.name:[]})
  1029. user=user.name.lower()
  1030. if len(sn[user]) > 0:
  1031. messg = sn[user][0]
  1032. dari, pesen, timey = messg
  1033. timey = time.time() - int(timey)
  1034. minute = 60
  1035. hour = minute * 60
  1036. day = hour * 24
  1037. days = int(timey / day)
  1038. hours = int((timey % day) / hour)
  1039. minutes = int((timey % hour) / minute)
  1040. seconds = int(timey % minute)
  1041. string = ""
  1042. if days > 0:
  1043. string += str(days) + " " + (days == 1 and "day" or "days" ) + ", "
  1044. if len(string) > 0 or hours > 0:
  1045. string += str(hours) + " " + (hours == 1 and "hour" or "hours" ) + ", "
  1046. if len(string) > 0 or minutes > 0:
  1047. string += str(minutes) + " " + (minutes == 1 and "minute" or "minutes" ) + ", "
  1048. string += str(seconds) + " " + (seconds == 1 and "second" or "seconds" )
  1049. room.message("[<font color='#6699CC'><b>Private Message</b></font>] from - "+sntonick(dari)+" : "+pesen+" (<font color='#9999FF'>"+string+" ago </font>)", True)
  1050. try:
  1051. del sn[user][0]
  1052. notif.remove(user)
  1053. except:pass
  1054. else:room.message('%s'%(user)+" you don't have any messages in your inbox" , True)
  1055. ###### leave + room
  1056. elif cmd == "leave" and self.getAccess(user) >=1:
  1057. if not args:args=room.name
  1058. self.leaveRoom(args)
  1059. room.message("Baik aku out "+args+" ...")
  1060. print("[SAVE] SAVING Rooms...")
  1061. f = open("rooms.txt", "w")
  1062. f.write("\n".join(self.roomnames))
  1063. f.close()
  1064.  
  1065. ###### join room + roomname
  1066.  
  1067. if cmd == "join" and len(args) > 1:
  1068. if self.getAccess (user) >= 1:
  1069. if args not in self.roomnames:
  1070. room.message("Baik aku join ke "+args+" ...")
  1071. self.joinRoom(args)
  1072. else:
  1073. room.message("aku sudah ada disana ...")
  1074. print("[SAVE] SAVING Rooms...")
  1075. f = open("rooms.txt", "w")
  1076. f.write("\n".join(self.roomnames))
  1077. f.close()
  1078. elif cmd == "userlist":
  1079. if args == "":
  1080. usrs = []
  1081. gay = []
  1082. finale = []
  1083. prop = 0
  1084. prop = prop + len(room._userlist) - 1
  1085. for i in room._userlist:
  1086. i = str(i)
  1087. usrs.append(i)
  1088. while prop >= 0:
  1089. j = usrs[prop].replace("<User: ", "")
  1090. i = j.replace(">", "")
  1091. gay.append(i)
  1092. prop = prop - 1
  1093. for i in gay:
  1094. if i not in finale:
  1095. finale.append(i)
  1096. if len(finale) > 40:
  1097. room.message("<font color='#9999FF'><b>40</b></font> of <b>%s</b> users in this room: %s"% (len(finale), ", ".join(finale[:41])), True)
  1098. if len(finale) <=40 :
  1099. room.message("Current <b>%s</b> users of this room: %s"% (len(finale),", ".join(finale)), True)
  1100. if args != "":
  1101. if args not in self.roomnames:
  1102. room.message("I'm not there.")
  1103. return
  1104. users = getParticipant(str(args))
  1105. if len(users) > 40:
  1106. 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)
  1107. if len(users) <=40:
  1108. room.message("Current <b>%s</b> users in <b>%s</b>: %s"% (len(users), args.title(), ", ".join(users)), True)
  1109. ##### bot rooms
  1110. elif cmd == "rooms" :
  1111. j = []
  1112. for i in self.roomnames:
  1113. j.append(i+'[%s]' % str(self.getRoom(i).usercount))
  1114. j.sort()
  1115. room.message("aku bermain Di "+'[%s] rooms: '%(len(self.roomnames))+", ".join(j))
  1116. ## Mods
  1117. elif cmd == "mods":
  1118. args = args.lower()
  1119. if args == "":
  1120. 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)
  1121. return
  1122. if args in self.roomnames:
  1123. modask = self.getRoom(args).modnames
  1124. owner = self.getRoom(args).ownername
  1125. room.message("<font color='#ffffff'><b>Room</b>: "+args+" <br/><b>Owner</b>: <u>"+ (owner) +"</u> <br/><b>Mods</b>: "+", ".join(modask), True)
  1126.  
  1127.  
  1128. ####nick
  1129. elif cmd == "nick":
  1130. ## if user.name in reg or user.name in friends or user.name in trusted or user.name in owners:
  1131. if args:
  1132. nick = args
  1133. user = user.name
  1134. nicks[user] = json.dumps(nick)
  1135. room.message(user +' sip sekarang kamu tak panggil '+str(args)+'', True)
  1136. try:
  1137. print("[SAVING] NICKS...")
  1138. f = open("nicks.txt", "w")
  1139. for user in nicks:
  1140. nick = json.loads(nicks[user])
  1141. f.write(json.dumps([user,nick]) + "\n")
  1142. except:
  1143. room.message("Gagal membuat Nick baru..");return
  1144. else:
  1145. room.message('Ketik >nick <spasi> nama yang di inginkan', True)
  1146.  
  1147.  
  1148. ##mynick
  1149. elif cmd == "mynick" :
  1150. user=user.name.lower()
  1151. if user in nicks :
  1152. nick = json.loads(nicks[user])
  1153. room.message(user+" is nicked : "+nick,True)
  1154. else:
  1155. room.message("Belum membuat Nick di saya :D ", True)
  1156.  
  1157.  
  1158. except Exception as e:
  1159. try:
  1160. et, ev, tb = sys.exc_info()
  1161. lineno = tb.tb_lineno
  1162. fn = tb.tb_frame.f_code.co_filename
  1163. room.message("[Expectation Failed] %s Line %i - %s"% (fn, lineno, str(e)))
  1164. return
  1165. except:
  1166. room.message("Undescribeable error detected !!")
  1167. return
  1168.  
  1169.  
  1170. ##Other Crap here, Dont worry about it
  1171.  
  1172. def onFloodWarning(self, room):
  1173. room.reconnect()
  1174.  
  1175. def onJoin(self, room, user):
  1176. print(user.name + " joined the chat!")
  1177.  
  1178. def onLeave(self, room, user):
  1179. print(user.name + " left the chat!")
  1180.  
  1181. def onUserCountChange(self, room):
  1182. print("users: " + str(room.usercount))
  1183.  
  1184.  
  1185.  
  1186.  
  1187. if __name__ == "__main__":
  1188. TestBot.easy_start(rooms, botname, password)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement