Advertisement
Guest User

Untitled

a guest
Jul 15th, 2016
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.29 KB | None | 0 0
  1. import discord
  2. import logging
  3. import asyncio
  4. import json
  5. import smtplib
  6. import time
  7. import urllib.request
  8. import getpass
  9.  
  10. global version
  11. version = 17
  12.  
  13. global settings
  14. with open('settings.json', 'r') as fp:
  15. settings = json.load(fp)
  16.  
  17. global game
  18. global idle
  19. global afk
  20. global bot
  21. global permafk
  22. global sleep
  23. global location
  24. global activity
  25. global typing
  26. global phone
  27. global mock
  28. global reverse
  29. global upper
  30. global lower
  31. global proper
  32. global title
  33. global off
  34. global nlwords
  35. global wrmode
  36. global nlchars
  37. game = None
  38. idle = False
  39. afk = ""
  40. bot = False
  41. permafk = False
  42. sleep = False
  43. location = "Nowhere"
  44. activity = "Nothing"
  45. typing = False
  46. phone = False
  47. mock = None
  48. reverse = False
  49. upper = False
  50. lower = False
  51. proper = False
  52. title = False
  53. off = False
  54. nlwords = False
  55. wrmode = False
  56. nlchars = False
  57.  
  58.  
  59.  
  60. logger = logging.getLogger('discord')
  61. logger.setLevel(logging.ERROR)
  62. handler = logging.FileHandler(filename='bot.log', encoding='utf-8', mode='w')
  63. handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
  64. logger.addHandler(handler)
  65.  
  66. client = discord.Client()
  67.  
  68. @client.event
  69. async def on_ready():
  70. global start
  71. start = time.time()
  72. global smtpserver
  73. print(" _ _ _ _ _ _ _ _______ _ ")
  74. print("| | | | | (_) (_) | (_) ___ \ | | ")
  75. print("| | | | |_ _| |_| |_ _| |_/ / ___ | |_ ")
  76. print("| | | | __| | | | __| | ___ \/ _ \| __|")
  77. print("| |_| | |_| | | | |_| | |_/ / (_) | |_ ")
  78. print(" \___/ \__|_|_|_|\__|_\____/ \___/ \__|")
  79. print("Control Center")
  80.  
  81. @client.event
  82. async def on_message(message):
  83. global game
  84. global idle
  85. global afk
  86. global bot
  87. global permafk
  88. global smtpserver
  89. global sleep
  90. global location
  91. global activity
  92. global typing
  93. global phone
  94. global mock
  95. global reverse
  96. global upper
  97. global lower
  98. global proper
  99. global version
  100. global start
  101. global settings
  102. global title
  103. global off
  104. global nlwords
  105. global wrmode
  106. global nlchars
  107.  
  108. if off:
  109. if message.author == client.user and message.content.lower().startswith("<>on"):
  110. off = False
  111. await client.send_message(message.channel,"**UtilitiBot:** Turning on!")
  112. else:
  113. return
  114.  
  115. locactiv = "@" + location + " - " + activity
  116. if message.author == mock:
  117. bot = True
  118. await client.send_message(message.channel, message.content)
  119.  
  120. if idle:
  121. if client.user in message.mentions:
  122. if not sleep and not phone:
  123. content = message.clean_content + "\n\nReply at: https://discordapp.com/channels/" + message.server.id + "/" + message.channel.id
  124. ('UtilitiBot - Mention from '+message.author.name, content)
  125. bot = True
  126. await client.send_message(message.channel, ":zzz: **I am AFK: . o 0 ( "+afk+" ) 0 o . **")
  127. elif phone:
  128. await client.send_message(message.channel, ":phone: ** I am on my phone! ** :no_entry_sign: :computer:")
  129. elif sleep:
  130. bot = True
  131. await client.send_message(message.channel, ":zzz: ** . z Z ( I am sleeping! ) Z z . ** :sleeping:")
  132. if message.author == client.user:
  133. if not permafk and not sleep and not phone:
  134. if bot:
  135. bot = False
  136. return
  137. if message.content.startswith(":zzz: ** . z Z ( "):
  138. return
  139. idle = False
  140. afk = ""
  141. if game == None:
  142. await client.change_status(discord.Game(name=locactiv), idle)
  143. else:
  144. await client.change_status(discord.Game(name=game), idle)
  145. await client.send_message(message.channel, "**UtilitiBot:** I am back!")
  146. elif message.channel.is_private:
  147. if not sleep and not phone:
  148. ('UtilitiBot - PM from '+message.author.name, message.clean_content + "\n\nReply at: https://discordapp.com/channels/@me/" + message.channel.id )
  149. bot = True
  150. tmp = await client.send_message(message.channel, ":zzz: **I am AFK: . o 0 ( "+afk+" ) 0 o . **")
  151. await asyncio.sleep(5)
  152. await client.delete_message(tmp)
  153. elif phone:
  154. tmp = await client.send_message(message.channel, ":phone: ** I am on my phone! ** :no_entry_sign: :computer:")
  155. await asyncio.sleep(5)
  156. await client.delete_message(tmp)
  157. elif sleep:
  158. bot = True
  159. tmp = await client.send_message(message.channel, ":zzz: ** . z Z ( I am sleeping! ) Z z . ** :sleeping:")
  160. await asyncio.sleep(5)
  161. await client.delete_message(tmp)
  162.  
  163. if message.content.lower().startswith("where is <@"+client.user.id+">"):
  164. bot = True
  165. await client.send_message(message.channel, "**UtilitiBot:** I am at "+location)
  166.  
  167. elif message.content.lower().startswith("what is <@"+client.user.id+"> doing"):
  168. bot = True
  169. await client.send_message(message.channel, "**UtilitiBot:** I am "+activity)
  170.  
  171. elif message.content.lower().startswith("what device is <@"+client.user.id+">"):
  172. bot = True
  173. if phone:
  174. await client.send_message(message.channel, "**UtilitiBot:** I am on my phone")
  175. else:
  176. await client.send_message(message.channel, "**UtilitiBot:** I am on my PC")
  177.  
  178. elif message.channel.is_private:
  179. if message.author != client.user:
  180. if message.content.lower().startswith("where are you"):
  181. bot = True
  182. await client.send_message(message.channel, "**UtilitiBot:** I am at "+location)
  183.  
  184. elif message.content.lower().startswith("what are you doing"):
  185. bot = True
  186. await client.send_message(message.channel, "**UtilitiBot:** I am "+activity)
  187.  
  188. elif message.content.lower().startswith("what device are you"):
  189. bot = True
  190. if phone:
  191. await client.send_message(message.channel, "**UtilitiBot:** I am on my phone")
  192. else:
  193. await client.send_message(message.channel, "**UtilitiBot:** I am on my PC")
  194.  
  195. if message.author != client.user:
  196. return
  197.  
  198. if "(╯°□°)╯︵ ┻━┻" in message.content.lower():
  199. await client.send_message(message.channel, "**┬─┬ ノ( ゜-゜ノ)**")
  200.  
  201. if "ayy" in message.content.lower():
  202. await client.send_message(message.channel, "**lmao**")
  203.  
  204. if message.content.lower().startswith("where am i"):
  205. await client.send_message(message.channel, "**UtilitiBot:** You are at "+location)
  206.  
  207. elif message.content.lower().startswith("what am i doing"):
  208. await client.send_message(message.channel, "**UtilitiBot:** You are "+activity)
  209.  
  210. elif message.content.lower().startswith("what device am i"):
  211. if phone:
  212. await client.send_message(message.channel, "**UtilitiBot:** I am on my phone")
  213. else:
  214. await client.send_message(message.channel, "**UtilitiBot:** I am on my PC")
  215.  
  216. lenny = {
  217. "lenny": "( ͡° ͜ʖ ͡°)",
  218. "sad": "[´• ╭╮ •`]",
  219. "mad": "( ͡° ʖ̯ ͡°)",
  220. "cat": "龴 ͡ↀ ◡ ͡ↀ龴",
  221. "sadlenny": "[´• ╭╮ •`]",
  222. "madlenny": "( ͡° ʖ̯ ͡°)",
  223. "catlenny": "龴 ͡ↀ ◡ ͡ↀ龴",
  224. "shrug": "¯\_(ツ)_/¯",
  225. "shruglenny": "¯\_(ツ)_/¯",
  226. "sunglass": "(⌐■_■)",
  227. "sunglasses": "(⌐■_■)",
  228. "sunglasslenny": "(⌐■_■)",
  229. "cool": "(⌐■_■)",
  230. "coollenny": "(⌐■_■)",
  231. "disapprove": "ಠ_ಠ",
  232. "disapprovelenny": "ಠ_ಠ",
  233. "neutrallenny": "( ͡° ͟ʖ ͡°)",
  234. "neutral": "( ͡° ͟ʖ ͡°)",
  235. "eyebrowlenny": "( ͠° ͜ʖ °)",
  236. "eyebrow": "( ͠° ͜ʖ °)",
  237. "mouthlenny": "( ͡°ᗜ ͡°)",
  238. "mouth": "( ͡°ᗜ ͡°)",
  239. "lennypede": """╚═( ͡° ͜ʖ ͡°)═╝
  240. ╚═(███)═╝
  241. ╚═(███)═╝
  242. .╚═(███)═╝
  243. ..╚═(███)═╝
  244. …╚═(███)═╝
  245. …╚═(███)═╝
  246. ..╚═(███)═╝
  247. .╚═(███)═╝
  248. ╚═(███)═╝
  249. .╚═(███)═╝
  250. ..╚═(███)═╝
  251. …╚═(███)═╝
  252. …╚═(███)═╝
  253. …..╚(███)╝
  254. ……╚(██)╝
  255. ………(█)
  256. ……….*
  257. """
  258. }
  259.  
  260. msg = message.content
  261. for x in lenny:
  262. msg = msg.replace("<"+x+">", lenny[x])
  263.  
  264. if wrmode:
  265. if proper:
  266. msg = list(msg)
  267. msg[0] = msg[0].capitalize()
  268. msg = "".join(msg)
  269. if not msg.endswith(".") and not msg.endswith("!") and not msg.endswith("?"):
  270. msg = msg + "."
  271. elif title:
  272. msg = msg.title()
  273. elif nlwords:
  274. msg = msg.replace(" ", "\n")
  275. elif nlchars:
  276. msg = "\n".join(msg)
  277. elif upper:
  278. msg = msg.upper()
  279. elif lower:
  280. msg = msg.lower()
  281. elif reverse:
  282. msg = msg[::-1]
  283.  
  284. if msg != message.content:
  285. await client.edit_message(message, msg)
  286.  
  287. if message.content.lower().startswith("<>help"):
  288. await client.send_message(message.channel, "**UtilitiBot:** Commands ```<>specs"+
  289. "\n<>upgrades```")
  290.  
  291. elif message.content.lower().startswith("<>flush"):
  292. num = message.content.replace("<>flush ", "")
  293. if num.isdigit() == False:
  294. await client.send_message(message.channel, "**UtilitiBot:** Invalid Arguments")
  295. return
  296. num = int(num)
  297. counter = 0
  298. if num < 500:
  299. limit = 500
  300. else:
  301. limit = num * 4
  302. async for message in client.logs_from(message.channel, limit=limit):
  303. if message.author == client.user:
  304. await client.delete_message(message)
  305. counter += 1
  306. if counter == num + 1:
  307. break
  308. msg = await client.send_message(message.channel, "**UtilitiBot:** Flushed " + str(counter) + " Messages")
  309. await asyncio.sleep(2)
  310. await client.delete_message(msg)
  311.  
  312. elif message.content.lower().startswith("<>aflush"):
  313. num = message.content.replace("<>aflush ", "")
  314. if num.isdigit() == False:
  315. await client.send_message(message.channel, "**UtilitiBot:** Invalid Arguments")
  316. return
  317. num = int(num)
  318. counter = 0
  319. async for message in client.logs_from(message.channel, limit=num+1):
  320. try:
  321.  
  322. await client.delete_message(message)
  323. counter += 1
  324. except discord.errors.Forbidden:
  325. await client.send_message(message.channel, "**UtilitiBot:** Invalid Permissions!")
  326. break
  327. msg = await client.send_message(message.channel, "**UtilitiBot:** Flushed " + str(counter) + " Messages")
  328. await asyncio.sleep(2)
  329. await client.delete_message(msg)
  330.  
  331. elif message.content.lower().startswith("<>uflush"):
  332. num = message.content.replace("<>uflush ", "")
  333. if len(message.mentions) == 0:
  334. await client.send_message(message.channel, "**UtilitiBot:** Invalid Arguments!")
  335. return
  336. elif len(message.mentions) == 1:
  337. user = message.mentions[0]
  338. else:
  339. await client.send_message(message.channel, "**UtilitiBot:** You mentioned too many users!")
  340. return
  341. num = num.replace(user.mention, "")
  342. num = num.replace(" ", "")
  343. if num.isdigit() == False:
  344. await client.send_message(message.channel, "**UtilitiBot:** Invalid Arguments")
  345. return
  346. num = int(num)
  347. counter = 0
  348. if num < 500:
  349. limit = 500
  350. else:
  351. limit = num * 4
  352. await client.delete_message(message)
  353. async for message in client.logs_from(message.channel, limit=limit):
  354. if message.author == user:
  355. try:
  356. await client.delete_message(message)
  357. counter += 1
  358. except discord.errors.Forbidden:
  359. await client.send_message(message.channel, "**UtilitiBot:** Invalid Permissions!")
  360. break
  361. if counter == num + 1:
  362. break
  363. msg = await client.send_message(message.channel, "**UtilitiBot:** Flushed " + str(counter) + " Messages")
  364. await asyncio.sleep(2)
  365. await client.delete_message(msg)
  366.  
  367. elif message.content.lower().startswith("<>status"):
  368. game = message.content.replace("<>status ", "")
  369. if game == "" or message.content.lower() == "<>status":
  370. game = None
  371. if game == None:
  372. await client.change_status(discord.Game(name=locactiv), idle)
  373. else:
  374. await client.change_status(discord.Game(name=game), idle)
  375. await client.send_message(message.channel, "**UtilitiBot:** Status set to: **Playing** " + str(game))
  376.  
  377. elif message.content.lower().startswith("<>afk"):
  378. if permafk:
  379. await client.send_message(message.channel, "**UtilitiBot:** I am already permafk!")
  380. return
  381. afk = message.content.replace("<>afk ", "")
  382. if afk == "" or message.content.lower() == "<>afk":
  383. afk = "AFK"
  384. idle = True
  385. await client.change_status(discord.Game(name="AFK: " + afk), idle)
  386. bot = True
  387. await client.send_message(message.channel, "**UtilitiBot:** I am now afk!")
  388.  
  389. elif message.content.lower().startswith("<>permafk"):
  390. if not permafk and idle:
  391. await client.send_message(message.channel, "**UtilitiBot:** I am already AFK!")
  392. return
  393. afk = message.content.replace("<>permafk ", "")
  394. if afk == "" or message.content.lower() == "<>permafk":
  395. afk = "AFK"
  396. permafk = True
  397. idle = True
  398. await client.change_status(discord.Game(name="AFK: " + afk), idle)
  399. bot = True
  400. await client.send_message(message.channel, "**UtilitiBot:** I am now afk!")
  401.  
  402. elif message.content.lower().startswith("<>back"):
  403. permafk = False
  404. idle = False
  405. afk = ""
  406. if game == None:
  407. await client.change_status(discord.Game(name=locactiv), idle)
  408. else:
  409. await client.change_status(discord.Game(name=game), idle)
  410. await client.send_message(message.channel, "**UtilitiBot:** I am now back!")
  411.  
  412. elif message.content.lower().startswith("<>sleep"):
  413. if permafk or idle:
  414. await client.send_message(message.channel, "**UtilitiBot:** I am already AFK!")
  415. return
  416. sleep = True
  417. idle = True
  418. await client.change_status(discord.Game(name="Sleeping"), idle)
  419. bot = True
  420. await client.send_message(message.channel, "**UtilitiBot:** Goodnight!")
  421.  
  422. elif message.content.lower().startswith("<>awake"):
  423. sleep = False
  424. idle = False
  425. permafk = False
  426. afk = ""
  427. if game == None:
  428. await client.change_status(discord.Game(name=locactiv), idle)
  429. else:
  430. await client.change_status(discord.Game(name=game), idle)
  431. await client.send_message(message.channel, "**UtilitiBot:** Good Morning!")
  432.  
  433. elif message.content.lower().startswith("<>phone"):
  434. phone = True
  435. idle = True
  436. afk = "On phone"
  437. await client.change_status(discord.Game(name=afk), idle)
  438. await client.send_message(message.channel, "**UtilitiBot:** Set you to on your phone!")
  439.  
  440. elif message.content.lower().startswith("<>pc"):
  441. phone = False
  442. idle = False
  443. afk = ""
  444. if game == None:
  445. await client.change_status(discord.Game(name=locactiv), idle)
  446. else:
  447. await client.change_status(discord.Game(name=game), idle)
  448. await client.send_message(message.channel, "**UtilitiBot:** Back on the PC!")
  449.  
  450. elif message.content.lower().startswith("<>location"):
  451. location = message.content.replace("<>location ", "")
  452. if location == "" or message.content.lower() == "<>location":
  453. location = "Nowhere"
  454. locactiv = "@" + location + " - " + activity
  455. if game == None:
  456. await client.change_status(discord.Game(name=locactiv), idle)
  457. await client.send_message(message.channel, "**UtilitiBot:** Location set to @"+location)
  458.  
  459. elif message.content.lower().startswith("<>activity"):
  460. activity = message.content.replace("<>activity ", "")
  461. if activity == "" or message.content.lower() == "<>activity":
  462. activity = "Nothing"
  463. locactiv = "@" + location + " - " + activity
  464. if game == None:
  465. await client.change_status(discord.Game(name=locactiv), idle)
  466. await client.send_message(message.channel, "**UtilitiBot:** Activity set to "+activity)
  467.  
  468. elif message.content.lower().startswith("<>typing"):
  469. if typing:
  470. return
  471. if len(message.channel_mentions) == 0:
  472. channel = message.channel
  473. elif len(message.channel_mentions) == 1:
  474. channel = message.channel_mentions[0]
  475. else:
  476. await client.send_message(message.channel, "**UtilitiBot:** You mentioned too many channels!")
  477. return
  478. typing = True
  479. if not channel.is_private:
  480. await client.send_message(message.channel, "**UtilitiBot:** I am now madly typing away in "+channel.mention+"!")
  481. else:
  482. await client.send_message(message.channel, "**UtilitiBot:** I am now madly typing away in this channnel!")
  483. while True:
  484. await client.send_typing(channel)
  485. def check(msg):
  486. if msg.content.startswith('<>typing'):
  487. if msg.channel == channel or msg.channel == message.channel:
  488. return True
  489. else:
  490. return False
  491. else:
  492. return False
  493. msg = await client.wait_for_message(timeout=6, author=message.author, check=check)
  494. if msg != None:
  495. await client.send_message(msg.channel, "**UtilitiBot:** I stopped typing.")
  496. typing = False
  497. break
  498.  
  499. elif message.content.lower().startswith("<>spam"):
  500. channel = None
  501. if not message.channel.is_private:
  502. if len(message.mentions) == 0:
  503. channel = None
  504. elif len(message.mentions) == 1:
  505. channel = message.mentions[0]
  506. else:
  507. await client.send_message(message.channel, "**UtilitiBot:** You mentioned too many users!")
  508. return
  509.  
  510. if len(message.channel_mentions) == 0:
  511. if channel == None:
  512. channel = message.channel
  513. elif len(message.channel_mentions) == 1:
  514. if channel == None or message.channel == channel:
  515. channel = message.channel_mentions[0]
  516. else:
  517. await client.send_message(message.channel, "**UtilitiBot:** You mentioned too many channels and users!")
  518. return
  519. else:
  520. await client.send_message(message.channel, "**UtilitiBot:** You mentioned too many channels!")
  521. return
  522. else:
  523. channel = message.channel
  524. msg = message.content.replace("<>spam ", "")
  525. if not message.channel.is_private:
  526. msg = msg.replace(channel.mention, "")
  527. if msg == "" or message.content.lower() == "<>spam":
  528. await client.send_message(message.channel, "Invalid Arguments!")
  529. return
  530. if channel == message.channel:
  531. await client.edit_message(message, msg)
  532. limit = 4
  533. else:
  534. limit = 5
  535. counter = 0
  536. while counter < limit:
  537. await client.send_message(channel, msg)
  538. counter += 1
  539.  
  540. elif message.content.lower().startswith("<>mock"):
  541. if not message.channel.is_private:
  542. if len(message.mentions) == 0:
  543. await client.send_message(message.channel, "**UtilitiBot:** Invalid Arguments!")
  544. return
  545. elif len(message.mentions) == 1:
  546. mock = message.mentions[0]
  547. else:
  548. await client.send_message(message.channel, "**UtilitiBot:** You mentioned too many users!")
  549. return
  550. else:
  551. mock = message.channel.user
  552. if mock == client.user:
  553. mock = None
  554. await client.send_message(message.channel, "**UtilitiBot:** You cannot mock yourself!")
  555. return
  556. await client.send_message(message.channel, "**UtilitiBot:** I am now mocking " + mock.mention)
  557.  
  558. elif message.content.lower().startswith("<>unmock"):
  559. omock = mock
  560. mock = None
  561. mbot = True
  562. if omock != None:
  563. await client.send_message(message.channel, "**UtilitiBot:** I stopped mocking " + omock.mention)
  564. omock = None
  565. mbot = False
  566.  
  567. elif message.content.lower().startswith("<>reverse"):
  568. if wrmode and not reverse:
  569. await client.send_message(message.channel, "**UtilitiBot:** Another writing mode is already on!")
  570. elif reverse:
  571. wrmode = False
  572. reverse = False
  573. await client.send_message(message.channel, "**UtilitiBot:** Message reversing off!")
  574. else:
  575. wrmode = True
  576. reverse = True
  577. await client.send_message(message.channel, "**UtilitiBot:** Message reversing on!")
  578.  
  579. elif message.content.lower().startswith("<>upper"):
  580. if wrmode and not upper:
  581. await client.send_message(message.channel, "**UtilitiBot:** Another writing mode is already on!")
  582. elif upper:
  583. wrmode = False
  584. upper = False
  585. await client.send_message(message.channel, "**UtilitiBot:** Upper off!")
  586. else:
  587. wrmode = True
  588. upper = True
  589. await client.send_message(message.channel, "**UtilitiBot:** Upper on!")
  590.  
  591. elif message.content.lower().startswith("<>lower"):
  592. if wrmode and not lower:
  593. await client.send_message(message.channel, "**UtilitiBot:** Another writing mode is already on!")
  594. elif lower:
  595. wrmode = False
  596. lower = False
  597. await client.send_message(message.channel, "**UtilitiBot:** Lower off!")
  598. else:
  599. wrmode = True
  600. lower = True
  601. await client.send_message(message.channel, "**UtilitiBot:** Lower on!")
  602.  
  603. elif message.content.lower().startswith("<>proper"):
  604. if wrmode and not proper:
  605. await client.send_message(message.channel, "**UtilitiBot:** Another writing mode is already on!")
  606. elif proper:
  607. wrmode = False
  608. proper = False
  609. await client.send_message(message.channel, "**UtilitiBot:** Proper off!")
  610. else:
  611. wrmode = True
  612. proper = True
  613. await client.send_message(message.channel, "**UtilitiBot:** Proper on!")
  614.  
  615. elif message.content.lower().startswith("<>title"):
  616. if wrmode and not title:
  617. await client.send_message(message.channel, "**UtilitiBot:** Another writing mode is already on!")
  618. elif title:
  619. wrmode = False
  620. title = False
  621. await client.send_message(message.channel, "**UtilitiBot:** Title off!")
  622. else:
  623. wrmode = True
  624. title = True
  625. await client.send_message(message.channel, "**UtilitiBot:** Title on!")
  626.  
  627. elif message.content.lower().startswith("<>nlwords"):
  628. if wrmode and not nlwords:
  629. await client.send_message(message.channel, "**UtilitiBot:** Another writing mode is already on!")
  630. elif nlwords:
  631. wrmode = False
  632. nlwords = False
  633. await client.send_message(message.channel, "**UtilitiBot:** NLWords off!")
  634. else:
  635. wrmode = True
  636. nlwords = True
  637. await client.send_message(message.channel, "**UtilitiBot:** NLWords on!")
  638.  
  639. elif message.content.lower().startswith("<>nlchars"):
  640. if wrmode and not nlchars:
  641. await client.send_message(message.channel, "**UtilitiBot:** Another writing mode is already on!")
  642. elif nlchars:
  643. wrmode = False
  644. nlchars = False
  645. await client.send_message(message.channel, "**UtilitiBot:** NLChars off!")
  646. else:
  647. wrmode = True
  648. nlchars = True
  649. await client.send_message(message.channel, "**UtilitiBot:** NLChars on!")
  650.  
  651. elif message.content.lower().startswith("<>eval"):
  652. evalc = message.content.replace("<>eval ```", "")
  653. evalc = evalc.replace("```", "")
  654. if evalc == "" or evalc.lower().startswith("<>eval"):
  655. await client.send_message(message.channel, "**UtilitiBot:** Invalid Arguments!")
  656. return
  657. try:
  658. output = eval(evalc)
  659. except Exception as e:
  660. output = e
  661. await client.send_message(message.channel, "**UtilitiBot:** Output```\n"+str(output)+"```")
  662.  
  663. elif message.content.lower().startswith("<>exec"):
  664. execc = message.content.replace("<>exec ```", "")
  665. execc = execc.replace("```", "")
  666. if execc == "" or execc.lower().startswith("<>exec"):
  667. await client.send_message(message.channel, "**UtilitiBot:** Invalid Arguments!")
  668. return
  669. try:
  670. output = exec(execc)
  671. except Exception as e:
  672. output = e
  673. await client.send_message(message.channel, "**UtilitiBot:** Output```\n"+str(output)+"```")
  674.  
  675. elif message.content.lower().startswith("<>version"):
  676. await client.send_message(message.channel, "**UtilitiBot**: Revision "+str(version))
  677.  
  678. elif message.content.lower().startswith("<>uptime"):
  679. stop = time.time()
  680. seconds = stop - start
  681. times = {}
  682. times['days'] = int(((seconds/60)/60)/24)
  683. times['hours'] = int((seconds/60)/60 - (times['days'] * 24))
  684. times['minutes'] = int((seconds/60)%60)
  685. times['seconds'] = int(seconds%60)
  686. wording = {
  687. "days": "days",
  688. "hours": "hours",
  689. "minutes": "minutes",
  690. "seconds": "seconds"
  691. }
  692. if times['days'] == 1:
  693. wording['days'] = "day"
  694. if times['hours'] == 1:
  695. wording['hours'] = "hour"
  696. if times['minutes'] == 1:
  697. wording['minutes'] = "minute"
  698. if times['seconds'] == 1:
  699. wording['seconds'] = "second"
  700. await client.send_message(message.channel, "**UtilitiBot:** I have been online for " + str(times['days']) + " "+wording['days']+", " +
  701. str(times['hours'])+" "+wording['hours']+", "+str(times['minutes'])+" "+wording['minutes']+" and "
  702. + str(times['seconds']) + " " + wording['seconds'])
  703.  
  704. elif message.content.lower().startswith("<>update"):
  705. urllib.request.urlretrieve("https://raw.githubusercontent.com/Hackzzila/UtilitiBot/master/main.py", "main.py")
  706. await client.send_message(message.channel, "**UtilitiBot:** Updated! Now restart me.")
  707.  
  708. elif message.content.lower().startswith("<>hardupdate"):
  709. urllib.request.urlretrieve("https://raw.githubusercontent.com/Hackzzila/UtilitiBot/master/main.py", "main.py")
  710. settings = {}
  711. settings['run'] = False
  712. with open('settings.json', 'w') as fp:
  713. json.dump(settings, fp)
  714. await client.send_message(message.channel, "**UtilitiBot:** Updated and all setting cleared! Now restart me.")
  715.  
  716. elif message.content.lower().startswith("<>mail"):
  717. if settings['mailing']:
  718. settings['mailing'] = False
  719. await client.send_message(message.channel, "**UtilitiBot:** Mailing turned off!")
  720. else:
  721. settings['mailing'] = True
  722. ('UtilitiBot - Setup Email', "UtilitiBot is all setup! If you don't want mail do <>mail in chat.")
  723. await client.send_message(message.channel, "**UtilitiBot:** Mailing turned on!")
  724. with open('settings.json', 'w') as fp:
  725. json.dump(settings, fp)
  726.  
  727. elif message.author == client.user and message.content.lower().startswith("<>shutdown"):
  728. await client.send_message(message.channel,"**UtilitiBot:** Closing, goodbye!")
  729. await client.logout()
  730.  
  731. elif message.author == client.user and message.content.lower().startswith("<>off"):
  732. off = True
  733. await client.send_message(message.channel,"**UtilitiBot:** Turning off!")
  734.  
  735. elif message.author == client.user and message.content.lower().startswith("<>ping"):
  736. await client.send_message(message.channel, "**UtilitiBot:** Pong")
  737.  
  738. elif message.content.lower().startswith("<>reset"):
  739. game = None
  740. idle = False
  741. afk = ""
  742. bot = False
  743. permafk = False
  744. sleep = False
  745. typing = False
  746. phone = False
  747. mock = None
  748. reverse = False
  749. upper = False
  750. lower = False
  751. proper = False
  752. title = False
  753. nlwords = False
  754. wrmode = False
  755. nlchars = False
  756. location = "Nowhere"
  757. activity = "Nothing"
  758. await client.change_status(None, idle)
  759. await client.send_message(message.channel, "**UtilitiBot:** All variables reset!")
  760.  
  761. elif message.content.lower().startswith("<>share"):
  762. await client.send_message(message.channel, "**UtilitiBot:** I am UtilitiBot, a personal Discord bot."+
  763. " To use me go to https://github.com/Hackzzila/UtilitiBot")
  764.  
  765.  
  766.  
  767. if __name__ == "__main__":
  768. if settings['run']:
  769. client.run(settings['email'], settings['password'])
  770. else:
  771. print("Hey, welcome to UtilitiBot, running setup...")
  772. print(" ___ _ _ ")
  773. print("| \(_)___ __ ___ _ _ __| |")
  774. print("| |) | (_-</ _/ _ \ '_/ _` |")
  775. print("|___/|_/__/\__\___/_| \__,_|")
  776. settings['email'] = input("Email: ")
  777. settings['password'] = getpass.getpass('Password:')
  778. settings['run'] = True
  779. settings['mailing'] = True
  780. ('UtilitiBot - Setup Email', "UtilitiBot is all setup! If you don't want mail do <>mail in chat.")
  781. with open('settings.json', 'w') as fp:
  782. json.dump(settings, fp)
  783. print("")
  784. print("")
  785. print("")
  786. client.run(settings['email'], settings['password'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement