Advertisement
Guest User

Untitled

a guest
Aug 31st, 2016
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 40.57 KB | None | 0 0
  1. #imports
  2. import ch
  3. import random
  4. import sys
  5. import os
  6. import cgi
  7. import traceback
  8. import time
  9. import urllib
  10. import datetime
  11. import binascii
  12. import json
  13. import re
  14. import requests
  15. from threading import Timer
  16. from threading import Thread
  17. from xml.etree import cElementTree as ET
  18.  
  19. ##YouTube Imports
  20.  
  21. #end imports
  22.  
  23. ##Python Version Info and urllib
  24. if sys.version_info[0] > 2:
  25. import urllib.request as urlreq
  26. else:
  27. import urllib2 as urlreq
  28.  
  29.  
  30. #######################
  31. ##Variables
  32. #######################
  33.  
  34. awake = True
  35. sleep = False
  36.  
  37. username = "username"
  38. password = "password"
  39.  
  40. prefix = "="
  41.  
  42. API_KEY = "AIzaSyBd2bbayXdgpErV86nGZ8KBXVxD5UzORtY"
  43.  
  44. #######################
  45. ##Loading Files
  46. #######################
  47.  
  48.  
  49. #NICKNAMES#
  50. nicks = dict()
  51. f = open("nicks.txt","r")
  52. print("[INFO] Loading Nicks...")
  53. time.sleep(1)
  54. for line in f.readlines():
  55. try:
  56. if len(line.strip())>0:
  57. user, nick = json.loads(line.strip())
  58. nicks[user] = json.dumps(nick)
  59. except:
  60. print("[ERROR] Can't load nick %s" % line)
  61. f.close()
  62.  
  63.  
  64. #DEFINITIONS#
  65. ##dictionary = dict() #volatile... of course...
  66. ##f = open("definitions.txt", "r") # read-only
  67. ##print("[INFO] Loading Definitions...")
  68. ##time.sleep(1)
  69. ##for line in f.readlines():
  70. ## try:
  71. ## if len(line.strip())> 0:
  72. ## word, definition, name = json.loads(line.strip())
  73. ## dictionary[word] = json.dumps([definition, name])
  74. ## except:
  75. ## print("[ERROR] Cant load definition: %s" % line)
  76. ##f.close()
  77. ##
  78. ##time.sleep(1)
  79.  
  80. #BLACKLIST#
  81. blacklist = []
  82. f = open("blacklist.txt", "r") # read-only
  83. print("[INFO] Loading Blacklist...")
  84. time.sleep(1)
  85. for name in f.readlines():
  86. if len(name.strip())>0: blacklist.append(name.strip())
  87. f.close()
  88. # END #
  89.  
  90. #MASTERS#
  91. masters = []
  92. f = open("masters.txt", "r") # read-only
  93. print("[INFO] Loading Masters...")
  94. time.sleep(1)
  95. for name in f.readlines():
  96. if len(name.strip())>0: masters.append(name.strip())
  97. f.close()
  98. # END #
  99.  
  100. #GODS#
  101. gods = []
  102. f = open("gods.txt", "r") # read-only
  103. print("[INFO] Loading Gods...")
  104. time.sleep(1)
  105. for name in f.readlines():
  106. if len(name.strip())>0: gods.append(name.strip())
  107. f.close()
  108. # END #
  109.  
  110. #ADMINS#
  111. admins = []
  112. f = open("admins.txt", "r") # read-only
  113. print("[INFO] Loading Admins...")
  114. time.sleep(1)
  115. for name in f.readlines():
  116. if len(name.strip())>0: admins.append(name.strip())
  117. f.close()
  118. # END #
  119.  
  120. #MODERATORS#
  121. moderators = []
  122. f = open("moderators.txt", "r") # read-only
  123. print("[INFO] Loading Moderators...")
  124. time.sleep(1)
  125. for name in f.readlines():
  126. if len(name.strip())>0: moderators.append(name.strip())
  127. f.close()
  128. #END #
  129.  
  130. #MEMBERS - WHITELISTED#
  131. members = []
  132. f = open("members.txt", "r") # read-only
  133. print("[INFO] Loading Members...")
  134. time.sleep(1)
  135. for name in f.readlines():
  136. if len(name.strip())>0: members.append(name.strip())
  137. f.close()
  138. #END #
  139.  
  140. #ROOMS#
  141. rooms = []
  142. f = open("rooms.txt", "r")
  143. print("[INFO] Loading Rooms....")
  144. for name in f.readlines():
  145. if len(name.strip())>0: rooms.append(name.strip())
  146. f.close()
  147.  
  148.  
  149.  
  150.  
  151. ##If no nick is present use username
  152. def sntonick(username):
  153. user = username.lower()
  154. if user in nicks:
  155. nick = json.loads(nicks[user])
  156. return nick.title()
  157. else:
  158. return user.capitalize()
  159.  
  160.  
  161. ###########################################################
  162. ##Startup
  163.  
  164. class bot(ch.RoomManager):
  165. def onInit(self):
  166. self.setNameColor("000000")
  167. self.setFontColor("000000")
  168. self.setFontFace("Corbel")
  169. self.setFontSize(11)
  170. self.enableBg()
  171. self.enableRecording()
  172.  
  173. def onConnect(self, room):
  174. self.setNameColor("000000")
  175. self.setFontColor("000000")
  176. self.setFontFace("Corbel")
  177. self.setFontSize(9)
  178. self.enableBg()
  179. self.enableRecording()
  180. print("[INFO] Connected to "+room.name)
  181.  
  182. def onReconnect(self, room):
  183. self.setNameColor("000000")
  184. self.setFontColor("000000")
  185. self.setFontFace("Corbel")
  186. self.setFontSize(9)
  187. self.enableBg()
  188. self.enableRecording()
  189. print("[INFO] Reconnected to : "+room.name)
  190. room.message("Reconnected")
  191.  
  192. def onDisconnect(self, room):
  193. self.setNameColor("000000")
  194. self.setFontColor("000000")
  195. self.setFontFace("Corbel")
  196. self.setFontSize(9)
  197. self.enableBg()
  198. self.enableRecording()
  199. print("[INFO] Disconnected from : "+room.name)
  200.  
  201.  
  202. def onFloodWarning(self, room):
  203. print("[INFO] FloodWarning in : "+room.name)
  204. room.reconnect()
  205.  
  206. def onBan(self, room, user, target):
  207. room.message(target.name.title()+" was voted off the island by "+user.name.title())
  208. print("[INFO] "+target.name.title()+" was voted off the island by "+user.name.title()+" in "+room.name.title())
  209.  
  210. def onUnban(self, room, user, target):
  211. room.message(target.name.title()+" has been unbanned by "+user.name.title())
  212. print("[INFO] "+target.name.title()+" was banned by "+user.name.title()+" in "+room.name.title())
  213.  
  214. def onPMMessage(self, pm, user, body):
  215. self.setFontFace("Corbel")
  216. self.setFontSize(12)
  217. self.pm.message(ch.User("Bewb"), "PM From : "+user.name.title()+" : "+body)
  218. self.setFontFace("Corbel")
  219. self.setFontSize(9)
  220.  
  221. def getAccess(self, user):
  222. if user.name in masters: return 5
  223. if user.name in gods: return 4
  224. if user.name in admins: return 3
  225. if user.name in moderators: return 2
  226. if user.name in members: return 1
  227. if user.name in blacklist: return 0
  228. else: return 0
  229.  
  230. def onMessage(self, room, user, message):
  231. global awake
  232. global sleep
  233. msgdata = message.body.split(" ",1)
  234. if len(msgdata) > 1:
  235. cmd, args = msgdata[0], msgdata[1]
  236. else:
  237. cmd, args = msgdata[0],""
  238. cmd=cmd.lower()
  239.  
  240. if len(cmd) >0:
  241. if cmd[0]==prefix:
  242. used_prefix = True
  243. cmd = cmd[1:]
  244. else:
  245. used_prefix = False
  246. else:
  247. return
  248.  
  249. ##########################################################
  250. ##Chatlogs
  251.  
  252.  
  253. #Write Chat to text file
  254. if not used_prefix:
  255. f = open("chatlogs.txt","a")
  256. f.write(("[TEXT/MESSAGE]")+(" [")+room.name+("]")+" "+user.name+(" : ")+message.body+(" : ")+message.ip+"\n")
  257. f.close()
  258.  
  259. #Write Commands to text file
  260. if used_prefix:
  261. f = open("chatlogs.txt","a")
  262. f.write(("[COMMAND]")+(" [")+room.name+("]")+" "+user.name+(" : ")+cmd+(" : ")+message.ip+"\n")
  263. f.close()
  264.  
  265. #Write IPs to text file
  266. ## if not used_prefix:
  267. ## f = open("iplist.txt","a")
  268. ## f.write(user.name+" : "+message.ip+"\n")
  269. ## f.close()
  270.  
  271. ##########################################################
  272. ##Detection
  273.  
  274. #Detect Message
  275. if not used_prefix:
  276. print(("[TEXT/MESSAGE]"), ("[")+room.name+("]"), user.name, (":"), message.body, (":"), message.ip)
  277.  
  278. #Detect Blacklist
  279. if used_prefix and user.name in blacklist:
  280. return
  281.  
  282. #Detect Command
  283. if used_prefix:
  284. print(("[COMMAND]"), ("[")+room.name+("]"), user.name, (":"), cmd, (":"), args, (":"), message.ip)
  285.  
  286. ###########################################################
  287. ##Commands
  288.  
  289.  
  290. #Say Command
  291. if used_prefix and cmd=="say" and self.getAccess(user) >=1:
  292. if args:
  293. room.message(args)
  294. else:
  295. room.message("F o h filthy sand nigger, actually say something.")
  296.  
  297. #Clear Chatlogs
  298. if used_prefix and cmd=="clear" and self.getAccess(user) >=5:
  299. if len(args)>0:
  300. if args=="logs":
  301. file = open("chatlogs.txt","w")
  302. f.write("")
  303. f.close()
  304. print("[INFO] Cleared Chatlogs.txt")
  305. room.message("Cleared the chatlogs, senpai")
  306. else:
  307. room.message("That is not a valid argument for this command.")
  308. return
  309.  
  310. #Announcement Command
  311. elif used_prefix and cmd=="anc" and self.getAccess(user) >=3:
  312. if args:
  313. return
  314. else:
  315. return
  316.  
  317. #Google
  318. elif used_prefix and cmd=="google" and self.getAccess(user) >=1:
  319. if args:
  320. room.message("Next time don't be lazy: www.lmgtfy.com/?q="+args)
  321. else:
  322. room.message("If you're not gonna say anything, do it yourself.")
  323.  
  324. #Image Upload
  325. elif used_prefix and cmd=="img" and self.getAccess(user) >=1:
  326. if not args:
  327. room.message("Put it here faggot: http://pyon.be/")
  328. else:
  329. room.message("This command does not require arguments.")
  330.  
  331.  
  332. #Ranks List
  333. elif used_prefix and cmd=="ranks" and self.getAccess(user) >=1:
  334. if not args:
  335. room.message("The current ranks are: 1. Member, 2. Moderator, 3. Admin, 4 God.")
  336. else:
  337. room.message("This command does not require arguments.")
  338.  
  339.  
  340. #Nickname
  341. elif used_prefix and cmd=="nick" and self.getAccess(user) >=1:
  342. if args:
  343. nick = args.lower()
  344. user=user.name.lower()
  345. nicks[user]=json.dumps(nick)
  346. room.message(str.capitalize(user)+" I'd rather call you scum, but I'll call you : "+str.capitalize(nick))
  347. print("[INFO] Saving Nicknames......")
  348. f = open("nicks.txt","w")
  349. for user in nicks:
  350. nick = json.loads(nicks[user])
  351. f.write(json.dumps([user,nick])+"\n")
  352. f.close()
  353. else:
  354. room.message("You need to type =nick [nickname]")
  355.  
  356.  
  357. #Youtube Search
  358. elif used_prefix and cmd=="yt" and self.getAccess(user) >=1 and len(args)>0:
  359. try:
  360. string=args.lower()
  361. def search(string):
  362. apikey = API_KEY
  363. api = requests.get("https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=1&order=relevance&q=%s&safeSearch=none&key=%s" % (string, apikey)).json()
  364. id = api['items'][0]['id']['videoId']
  365. link = "https://www.youtube.com/watch?v=%s" % id
  366. title = api['items'][0]['snippet']['title']
  367. auth = api['items'][0]['snippet']['channelTitle']
  368. try:
  369. return title + " by " + auth + " " + link
  370. except:
  371. return "fucked your shit up"
  372. room.message(search(string))
  373. except:
  374. room.message("You dun fucked up kid")
  375. print(traceback.format_exc())
  376.  
  377.  
  378. #Urban Dictionary
  379. elif used_prefix and cmd=="ud" and args != "" and self.getAccess(user) >=1:
  380. if args:
  381. url = urlreq.urlopen("http://www.urbandictionary.com/define.php?term="+args).read().decode()
  382. stuff = url.split("<div class='meaning'>")[1]
  383. stuff2 = stuff.split("</div>")[0]
  384. stuff2 = stuff2.replace("\n", "")
  385. room.message(args+ ": "+stuff2)
  386. else:
  387. room.message("You need to type =ud [search]")
  388.  
  389. #PM
  390. elif used_prefix and cmd=="pm" and self.getAccess(user) >=2:
  391. if len(args)>0:
  392. a,b = args.split(" ", 1)
  393. try:
  394. self.setFontFace("Corbel")
  395. self.setFontSize(12)
  396. self.pm.message(ch.User(a.lower()), "From : "+user.name.title()+" : "+b)
  397. self.setFontFace("Corbel")
  398. self.setFontSize(9)
  399. room.message("Message Sent to: "+a.title())
  400. print("[INFO] Message To : "+a.title()+" : From : "+user.name.title()+" : "+b)
  401. except:
  402. room.message("Message was unable to send.")
  403. return
  404. else:
  405. room.message("You need to type =pm [username, message]")
  406.  
  407. #Room Message
  408. elif used_prefix and cmd=="rm" and self.getAccess(user) >=4:
  409. if len(args)>0:
  410. a,b = args.split(" ", 1)
  411. try:
  412. self.getRoom(a).message(b)
  413. room.message("Message sent to room: "+a.title())
  414. print("[INFO] Message To : "+a.title()+" : From : "+user.name.title()+" : "+b)
  415. except:
  416. room.message("Couldn't send message.")
  417. return
  418. else:
  419. room.message("You need to type =rm [roomname, message]")
  420.  
  421.  
  422. #Define
  423. ##To be coded
  424.  
  425.  
  426. #COMMANDS
  427. elif used_prefix and cmd=="cmds" and self.getAccess(user)>=1:
  428. if not args:
  429. room.message("Use commands with [=] dumbass.")
  430. room.message("Commands: say , hi, help, rules , nick, ud, boom, ping, prof, coin, donate, yt, cookie, lvl, rabbit, google, ranks")
  431. elif args and args=="mod":
  432. room.message("Moderator Commands: userlist, pm")
  433. elif args and args=="admin":
  434. room.message("Admin Commands: ban, unban, del, poof, dc, rc")
  435.  
  436.  
  437. #Help
  438. elif used_prefix and cmd=="help":
  439. if args and args == "say":
  440. room.message("type =say and then arguments (what you want me to say)")
  441. elif args and args =="hi":
  442. room.message("type =hi to get my attention, I'm busy")
  443. elif args and args =="mods":
  444. room.message("type =mods room to get the mods")
  445. elif args and args=="rules":
  446. room.message("type =rules to know wtf you're doing")
  447. elif args and args=="nick":
  448. room.message("type =nick then what I should call you")
  449. elif args and args=="ud":
  450. room.message("type -ud to search the urban dictionary")
  451. elif args and args=="boom":
  452. room.message("type =boom to kill someone, throw it or not, I don't care")
  453. elif args and args=="ping":
  454. room.message("type =ping and the name of the other useless body you want to notice you")
  455. elif args and args=="prof":
  456. room.message("type =prof and then someone's name to see their pic")
  457. elif args and args=="coin":
  458. room.message("type =coin to flip a coin ")
  459. elif args and args=="donate":
  460. room.message("type =donate to give me money")
  461. elif args and args=="yt":
  462. room.message("type =yt to find your video")
  463. elif args and args=="cookie":
  464. room.message("type =cookie to give me substance")
  465. elif args and args=="rabbit":
  466. room.message("type =rabbit then the rabb.it username you want")
  467. elif args and args=="lvl":
  468. room.message("type =lvl to check your rank in my system or type -lvl and then a username to check someone elses")
  469. elif args and args=="pm":
  470. room.message("type =pm then a username, followed by a message to send someone a private message.")
  471. elif args and args=="google":
  472. room.message("type =google and then what you want to search")
  473. elif not args:
  474. room.message("type =help to learn how to use commands")
  475. else:
  476. room.message("That is not a valid argument for this command.")
  477. return
  478.  
  479.  
  480. #Hello
  481. elif used_prefix and cmd=="hi" and self.getAccess(user) >=1:
  482. if not args:
  483. room.message("Sup fag, I mean "+str.capitalize(sntonick(user.name))+".")
  484. else:
  485. room.message("This command does not require arguments.")
  486.  
  487. #Mod List
  488. elif used_prefix and cmd=="mods" and self.getAccess(user) >=2:
  489. if args and args=="room":
  490. room.message("OWNER :"+str(room.owner))
  491. room.message("MODS : "+str(room.mods))
  492. elif args and args=="bot":
  493. f = open("moderators.txt","r")
  494. for name in f.readlines():
  495. room.message(name)
  496. f.close()
  497. else:
  498. room.message("That is not a valid argument for this command.")
  499.  
  500. #Check staff level within room
  501. elif used_prefix and cmd=="stafflvl" and self.getAccess(user) >=1:
  502. if not args:
  503. room.message("Staff Level: %i" %(room.getLevel(user)))
  504. else:
  505. room.message("This command does not require arguments.")
  506.  
  507.  
  508. #Add Room Mod
  509. elif used_prefix and cmd=="addmod" and self.getAccess(ch.User(name)) >=2:
  510. room.addMod(ch.User(args.lower()))
  511. print("[INFO] Adding Room Moderator: "+args.title())
  512. room.message("Adding Room Moderator: "+args.title())
  513.  
  514. #Delete Room Mod
  515. elif used_prefix and cmd=="removemod" and self.getAccess(ch.User(name)) >=2:
  516. room.removeMod(ch.User(args.lower()))
  517. print("[INFO] Removed Room Moderator: "+args.title())
  518. room.message("Deleting Room Moderator: "+args.title())
  519.  
  520.  
  521. #Ban
  522. elif used_prefix and cmd=="ban" and self.getAccess(user) >=3:
  523. if args:
  524. room.ban(ch.User(args.lower()))
  525. else:
  526. room.message("You need to type =ban [username]")
  527.  
  528. #Unban
  529. elif used_prefix and cmd=="unban" and self.getAccess(user) >=3:
  530. if args:
  531. room.unban(ch.User(args.lower()))
  532. else:
  533. room.message("You need to type =unban [username]")
  534.  
  535. #Delete User
  536. elif used_prefix and cmd=="del" and self.getAccess(user)>=3:
  537. if args:
  538. room.clearUser(ch.User(args.lower()))
  539. print("[INFO] Deleted user: "+args.title())
  540. room.message("Deleted user: "+args.title())
  541. else:
  542. room.message("You need to type =del [username]")
  543.  
  544. #Clear Chat
  545. elif used_prefix and cmd=="poof" and self.getAccess(user) >=3:
  546. if not args:
  547. room.message("Clearing chat")
  548. room.clearall()
  549. else:
  550. room.message("This command does not require arguments.")
  551.  
  552. #Ping
  553. elif used_prefix and cmd=="ping" and self.getAccess(user) >=1:
  554. if args:
  555. room.message("@"+args)
  556. else:
  557. room.message("You need to type =ping [username]")
  558.  
  559. #All Users Online
  560. elif used_prefix and cmd=="userlist" and self.getAccess(user) >=2:
  561. if not args:
  562. room.message("Users Online: "+str(room.userlist))
  563. else:
  564. room.message("This command does not require arguments.")
  565.  
  566. #Reconnect
  567. elif used_prefix and cmd=="rc" and self.getAccess(user) >=3:
  568. if not args:
  569. room.reconnect()
  570. else:
  571. room.message("This command does not require arguments.")
  572.  
  573. #Disconnect
  574. elif used_prefix and cmd=="dc" and self.getAccess(user) >=3:
  575. if not args:
  576. room.message("Leaving Room "+room.name)
  577. room.disconnect()
  578. else:
  579. room.message("This command does not require arguments.")
  580.  
  581. #Rules
  582. elif used_prefix and cmd=="rules" and self.getAccess(user) >=1:
  583. if not args:
  584. room.message("Rule Number One: You must obey the hosts every command, Rule Number Two: Refer to rule 1")
  585. else:
  586. room.message("This command does not require arguments.")
  587.  
  588. #Paypal donation link
  589. elif used_prefix and cmd=="donate":
  590. if not args:
  591. room.message("If you want to support us and give us the opportunity to run ourselves 24/7, you can donate here: www.paypal.me/xaelitry")
  592. else:
  593. room.message("This command does not require arguments.")
  594.  
  595. #Profile
  596. elif used_prefix and cmd=="prof" and args !="" and self.getAccess(user) >=1:
  597. if args:
  598. room.message("www.barrykun.com/pic/"+args+".jpg")
  599. if not args:
  600. room.message("www.barrykun.com/pic/"+user.name+".jpg")
  601. else:
  602. room.message("You need to type =prof [username] or just -prof to get your own")
  603.  
  604.  
  605. #Grenade
  606. elif used_prefix and cmd=="boom" and self.getAccess(user) >=1:
  607. if args:
  608. room.message(random.choice(["Hands "+args.title()+" a grenade -waits 10 seconds- *BOOM* "+args.title()+" is KEELED xD", "Takes a shot at "+args.title()+" with a remmington 2200, you ded", "-Fires a RPG at "+args.title()+"- Kaboom! "+args.title()+" is dead [WASTED]"]))
  609. else:
  610. room.message("You didn't throw it! [WASTED]")
  611.  
  612. #Rabb.it
  613. elif used_prefix and cmd=="rabbit" and self.getAccess(user) >=1:
  614. if args:
  615. room.message("Come hang out in www.rabb.it/"+args)
  616. else:
  617. room.message("You need to type -rabbit [rabb.it username]")
  618.  
  619. #Cookie
  620. elif used_prefix and cmd=="cookie" and self.getAccess(user) >=1:
  621. if not args:
  622. room.message(random.choice(["yesh" , "sure ^^" , "no ty =/" , "O_O gimme" , "cookie...YESH" , "^.^" , "COOKIE" , "-noms cookie- arigatou"]))
  623. else:
  624. room.message("This command does not require arguments.")
  625.  
  626. #Kawaii on the streets Senpai in the sheets
  627. elif used_prefix and cmd=="senpai" and self.getAccess(user) >=4:
  628. if not args:
  629. room.message("https://cdn.shopify.com/s/files/1/0215/5308/products/kawaii_on_streets_1024x1024.jpg?v=1417209482")
  630. else:
  631. room.message("This command does not require arguments.")
  632.  
  633. #evaluation
  634. elif used_prefix and cmd == "eval" and self.getAccess(user) >=5:
  635. if args:
  636. try:
  637. ret = eval(args)
  638. room.message(str(repr(ret)))
  639. except:
  640. room.message("Error >_>" + str(sys.exc_info()))
  641. else:
  642. room.message("This command requires arguments.")
  643.  
  644. #Coin Flip
  645. elif used_prefix and cmd=="coin" and self.getAccess(user) >=1:
  646. if not args:
  647. room.message(random.choice(["%s flips a coin and gets heads" % user.name.title(), "%s flips a coin and gets tails" % user.name.title(), "%s flips a coin and it falls off the table o.O" % user.name.title()]))
  648. else:
  649. room.message("This command does not require arguments.")
  650.  
  651. ###########################################################
  652. ##Console
  653.  
  654. ## talk = input("Message: ")
  655. ##
  656. ## ##Console Chat Function
  657. ## if talk:
  658. ## room.message(talk)
  659. ###########################################################
  660. ##Room Leaving/Joining
  661.  
  662.  
  663. ##Join Room
  664. elif used_prefix and cmd=="join" and self.getAccess(user)>=3:
  665. if len(args)>0:
  666. room.message("Joining Room: "+args.title())
  667. rooms.append(args.lower())
  668. self.joinRoom(args.lower())
  669. f = open("rooms.txt", "w")
  670. f.write("\n".join(rooms))
  671. f.close()
  672.  
  673. ##Leave Room
  674. elif used_prefix and cmd=="leave" and self.getAccess(user)>=3:
  675. if len(args)>0:
  676. self.leaveRoom(args.lower())
  677. room.message("Leaving Room: "+args.title())
  678. rooms.remove(args.lower())
  679. f = open("rooms.txt", "w")
  680. f.write("\n".join(rooms))
  681. f.close()
  682. else:
  683. room.message("Leaving Room: "+room.name.title())
  684. self.setTimeout(1, self.leaveRoom, room.name)
  685. rooms.remove(room.name.lower())
  686. f = open("rooms.txt", "w")
  687. f.write("\n".join(rooms))
  688. f.close()
  689.  
  690. ###########################################################
  691. ##Rank Commands
  692.  
  693. #Whitelist
  694. elif used_prefix and cmd == "wl":
  695. if len(args) >= 3:
  696. do, name = args.lower().split(" ", 1)
  697. if self.getAccess(user) < 2 or user.name in blacklist:
  698. room.message("no. :|")
  699. return
  700. if do == "add":
  701. if self.getAccess(user) >= 1:
  702. if name in members:
  703. room.message("%s is already whitelisted. ^.^" % name.title(), True)
  704. else:
  705. members.append(name)
  706. room.message("%s is now Whitelisted(Level 1) now fuck off." % name.title(), True)
  707. print("[INFO] Saving Members......")
  708. f = open("members.txt", "w")
  709. f.write("\n".join(members))
  710. f.close()
  711. else:
  712. room.message("I couldn't whitelist that person, k bye")
  713. elif do == "remove":
  714. if self.getAccess(user) <= 1:
  715. room.message("no. :|")
  716. return
  717. if name not in members: room.message("%s is not whitelisted =/" % name.title(), True)
  718. else:
  719. members.remove(name)
  720. room.message("It has been done.", True)
  721. print("[INFO] Saving Members......")
  722. f = open("members.txt", "w")
  723. f.write("\n".join(members))
  724. f.close()
  725. else:
  726. room.message("what? >.>", True)
  727. else:
  728. if len(members) == 0: room.message("I have no whitelisted members.", True)
  729. elif len(members) == 1: room.message("I have 1 whitelisted member.", True)
  730. else: room.message("I have %s whitelisted members." % len(members), True)
  731.  
  732.  
  733. #Moderator
  734. elif used_prefix and cmd == "mod":
  735. if len(args) >= 3:
  736. do, name = args.lower().split(" ", 1)
  737. if self.getAccess(user) < 3 or user.name in blacklist:
  738. room.message("no. :|")
  739. return
  740. if do == "add":
  741. if self.getAccess(user) >= 3:
  742. if name in moderators:
  743. room.message("%s is already modded" % name.title(), True)
  744. else:
  745. moderators.append(name)
  746. room.message("%s is now a Moderator (Level 2) now fuck off." % name.title(), True)
  747. print("[INFO] Saving Moderators......")
  748. f = open("moderators.txt", "w")
  749. f.write("\n".join(moderators))
  750. f.close()
  751. else:
  752. room.message("I couldn't mod that person, k bye")
  753. elif do == "remove":
  754. if self.getAccess(user) < 3:
  755. room.message("no. :|")
  756. return
  757. if name not in moderators: room.message("%s is not modded." % name.title(), True)
  758. else:
  759. moderators.remove(name)
  760. room.message("It has been done. =/", True)
  761. print("[INFO] Saving Moderators......")
  762. f = open("moderators.txt", "w")
  763. f.write("\n".join(moderators))
  764. f.close()
  765. else:
  766. room.message("what? >.>", True)
  767.  
  768.  
  769. #Admin
  770. elif used_prefix and cmd == "admin":
  771. if len(args) >= 3:
  772. do, name = args.lower().split(" ", 1)
  773. if self.getAccess(user) < 4 or user.name in blacklist:
  774. room.message("no. :|")
  775. return
  776. if do == "add":
  777. if self.getAccess(user) >= 4:
  778. if name in admins:
  779. room.message("%s is already Admin." % name.title(), True)
  780. else:
  781. admins.append(name)
  782. room.message("%s is now an Admin (Level 3) now fuck off." % name.title(), True)
  783. print("[INFO] Saving Admins......")
  784. f = open("admins.txt", "w")
  785. f.write("\n".join(admins))
  786. f.close()
  787. else:
  788. room.message("I couldn't admin that person, k bye")
  789. elif do == "remove":
  790. if self.getAccess(user) < 4:
  791. room.message("You don't have access to that.")
  792. return
  793. if name not in admins: room.message("%s is not admin." % name.title(), True)
  794. else:
  795. admins.remove(name)
  796. room.message("It has been done. =/", True)
  797. print("[INFO] Saving Admins......")
  798. f = open("admins.txt", "w")
  799. f.write("\n".join(admins))
  800. f.close()
  801. else:
  802. room.message("what? >.>", True)
  803.  
  804.  
  805. #God
  806. elif used_prefix and cmd == "god":
  807. if len(args) >= 3:
  808. do, name = args.lower().split(" ", 1)
  809. if self.getAccess(user) < 4 or user.name in blacklist:
  810. room.message("no. :|")
  811. return
  812. if do == "add":
  813. if self.getAccess(user) >= 4:
  814. if name in gods:
  815. room.message("%s is already a God. ^~^" % name.title(), True)
  816. else:
  817. gods.append(name)
  818. room.message("%s is now a God (Level 4) now fuck off" % name.title(), True)
  819. print("[INFO] Saving Gods......")
  820. f = open("gods.txt", "w")
  821. f.write("\n".join(gods))
  822. f.close()
  823. else:
  824. room.message("You could not be ascended into the heavens, gomenasai senpai v~v")
  825. elif do == "remove":
  826. if self.getAccess(user) < 4:
  827. room.message("You don't have access to that.")
  828. return
  829. if name not in gods: room.message("%s is not a god." % name.title(), True)
  830. else:
  831. gods.remove(name)
  832. room.message("It has been done. =/", True)
  833. print("[INFO] Saving Gods......")
  834. f = open("gods.txt", "w")
  835. f.write("\n".join(gods))
  836. f.close()
  837. else:
  838. room.message("what? >.>", True)
  839.  
  840. #Master
  841. elif used_prefix and cmd == "master":
  842. if len(args) >= 3:
  843. do, name = args.lower().split(" ", 1)
  844. if self.getAccess(user) < 5 or user.name in blacklist:
  845. room.message("no. :|")
  846. return
  847. if do == "add":
  848. if self.getAccess(user) >= 5:
  849. if name in masters:
  850. room.message("%s is already my Master." % name.title(), True)
  851. else:
  852. masters.append(name)
  853. room.message("%s is now my Master (Level 4) now fuck off" % name.title(), True)
  854. print("[INFO] Saving Masters......")
  855. f = open("masters.txt", "w")
  856. f.write("\n".join(masters))
  857. f.close()
  858. else:
  859. room.message("You could not be ascended into the heavens, k bye")
  860. elif do == "remove":
  861. if self.getAccess(user) < 4:
  862. room.message("You don't have access to that.")
  863. return
  864. if name not in masters: room.message("%s is not my Master." % name.title(), True)
  865. else:
  866. masters.remove(name)
  867. room.message("It has been done. =/", True)
  868. print("[INFO] Saving Masters......")
  869. f = open("masters.txt", "w")
  870. f.write("\n".join(masters))
  871. f.close()
  872. else:
  873. room.message("what? >.>", True)
  874.  
  875. #Blacklist
  876. elif used_prefix and cmd == "bl":
  877. if len(args) >= 3:
  878. do, name = args.lower().split(" ", 1)
  879. if self.getAccess(user) < 4:
  880. room.message("no. :|")
  881. return
  882. if do == "add":
  883. if self.getAccess(user) >= 4:
  884. if name in blacklist:
  885. room.message("%s is already blacklisted" % name.title(), True)
  886. else:
  887. blacklist.append(name)
  888. room.message("It has been done. %s is now blacklisted (Level -1)" % name.title(), True)
  889. print("[INFO] Saving Blacklist......")
  890. f = open("blacklist.txt", "w")
  891. f.write("\n".join(blacklist))
  892. f.close()
  893. members.remove(name)
  894. moderators.remove(name)
  895. admins.remove(name)
  896. gods.remove(name)
  897. f = open("members.txt","w")
  898. f.write("\n".join(members))
  899. f.close()
  900. f = open("moderators.txt","w")
  901. f.write("\n".join(moderators))
  902. f.close()
  903. f = open("admins.txt","w")
  904. f.write("\n".join(admins))
  905. f.close()
  906. f = open("gods.txt","w")
  907. f.write("\n".join(gods))
  908. f.close()
  909. else:
  910. room.message("You could not blacklist that person.")
  911. elif do == "remove":
  912. if self.getAccess(user) < 4:
  913. room.message("You don't have access to that.")
  914. return
  915. if name not in blacklist: room.message("%s is not blacklisted." % name.title(), True)
  916. else:
  917. blacklist.remove(name)
  918. room.message("%s is now free to use commands" % name.title(), True)
  919. print("[INFO] Saving Blacklist......")
  920. f = open("blacklist.txt", "w")
  921. f.write("\n".join(blacklist))
  922. f.close()
  923. else:
  924. room.message("what? >.>", True)
  925.  
  926.  
  927. #Level
  928. elif used_prefix and cmd == "lvl":
  929. if args and args in blacklist:
  930. room.message(args.title()+" is blacklisted (Level -1)")
  931. if args and args in members:
  932. room.message(args.title()+" is a Member (Level 1)")
  933. if args and args in moderators:
  934. room.message(args.title()+" is a Moderator (Level 2)")
  935. if args and args in admins:
  936. room.message(args.title()+" is an Admin (Level 3)")
  937. if args and args in gods:
  938. room.message(args.title()+" is a God (Level 4)")
  939. if args and args in masters:
  940. room.message(args.title()+" is my Master (Level 5)")
  941. if args and args not in blacklist and args not in members and args not in moderators and args not in admins and args not in gods and args not in masters:
  942. room.message("Unlisted (Level 0)")
  943. if not args and user.name in blacklist:
  944. room.message(user.name.title()+" is blacklisted (Level -1)")
  945. if not args and user.name in members:
  946. room.message(user.name.title()+" is a Member (Level 1)")
  947. if not args and user.name in moderators:
  948. room.message(user.name.title()+" is a Moderator (Level 2)")
  949. if not args and user.name in admins:
  950. room.message(user.name.title()+" is an Admin (Level 3)")
  951. if not args and user.name in gods:
  952. room.message(user.name.title()+" is a God (Level 4)")
  953. if not args and user.name in masters:
  954. room.message(user.name.title()+" is my Master (Level 5)")
  955. if not args and user.name not in blacklist and user.name not in members and user.name not in moderators and user.name not in admins and user.name not in gods and user.name not in masters:
  956. room.message(user.name.title()+(" is Unlisted (Level 0)"))
  957.  
  958.  
  959.  
  960. ###########################################################
  961. ##Persona
  962.  
  963.  
  964. #Persona Enable
  965. elif used_prefix and cmd=="p" and self.getAccess(user) >=3:
  966. if args and args=="enable":
  967. print("[INFO] Enabling Persona")
  968. room.message("Persona Enabled")
  969. f = open("persona.txt","w")
  970. f.write(args)
  971. f.close()
  972. elif args and args=="disable":
  973. print("[INFO] Disabling Persona")
  974. room.message("Persona Disabled")
  975. f = open("persona.txt","w")
  976. f.write(args)
  977. f.close()
  978.  
  979.  
  980. ## if cmd=="hi" and self.getAccess(user) >=1:
  981. ## room.message("Hiya "+str.capitalize(sntonick(user.name))+"-senpai *h*")
  982. ## if cmd=="brb":
  983. ## room.message("Tyt, don't worry about comin back "+str.capitalize(sntonick(user.name))+"! *h*")
  984. ## if cmd=="back":
  985. ## room.message("So you came back after all? "+str.capitalize(sntonick(user.name))+"-senpai! *h*")
  986. ## if cmd=="bbl":
  987. ## room.message("K bye "+str.capitalize(sntonick(user.name))+"-senpai.. *h*")
  988. ## if cmd=="smd":
  989. ## room.message("How much you paying? "+str.capitalize(sntonick(user.name))+", you pindick")
  990. ## if cmd=="kys":
  991. ## room.message("You first")
  992. ## if cmd=="kms":
  993. ## room.message("Go for it, let me watch!")
  994. elif len(cmd) ==3 and not args and cmd=="Ateluix" or cmd=="ateluix" or cmd=="atel"or cmd=="Atel":
  995. if user.name in blacklist:
  996. return
  997. else:
  998. room.message("What the fuck you want?")
  999.  
  1000.  
  1001.  
  1002. ###########################################################
  1003. ##Saving
  1004.  
  1005. #Save
  1006. if used_prefix and cmd=="save" and self.getAccess(user) >=3:
  1007. room.message("Saving stuffs my dood :P")
  1008. print("[INFO] Saving Nicknames......")
  1009. f = open("nicks.txt","w")
  1010. for user in nicks:
  1011. nick = json.loads(nicks[user])
  1012. f.write(json.dumps([user,nick])+"\n")
  1013. f.close()
  1014.  
  1015. time.sleep(1)
  1016.  
  1017. print("[INFO] Saving Defintions......")
  1018. f = open("definitions.txt")
  1019. for word in dictionary:
  1020. definition, name = json.loads(dictionary[word])
  1021. f.write(json.dumps([word, definition, name])+"\n")
  1022. f.close()
  1023.  
  1024.  
  1025. ###########################################################
  1026. ##Room Connection
  1027.  
  1028. if __name__ == "__main__":
  1029. bot.easy_start(rooms, username, password)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement