Advertisement
Guest User

Bot.py

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