Advertisement
ReiShi

Untitled

Jun 28th, 2017
1,050
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 48.06 KB | None | 0 0
  1. #################################################################################################################
  2. import ch
  3. import random
  4. import sys
  5. import re
  6. import json
  7. import time
  8. import datetime
  9. import os
  10. import urllib
  11. from xml.etree import cElementTree as ET
  12. if sys.version_info[0] > 2:
  13. import urllib.request as urlreq
  14. else:
  15. import urllib2 as urlreq
  16.  
  17. botname = 'saayabot' ##isi idnya
  18. password = 'reinashiyami123' ##isi paswordnya
  19.  
  20. ##nick names
  21. def sntonick(username):
  22. user = username.lower()
  23. if user in nicks:
  24. nick = json.loads(nicks[user])
  25. return nick
  26. else:
  27. return user
  28.  
  29. #### Returns the number of seconds since the program started.
  30. ################################################################
  31. def getUptime():
  32. # do return start time if you just want the process start time
  33. return time.time() - starttime
  34.  
  35. def reboot():
  36. output = ("rebooting server . . .")
  37. os.popen("sudo -S reboot")
  38. return output
  39.  
  40. #### SYSTEM UPTIME
  41. def uptime():
  42.  
  43. total_seconds = float(getUptime())
  44.  
  45. # Helper vars:
  46. MINUTE = 60
  47. HOUR = MINUTE * 60
  48. DAY = HOUR * 24
  49.  
  50. # Get the days, hours, etc:
  51. days = int( total_seconds / DAY )
  52. hours = int( ( total_seconds % DAY ) / HOUR )
  53. minutes = int( ( total_seconds % HOUR ) / MINUTE )
  54. seconds = int( total_seconds % MINUTE )
  55.  
  56. # Build up the pretty string (like this: "N days, N hours, N minutes, N seconds")
  57. string = ""
  58. if days > 0:
  59. string += str(days) + " " + (days == 1 and "day" or "days" ) + ", "
  60. if len(string) > 0 or hours > 0:
  61. string += str(hours) + " " + (hours == 1 and "hour" or "hours" ) + ", "
  62. if len(string) > 0 or minutes > 0:
  63. string += str(minutes) + " " + (minutes == 1 and "minute" or "minutes" ) + ", "
  64. string += str(seconds) + " " + (seconds == 1 and "second" or "seconds" )
  65.  
  66. return string;
  67.  
  68. ## DEFINITIONS
  69. dictionary = dict()
  70. f = open("definitions.txt", "r")
  71. for line in f.readlines():
  72. try:
  73. if len(line.strip())>0:
  74. word, definition, name = json.loads(line.strip())
  75. dictionary[word] = json.dumps([definition, name])
  76. except:
  77. print("[ERROR]Cant load definition: %s" % line)
  78. f.close()
  79. ##nicks
  80. nicks=dict()#empty list
  81. f=open ("nicks.txt","r")#r=read w=right
  82. for line in f.readlines():#loop through eachlinimporte and read each line
  83. try:#try code
  84. if len(line.strip())>0:#strip the whitespace checkgreater than 0
  85. user , nick = json.loads(line.strip())
  86. nicks[user] = json.dumps(nick)
  87. except:
  88. print("[Error]Can't load nick %s" % line)
  89. f.close()
  90. ##Rooms
  91. rooms = []
  92. f = open("rooms.txt", "r") # read-only
  93. for name in f.readlines():
  94. if len(name.strip())>0: rooms.append(name.strip())
  95. f.close()
  96. ##owners
  97. owners = []
  98. try:
  99. file = open("owners.txt", "r")
  100. for name in file.readlines():
  101. if len(name.strip()) > 0:
  102. owners.append(name.strip())
  103. print("[INFO]Owners loaded...")
  104. file.close()
  105. except:
  106. print("[ERROR]no file named owners")
  107. print("2 second to read the error")
  108. time.sleep(2)
  109. exit()
  110. time.sleep(1)
  111.  
  112. ###admin
  113. admin = []
  114. try:
  115. file = open("admin.txt", "r")
  116. for name in file.readlines():
  117. if len(name.strip()) > 0:
  118. admin.append(name.strip())
  119. print("[INFO]Admin loaded...")
  120. file.close()
  121. except:
  122. print("[ERROR]no file named admin")
  123. print("2 second to read the error")
  124. time.sleep(2)
  125. exit()
  126. time.sleep(1)
  127.  
  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 1 # 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 "Saaya" or "aya" or "Aya" or "saya" or "saaya" or "Saya" == message.body:
  328. if self.getAccess(user) >= 1 or room.getLevel(user) > 0 and not user.name in blacklist:
  329. room.message (random.choice(["Ada yang bisa Saaya bantu "+sntonick(user.name)+ " ?? "]),True)
  330. if "malam" or "Malam" or "selamat malam" or "malem" or "konbanwa" == message.body:
  331. if self.getAccess(user) >= 1 or room.getLevel(user) > 0 and not user.name in blacklist:
  332. room.message("Malam juga "+sntonick(user.name)+ " :D ")
  333. if "pagi" or "selamat pagi" or "ohayou" or "guten morgen" or "met pagi" == message.body:
  334. if self.getAccess(user) >= 1 or room.getLevel(user) > 0 and not user.name in blacklist:
  335. room.message("Pagi juga "+sntonick(user.name)+ " *waves* ")
  336. if "siang" == message.body:
  337. if self.getAccess(user) >= 1 or room.getLevel(user) > 0 and not user.name in blacklist:
  338. room.message("Siang Juga "+sntonick(user.name)+ " :) "),True
  339. if "sore" == message.body:
  340. if self.getAccess(user) >= 1 or room.getLevel(user) > 0 and not user.name in blacklist:
  341. room.message("Sore Juga "+sntonick(user.name)+ " ;) ")
  342. if "afk" in message.body:
  343. if self.getAccess(user) >= 1 or room.getLevel(user) > 0 and not user.name in blacklist:
  344. room.message (random.choice(["See ya "+sntonick(user.name)+" :) ",]),True)
  345. if "bye" or "bye bye" or "bay" == message.body:
  346. if self.getAccess(user) >= 1 or room.getLevel(user) > 0 and not user.name in blacklist:
  347. room.message (random.choice(["Bye bye "+sntonick(user.name)+" *waves* ",]),True)
  348. if "off" in message.body:
  349. if self.getAccess(user) >= 1 or room.getLevel(user) > 0 and not user.name in blacklist:
  350. room.message (random.choice(["Njaa ne "+sntonick(user.name)+" :) ",]),True)(random.choice(["Sampai jumpa besok"+sntonick(user.name)+" *waves* ",]),True)
  351. if "test" in message.body:
  352. if self.getAccess(user) >= 1 or room.getLevel(user) > 0 and not user.name in blacklist:
  353. room.message (random.choice(["Succes :) "+sntonick(user.name)+" :) ",]),True)
  354. if "mnas" in message.body:
  355. if self.getAccess(user) >= 1 or room.getLevel(user) > 0 and not user.name in blacklist:
  356. room.message (random.choice(["Yes *waves* "+sntonick(user.name)+" :) ",]),True)
  357. if "brb" in message.body:
  358. if self.getAccess(user) >= 1 or room.getLevel(user) > 0 and not user.name in blacklist:
  359. room.message (random.choice(["Bye "+sntonick(user.name)+" :) ",]),True)
  360. if message.body == "": return
  361. if message.body[0] in ["}"]:
  362. data = message.body[1:].split(" ", 1)
  363. if len(data) > 1:
  364. cmd, args = data[0], data[1]
  365. else:
  366. cmd, args = data[0], ""
  367.  
  368.  
  369.  
  370. ##check access and ignore
  371. if self.getAccess(user) == 0: return
  372. def pars(args):
  373. args=args.lower()
  374. for name in room.usernames:
  375. if args in name:return name
  376. def roompars(args):
  377. args = args.lower()
  378. for name in self.roomnames:
  379. if args in name:return name
  380. def roomUsers():
  381. usrs = []
  382. gay = []
  383. prop = 0
  384. prop = prop + len(room._userlist) - 1
  385. for i in room._userlist:
  386. i = str(i)
  387. usrs.append(i)
  388. while prop >= 0:
  389. j = usrs[prop].replace("<User: ", "")
  390. i = j.replace(">", "")
  391. gay.append(i)
  392. prop = prop - 1
  393. return gay
  394.  
  395. def getParticipant(arg):
  396. rname = self.getRoom(arg)
  397. usrs = []
  398. gay = []
  399. finale = []
  400. prop = 0
  401. prop = prop + len(rname._userlist) - 1
  402. for i in rname._userlist:
  403. i = str(i)
  404. usrs.append(i)
  405. while prop >= 0:
  406. j = usrs[prop].replace("<User: ", "")
  407. i = j.replace(">", "")
  408. gay.append(i)
  409. prop = prop - 1
  410. for j in gay:
  411. if j not in finale:
  412. finale.append(j)
  413. return finale
  414.  
  415. #Find
  416. if cmd == "find" and len(args) > 0:
  417. name = args.split()[0].lower()
  418. if not ch.User(name).roomnames:
  419. room.message("GPS user telah dimatikan, tidak dapat ditemukan ;(")
  420. else:
  421. room.message("kamu dapat menemukan %s Di %s" % (args, ", ".join(ch.User(name).roomnames)),True)
  422.  
  423. ##cmds
  424. if cmd == "cmds":
  425. if user.name in owners and not user.name in admin and not user.name in archknight and not user.name in whitelist:
  426. 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)
  427. if user.name in admin and not user.name in owners and not user.name in archknight and not user.name in whitelist:
  428. 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)
  429. if user.name in archknight and not user.name in owners and not user.name in admin and not user.name in whitelist:
  430. 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)
  431. if user.name in whitelist and not user.name in owners and not user.name in admin and not user.name in archknight:
  432. 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)
  433.  
  434. ##testcmd
  435. if cmd == "webanime":
  436. 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)
  437. if cmd == "opnew": room.message(newOp(), True)
  438. if cmd == "newbat":
  439. sss = args
  440. data = urlreq.Request("http://ruangotaku.com/?s=", headers = {'User-Agent': 'Mozilla/5.0'})
  441. asu = urlreq.urlopen(data)
  442. udict = asu.read().decode('utf-8')
  443. data = re.findall('<h2><a href="(.*?)">(.*?)</a>', udict)
  444. newset = list()
  445. num = 1
  446. for link, title in data:
  447. newset.append(("(%s) <b>%s</b> - %s") % (num, title, link))
  448. num = num+1
  449. room.message("<br/>New episode on batchid.net:<br/>"+"<br/>".join(newset[0:5]),True)
  450.  
  451.  
  452. ##Setnick
  453. if cmd == "setnick":
  454. if self.getAccess(user) < 4:return
  455. try:
  456. if args:
  457. user, nick = args.split(" ",1)
  458. nicks[user]=json.dumps(nick)
  459. room.message("Sukses")
  460. f = open("nicks.txt","w")
  461. for user in nicks:
  462. nick = json.loads(nicks[user])
  463. f.write(json.dumps([user,nick])+"\n")
  464. f.close()
  465. else:
  466. room.message("Who?")
  467. except:
  468. room.message("The nick please")
  469.  
  470.  
  471. ##Setrank
  472. if cmd == "setrank":
  473. if self.getAccess(user) < 4:return
  474. try:
  475. if len(args) >= 3:
  476. name = args
  477. if pars(name) == None:
  478. name = name
  479. elif pars(name) != None:
  480. name = pars(name)
  481. name, rank = args.lower().split(" ", 1)
  482. if rank == "4":
  483. owners.append(name)
  484. f = open("owners.txt", "w")
  485. f.write("\n".join(owners))
  486. f.close()
  487. room.message("Sukses")
  488. if name in admin:
  489. admin.remove(name)
  490. f = open("admin.txt", "w")
  491. f.write("\n".join(admin))
  492. f.close()
  493. if name in archknight:
  494. archknight.remove(name)
  495. f = open("archknight.txt", "w")
  496. f.write("\n".join(archknight))
  497. f.close()
  498. if name in whitelist:
  499. whitelist.remove(name)
  500. f = open("whitelist.txt", "w")
  501. f.write("\n".join(whitelist))
  502. f.close()
  503. if rank == "3":
  504. admin.append(name)
  505. f = open("admin.txt", "w")
  506. f.write("\n".join(admin))
  507. f.close()
  508. room.message("Sukses")
  509. if name in owners:
  510. owners.remove(name)
  511. f = open("owners.txt", "w")
  512. f.write("\n".join(owners))
  513. f.close()
  514. if name in archknight:
  515. archknight.remove(name)
  516. f = open("archknight.txt", "w")
  517. f.write("\n".join(archknight))
  518. f.close()
  519. if name in whitelist:
  520. whitelist.remove(name)
  521. f = open("whitelist.txt", "w")
  522. f.write("\n".join(whitelist))
  523. f.close()
  524. if rank == "2":
  525. archknight.append(name)
  526. f = open("archknight.txt", "w")
  527. f.write("\n".join(archknight))
  528. f.close()
  529. room.message("Sukses")
  530. if name in owners:
  531. owners.remove(name)
  532. f = open("owners.txt", "w")
  533. f.write("\n".join(owners))
  534. f.close()
  535. if name in admin:
  536. admin.remove(name)
  537. f = open("admin.txt", "w")
  538. f.write("\n".join(admin))
  539. f.close()
  540. if name in whitelist:
  541. whitelist.remove(name)
  542. f = open("whitelist.txt", "w")
  543. f.write("\n".join(whitelist))
  544. f.close()
  545. if rank == "1":
  546. whitelist.append(name)
  547. f = open("whitelist.txt", "w")
  548. f.write("\n".join(whitelist))
  549. f.close()
  550. room.message("Sukses")
  551. if name in owners:
  552. owners.remove(name)
  553. f = open("owners.txt", "w")
  554. f.write("\n".join(owners))
  555. f.close()
  556. if name in admin:
  557. admin.remove(name)
  558. f = open("admin.txt", "w")
  559. f.write("\n".join(admin))
  560. f.close()
  561. if name in archknight:
  562. archknight.remove(name)
  563. f = open("archknight.txt", "w")
  564. f.write("\n".join(archknight))
  565. f.close()
  566.  
  567. except:
  568. room.message("something wrong")
  569.  
  570. # clear
  571. elif cmd == "clear":
  572. if room.getLevel(self.user) > 0:
  573. if self.getAccess(user) >= 4 or room.getLevel(user) == 2:
  574. room.clearall(),
  575. room.clearUser(ch.User(random.choice(room.usernames))),
  576. room.clearUser(ch.User(random.choice(room.usernames))),
  577. room.clearUser(ch.User(random.choice(room.usernames))),
  578. room.clearUser(ch.User(random.choice(room.usernames))),
  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. else: room.message("Only rank 4+ or the room owner can do this")
  611. else:
  612. room.message("aku bukan mods disini :|")
  613. ##delete chat
  614. elif (cmd == "delete" or cmd == "dl" or cmd == "del"):
  615. if room.getLevel(self.user) > 0:
  616. if self.getAccess(user) >= 1 or room.getLevel(user) > 0:
  617. name = args.split()[0].lower()
  618. room.clearUser(ch.User(name))
  619. else:room.message("kamu tidak bisa melakukannya!!")
  620. else:
  621. room.message("aku bukan mods disini :|")
  622.  
  623. ##fax
  624. if cmd == "fax":
  625. if self.getAccess(user) >= 1:
  626. if len(args) > 1:
  627. try:
  628. target, body = args.split(" ", 1)
  629. if user.name in room.modnames or user.name in room.ownername or self.getAccess(user) > 2:
  630. if target in self.roomnames:
  631. if room.name == "dai-tenshi":
  632. 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)
  633. room.message("[<b>%s</b>] Fax Sent" % "INF", True)
  634. else:
  635. 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)
  636. room.message("[<b>%s</b>] Fax Sent" % "INF", True)
  637. else:
  638. room.message("[<b>%s</b>] There's no Fax Service in <font color='#ff0000'><b>%s</b></font> :|" % ("ERROR", target), True)
  639. else:
  640. room.message("You mere mortals can never do that !!")
  641. self.setTimeout(int(3), room.message, "*Aims Colt. Python Revolver at <b>%s</b> and shot him dead*" % user.name, True)
  642. except:
  643. room.message("Gagal !!")
  644.  
  645.  
  646.  
  647. ##Ranker
  648. if cmd == "ranker":
  649. 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)
  650. ##staff
  651. if cmd == "staff":
  652. 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)
  653.  
  654. ##Accesbot
  655. if cmd == "accesbot":
  656. room.message(("DownloadScript(DLS) , UpRankBot(URB)"),True)
  657.  
  658. ##Download
  659. if cmd == "dls":
  660. room.message(("Maaf Anda Tidak Memiliki Hak Owner, Sign Up Now!!"),True)
  661.  
  662. ##UpRank
  663. if cmd == "urb":
  664. room.message(("Rank Berhasil Di up, gunakan perintah setrank (user) (rank)"),True)
  665.  
  666. ##GS
  667. if cmd == "gs":
  668. room.message(gs(args),True)
  669.  
  670. if cmd == "pic":
  671. link = "http://fp.chatango.com/profileimg/%s/%s/%s/full.jpg" % (args[0], args[1], args)
  672. room.message("<br/>"+"User ID : "+args+""+"<br/>Profile Picture :<br/>"+link,True)
  673. ##Eval
  674. if cmd == "ev" or cmd == "eval" or cmd == "e":
  675. if self.getAccess(user) == 4:
  676. ret = eval(args)
  677. if ret == None:
  678. room.message("Done.")
  679. return
  680. room.message(str(ret))
  681.  
  682. ##Say
  683. if cmd == "say":
  684. room.message(args)
  685.  
  686. ##Random User
  687. if cmd == "randomuser":
  688. room.message(random.choice(room.usernames))
  689.  
  690.  
  691.  
  692.  
  693. ##Check if Mod
  694. #not really important
  695. elif cmd == "ismod":
  696. user = ch.User(args)
  697. if room.getLevel(user) > 0:
  698. room.message("yesh")
  699. else:
  700. room.message("nope")
  701.  
  702. ## Youtube
  703. elif cmd == "youtube" or cmd == "yt":
  704. if args:
  705. room.message(tube(args),True)
  706.  
  707. ## Broadcast
  708. elif cmd=="bc" and self.getAccess(user) > 1:
  709. r = room.name
  710. l = "http://ch.besaba.com/mty.htm?"+r+"+"
  711. for room in self.rooms:
  712. room.message("[<font color='#6699CC'><b>Broadcast</b></font>] from - "+sntonick(user.name)+ " : <font color='#33FF33'><i>"+args+"<i></font>", True)
  713. ###### Define
  714. elif cmd == "define" or cmd == "df" and len(args) > 0:
  715. try:
  716. try:
  717. word, definition = args.split(" as ",1)
  718. word = word.lower()
  719. except:
  720. word = args
  721. definition = ""
  722. if len(word.split()) > 4:
  723. room.message("Fail")
  724. return
  725. elif len(definition) > 0:
  726. if word in dictionary:
  727. room.message("%s defined already" % user.name.capitalize())
  728. else:
  729. dictionary[word] = json.dumps([definition, user.name])
  730. f =open("definitions.txt", "w")
  731. for word in dictionary:
  732. definition, name = json.loads(dictionary[word])
  733. f.write(json.dumps([word, definition, name])+"\n")
  734. f.close
  735. room.message("Definition Saved")
  736. else:
  737. if word in dictionary:
  738. definition, name = json.loads(dictionary[word])
  739. room.message("<br/>ID : %s<br/>Keyword : %s<br/>Definition:<br/>%s" % (name, word, definition),True)
  740. else:
  741. room.message(args+" is not defined")
  742. except:
  743. room.message("something wrong")
  744.  
  745. elif cmd == "rank":
  746. if not args:
  747. if user.name in owners and not user.name in whitelist:
  748. room.message(user.name+" Kamu Rank 4 [Owner] ",True)
  749. elif user.name in admin and not user.name in whitelist and not user.name in archknight and not user.name in owner:
  750. room.message(user.name+" Kamu Rank 3 [Admin] ",True)
  751. elif user.name in archknight and not user.name in whitelist and not user.name in owners and not user.name in admin:
  752. room.message(user.name+" Kamu Rank 2 [Arckhnight]",True)
  753. elif user.name in whitelist and not user.name in owners:
  754. room.message(user.name+" Kamu Rank 1 [Whitelist]",True)
  755. 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:
  756. room.message(user.name+" Kamu Belum terdaftar",True)
  757. if args:
  758. sss = args
  759. if sss in owners:
  760. room.message(sss.title()+" Rank Dia 4 [Owner] ",True)
  761. if sss in admin:
  762. room.message(sss.title()+" Rank Dia 3 [Admin] ",True)
  763. if sss in archknight:
  764. room.message(sss.title()+" Rank Dia 2 [Arckhnight] ",True)
  765. if sss in whitelist:
  766. room.message(sss.title()+" rank Dia 1 [Whitelist] ",True)
  767. if sss not in owners and sss not in admin and sss not in archknight and sss not in whitelist:
  768. room.message(sss.title()+" Tidak ada rank :) ")
  769.  
  770.  
  771. ##### Whitelist
  772. elif cmd == "wl" and self.getAccess(user) >= 1:
  773. name = args
  774. 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:
  775. room.message("Sukses")
  776. whitelist.append(name)
  777. f = open("whitelist.txt","w")
  778. f.write("\n".join(whitelist))
  779. f.close
  780. else:
  781. room.message("User tersebut sudah terdaftar")
  782.  
  783. ###blacklist
  784. elif cmd == "bl" and self.getAccess(user) >= 3:
  785. name = args
  786. if name not in whitelist and name not in owners and name not in admin and name not in archknight:
  787. room.message("Done")
  788. blacklist.append(name)
  789. f = open("blacklist.txt","w")
  790. f.write("\n".join(blacklist))
  791. f.close
  792. else:
  793. room.message("User tersebut sudah di blacklist")
  794.  
  795. ##ubl
  796. if cmd == "ubl" and self.getAccess(user) >= 3:
  797. try:
  798. if args in blacklist:
  799. blacklist.remove(args)
  800. f = open("blacklist.txt","w")
  801. f.write("\n".join(blacklist))
  802. f.close()
  803. room.message("Sukses")
  804. except:
  805. room.message("Gagal")
  806.  
  807. ##uwl
  808. if cmd == "uwl" and self.getAccess(user) >= 3:
  809. try:
  810. if args in owners:
  811. owners.remove(args)
  812. f = open("owners.txt","w")
  813. f.write("\n".join(owners))
  814. f.close()
  815. room.message("Sukses")
  816. if args in admin:
  817. admin.remove(args)
  818. f = open("admin.txt","w")
  819. f.write("\n".join(admin))
  820. f.close()
  821. room.message("Sukses")
  822. if args in archknight:
  823. archknight.remove(args)
  824. f = open("archknight.txt","w")
  825. f.write("\n".join(archknight))
  826. f.close()
  827. room.message("Sukses")
  828. if args in whitelist:
  829. whitelist.remove(args)
  830. f = open("whitelist.txt","w")
  831. f.write("\n".join(whitelist))
  832. f.close()
  833. room.message("Sukses")
  834. except:
  835. room.message("Gagal")
  836.  
  837. if cmd== "sbg":
  838. if self.getAccess(user) >= 3:
  839. if len(args) > 0:
  840. if args == "on":
  841. room.setBgMode(1)
  842. room.message("Background On")
  843. return
  844. if args == "off":
  845. room.setBgMode(0)
  846. room.message("Background Off")
  847. elif cmd == "mydict":
  848. arr = []
  849. for i in dictionary:
  850. if user.name in dictionary[i]:
  851. arr.append(i)
  852. if len(arr) > 0:
  853. room.message("You have defined <b>"+str(len(arr))+"</b> words in your dictionary :<i> %s"% (', '.join(sorted(arr))), True)
  854. else:
  855. room.message("kamu tidak memiliki dictionary.")
  856.  
  857.  
  858.  
  859. if cmd == "udf" and len(args) > 0:
  860. try:
  861. word = args
  862. if word in dictionary:
  863. definition, name = json.loads(dictionary[word])
  864. if name == user.name or self.getAccess(user) >= 3:
  865. del dictionary[word]
  866. f =open("definitions.txt", "w")
  867. for word in dictionary:
  868. definition, name = json.loads(dictionary[word])
  869. f.write(json.dumps([word, definition, name])+"\n")
  870. f.close
  871. room.message(args+" has been removed from Definition database")
  872. return
  873. else:
  874. 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)
  875. return
  876. else:
  877. room.message("<b>%s</b> is not yet defined you can define it by typing <b>define %s: meaning</b>" % args, True)
  878. except:
  879. room.message("Gagal")
  880. return
  881.  
  882. elif cmd == "sdf" or cmd == "seedict":
  883. if not args:
  884. room.message("Whose dict do you want to see ?")
  885. return
  886. args = args.lower()
  887. if pars(args) == None:
  888. args = args.lower()
  889. if pars(args) != None:
  890. args = pars(args)
  891. arr = []
  892. for i in dictionary:
  893. if args in dictionary[i]:
  894. arr.append(i)
  895. if len(arr) > 0:
  896. room.message("<b>"+args.title()+"</b> have defined <b>"+str(len(arr))+"</b> words in his dictionary :<i> %s"% (', '.join(sorted(arr))), True)
  897. else:
  898. room.message(args.title()+" defined nothing.")
  899.  
  900. if cmd == "seenick":
  901. try:
  902. if args in nicks:
  903. room.message(args+" Nick Dia : "+sntonick(args)+"", True)
  904. else:
  905. room.message(args+" Belum membuat nick di aku :|")
  906. except:
  907. return
  908.  
  909. elif cmd=="prof" or cmd == "profile":
  910. try:
  911. args=args.lower()
  912. stuff=str(urlreq.urlopen("http://"+args+".chatango.com").read().decode("utf-8"))
  913. crap, age = stuff.split('<span class="profile_text"><strong>Age:</strong></span></td><td><span class="profile_text">', 1)
  914. age, crap = age.split('<br /></span>', 1)
  915. crap, gender = stuff.split('<span class="profile_text"><strong>Gender:</strong></span></td><td><span class="profile_text">', 1)
  916. gender, crap = gender.split(' <br /></span>', 1)
  917. if gender == 'M':
  918. gender = 'Male'
  919. elif gender == 'F':
  920. gender = 'Female'
  921. else:
  922. gender = '?'
  923. crap, location = stuff.split('<span class="profile_text"><strong>Location:</strong></span></td><td><span class="profile_text">', 1)
  924. location, crap = location.split(' <br /></span>', 1)
  925. crap,mini=stuff.split("<span class=\"profile_text\"><!-- google_ad_section_start -->",1)
  926. mini,crap=mini.split("<!-- google_ad_section_end --></span>",1)
  927. mini=mini.replace("<img","<!")
  928. 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>'
  929. 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
  930. room.message(prodata,True)
  931. except:
  932. room.message(""+args+" doesn't exist o.o ")
  933. elif cmd=="mini":
  934. try:
  935. args=args.lower()
  936. stuff=str(urlreq.urlopen("http://"+args+".chatango.com").read().decode("utf-8"))
  937. crap,mini=stuff.split("<span class=\"profile_text\"><!-- google_ad_section_start -->",1)
  938. mini,crap=mini.split("<!-- google_ad_section_end --></span>",1)
  939. mini=mini.replace("<img","<!")
  940. prodata = '<br/>'+mini
  941. room.message(prodata,True)
  942. except:
  943. room.message(""+args+" doesn't exist o.o ")
  944.  
  945. if cmd == "bgimg":
  946. try:
  947. args=args.lower()
  948. 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>'
  949. prodata = '<br/>'+picture
  950. room.message("<br/>"+"User ID : "+args+"<br/>Background :"+prodata,True)
  951. except:
  952. room.message(""+args+" doesn't exist:'v")
  953.  
  954.  
  955.  
  956.  
  957. ### Private Messages
  958. elif cmd=="pm":
  959. data = args.split(" ", 1)
  960. if len(data) > 1:
  961. name , args = data[0], data[1]
  962. self.pm.message(ch.User(name), "[Private.Message] By - "+user.name+" : "+args+" ")
  963. room.message("Sent to "+name+"")
  964. ### Sentnote
  965. elif cmd == "inbox":
  966. if user.name in sn:
  967. mesg = len(sn[user.name])
  968. room.message("["+str(mesg)+"] messages in your inbox. To read it, do irn")
  969. else:
  970. sn.update({user.name:[]})
  971. mesg = len(sn[user.name])
  972. room.message("["+str(mesg)+"] messages in your inbox. To read it, do irn")
  973.  
  974. #send notes
  975. elif cmd == "sn" or cmd == "sendnote":
  976. args.lower()
  977. untuk, pesan = args.split(" ", 1)
  978. if untuk[0] == "+":
  979. untuk = untuk[1:]
  980. else:
  981. if pars(untuk) == None:
  982. room.message("Who is "+untuk+" ??")
  983. return
  984. untuk = pars(untuk)
  985. if untuk in sn:
  986. sn[untuk].append([user.name, pesan, time.time()])
  987. if untuk not in notif:
  988. notif.append(untuk)
  989. else:pass
  990. else:
  991. sn.update({untuk:[]})
  992. sn[untuk].append([user.name, pesan, time.time()])
  993. if untuk not in notif:
  994. notif.append(untuk)
  995. else:pass
  996. room.message('Sent to %s'% (untuk)+"'s inbox" , True)
  997.  
  998.  
  999.  
  1000. #Read Notes
  1001. elif cmd =="rn" or cmd =="readnote":
  1002. if user.name not in sn:
  1003. sn.update({user.name:[]})
  1004. user=user.name.lower()
  1005. if len(sn[user]) > 0:
  1006. messg = sn[user][0]
  1007. dari, pesen, timey = messg
  1008. timey = time.time() - int(timey)
  1009. minute = 60
  1010. hour = minute * 60
  1011. day = hour * 24
  1012. days = int(timey / day)
  1013. hours = int((timey % day) / hour)
  1014. minutes = int((timey % hour) / minute)
  1015. seconds = int(timey % minute)
  1016. string = ""
  1017. if days > 0:
  1018. string += str(days) + " " + (days == 1 and "day" or "days" ) + ", "
  1019. if len(string) > 0 or hours > 0:
  1020. string += str(hours) + " " + (hours == 1 and "hour" or "hours" ) + ", "
  1021. if len(string) > 0 or minutes > 0:
  1022. string += str(minutes) + " " + (minutes == 1 and "minute" or "minutes" ) + ", "
  1023. string += str(seconds) + " " + (seconds == 1 and "second" or "seconds" )
  1024. room.message("[<font color='#6699CC'><b>Private Message</b></font>] from - "+sntonick(dari)+" : "+pesen+" (<font color='#9999FF'>"+string+" ago </font>)", True)
  1025. try:
  1026. del sn[user][0]
  1027. notif.remove(user)
  1028. except:pass
  1029. else:room.message('%s'%(user)+" you don't have any messages in your inbox" , True)
  1030. ###### leave + room
  1031. elif cmd == "leave" and self.getAccess(user) >=1:
  1032. if not args:args=room.name
  1033. self.leaveRoom(args)
  1034. room.message("Kasus Selesai aku out TKP "+args+" ...")
  1035. print("[SAVE] SAVING Rooms...")
  1036. f = open("rooms.txt", "w")
  1037. f.write("\n".join(self.roomnames))
  1038. f.close()
  1039.  
  1040. ###### join room + roomname
  1041.  
  1042. if cmd == "join" and len(args) > 1:
  1043. if self.getAccess (user) >= 1:
  1044. if args not in self.roomnames:
  1045. room.message("Segera Meluncur ;) "+args+" ...")
  1046. self.joinRoom(args)
  1047. else:
  1048. room.message("Sudah Berada di TKP ;) ...")
  1049. print("[SAVE] SAVING Rooms...")
  1050. f = open("rooms.txt", "w")
  1051. f.write("\n".join(self.roomnames))
  1052. f.close()
  1053. elif cmd == "userlist":
  1054. if args == "":
  1055. usrs = []
  1056. gay = []
  1057. finale = []
  1058. prop = 0
  1059. prop = prop + len(room._userlist) - 1
  1060. for i in room._userlist:
  1061. i = str(i)
  1062. usrs.append(i)
  1063. while prop >= 0:
  1064. j = usrs[prop].replace("<User: ", "")
  1065. i = j.replace(">", "")
  1066. gay.append(i)
  1067. prop = prop - 1
  1068. for i in gay:
  1069. if i not in finale:
  1070. finale.append(i)
  1071. if len(finale) > 40:
  1072. room.message("<font color='#9999FF'><b>40</b></font> of <b>%s</b> users in this room: %s"% (len(finale), ", ".join(finale[:41])), True)
  1073. if len(finale) <=40 :
  1074. room.message("Current <b>%s</b> users of this room: %s"% (len(finale),", ".join(finale)), True)
  1075. if args != "":
  1076. if args not in self.roomnames:
  1077. room.message("I'm not there.")
  1078. return
  1079. users = getParticipant(str(args))
  1080. if len(users) > 40:
  1081. 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)
  1082. if len(users) <=40:
  1083. room.message("Current <b>%s</b> users in <b>%s</b>: %s"% (len(users), args.title(), ", ".join(users)), True)
  1084. ##### bot rooms
  1085. elif cmd == "rooms" :
  1086. j = []
  1087. for i in self.roomnames:
  1088. j.append(i+'[%s]' % str(self.getRoom(i).usercount))
  1089. j.sort()
  1090. room.message("aku bermain Di "+'[%s] rooms: '%(len(self.roomnames))+", ".join(j))
  1091. ## Mods
  1092. elif cmd == "mods":
  1093. args = args.lower()
  1094. if args == "":
  1095. 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)
  1096. return
  1097. if args in self.roomnames:
  1098. modask = self.getRoom(args).modnames
  1099. owner = self.getRoom(args).ownername
  1100. room.message("<font color='#ffffff'><b>Room</b>: "+args+" <br/><b>Owner</b>: <u>"+ (owner) +"</u> <br/><b>Mods</b>: "+", ".join(modask), True)
  1101.  
  1102.  
  1103. ####nick
  1104. elif cmd == "nick":
  1105. ## if user.name in reg or user.name in friends or user.name in trusted or user.name in owners:
  1106. if args:
  1107. nick = args
  1108. user = user.name
  1109. nicks[user] = json.dumps(nick)
  1110. room.message(user +' sip sekarang kamu tak panggil '+str(args)+'', True)
  1111. try:
  1112. print("[SAVING] NICKS...")
  1113. f = open("nicks.txt", "w")
  1114. for user in nicks:
  1115. nick = json.loads(nicks[user])
  1116. f.write(json.dumps([user,nick]) + "\n")
  1117. except:
  1118. room.message("Gagal membuat Nick baru..");return
  1119. else:
  1120. room.message('Ketik >nick <spasi> nama yang di inginkan', True)
  1121.  
  1122.  
  1123. ##mynick
  1124. elif cmd == "mynick" :
  1125. user=user.name.lower()
  1126. if user in nicks :
  1127. nick = json.loads(nicks[user])
  1128. room.message(user+" is nicked : "+nick,True)
  1129. else:
  1130. room.message("Belum membuat Nick di saya :D ", True)
  1131.  
  1132. ##save
  1133. elif cmd == "save":
  1134. if self.getAccess(user) >= 2:
  1135. print("[SAVE] Saving Notes..")
  1136. f = open("owner.txt", "w")
  1137. for to in sasaran:
  1138. body, sender = json.loads(sasaran[to])
  1139. f.write(json.dumps([to, body, sender])+"\n")
  1140. f.close()
  1141. f = open("nicks.txt", "w")
  1142. f.write("\n".join(nicks))
  1143. f.close()
  1144. print("[SV] Saving Whitelist..")
  1145. f = open("whitelist.txt", "w")
  1146. f.write("\n".join(whitelist))
  1147. f.close()
  1148. print("[SV] Saving Rooms..")
  1149. f = open("rooms.txt", "w")
  1150. f.write("\n".join(self.roomnames))
  1151. f.close()
  1152. f = open("archknight.txt","w")
  1153. f.write('\n'.join(archknight))
  1154. f.close()
  1155. saveRank()
  1156. f = open("admin.txt","w")
  1157. f.write('\n'.join(admin))
  1158. f.close()
  1159. room.message("Save Success..")
  1160. else:
  1161. room.message("wish i could :|")
  1162.  
  1163.  
  1164. except Exception as e:
  1165. try:
  1166. et, ev, tb = sys.exc_info()
  1167. lineno = tb.tb_lineno
  1168. fn = tb.tb_frame.f_code.co_filename
  1169. room.message("[Expectation Failed] %s Line %i - %s"% (fn, lineno, str(e)))
  1170. return
  1171. except:
  1172. room.message("Undescribeable error detected !!")
  1173. return
  1174.  
  1175.  
  1176. ##Other Crap here, Dont worry about it
  1177.  
  1178. def onFloodWarning(self, room):
  1179. room.reconnect()
  1180.  
  1181. def onJoin(self, room, user):
  1182. print(user.name + " joined the chat!")
  1183.  
  1184. def onLeave(self, room, user):
  1185. print(user.name + " left the chat!")
  1186.  
  1187. def onUserCountChange(self, room):
  1188. print("users: " + str(room.usercount))
  1189.  
  1190.  
  1191.  
  1192.  
  1193. if __name__ == "__main__":
  1194. TestBot.easy_start(rooms, botname, password)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement