/bots/DM/discord_insult_spam_dm.py

https://github.com/Merubokkusu/discord-spam-bots · Python · 114 lines · 97 code · 7 blank · 10 comment · 29 complexity · 23e8553fc49f68c70889e31c4351c04f MD5 · raw file

  1. #
  2. # discord_insult_spam_dm.py
  3. # @author Merubokkusu
  4. # @created Fri Jan 04 2019 00:58:07 GMT-0500 (Eastern Standard Time)
  5. # @copyright 2018 - 2019
  6. # @license CC BY-NC-ND 3.0 US | https://creativecommons.org/licenses/by-nc-nd/3.0/us/
  7. # @website https://github.com/Merubokkusu/discord-spam-bots/
  8. # @email liam@merubokkusu.com
  9. # @last-modified Mon Mar 18 2019 15:02:26 GMT-0400 (Eastern Daylight Time)
  10. #
  11. import urllib.request
  12. import discord
  13. import asyncio
  14. import sys
  15. import subprocess
  16. import aiohttp
  17. import os
  18. import random
  19. from bs4 import BeautifulSoup
  20. sys.path.append("./.")
  21. from config import *
  22. if(os.path.exists("proxies.txt")):
  23. conn = aiohttp.ProxyConnector(proxy="http://"+sys.argv[2])
  24. client = discord.Client(connector=conn)
  25. else:
  26. client = discord.Client()
  27. token = sys.argv[1]
  28. UserList = []
  29. @client.event
  30. async def on_ready():
  31. for server in client.servers:
  32. if ScanAllServers == False:
  33. if(server.id == DiscordServer):
  34. UserList = list(server.members)
  35. else:
  36. UserList = list(server.members)
  37. if HeavyScrape == False:
  38. for member in UserList:
  39. userNames = open('dm_spam_insult.txt');
  40. text = userNames.read().strip().split()
  41. if member.id in text:
  42. print(member.name + ' was already messaged')
  43. else:
  44. try:
  45. print('Sent message to '+ member.name)
  46. file = open('dm_spam_insult.txt','a')
  47. file.writelines(member.id + '\n')
  48. file.close()
  49. html = urllib.request.urlopen("https://insult.mattbas.org/api/insult.html").read()
  50. soup = BeautifulSoup(html,"html.parser")
  51. insult_text = soup.find('h1')
  52. print(insult_text.text)
  53. await client.send_message(member, insult_text.text)
  54. for remaining in range(31, 0, -1):# Changes how fast the messages are sent. (Discord has a 10 minute cool down for every 10 users)
  55. sys.stdout.write("\r")
  56. sys.stdout.write("{:2d} seconds remaining.".format(remaining))
  57. sys.stdout.flush()
  58. await asyncio.sleep(1)
  59. sys.stdout.write("\rComplete! \n")
  60. except Exception:
  61. print('Something went wrong (;3;) relaunching...')
  62. else:
  63. while not client.is_closed:
  64. member = random.choice(UserList)
  65. if(member.id != client.user.id):
  66. userNames = open('dm_spam_insult.txt')
  67. text = userNames.read().strip().split()
  68. if member.id in text:
  69. print(member.name + ' was already messaged')
  70. else:
  71. try:
  72. print('Sent message to '+ member.name)
  73. file = open('dm_spam_insult.txt','a')
  74. file.writelines(member.id + '\n')
  75. file.close()
  76. html = urllib.request.urlopen("https://insult.mattbas.org/api/insult.html").read()
  77. soup = BeautifulSoup(html,"html.parser")
  78. insult_text = soup.find('h1')
  79. print(insult_text.text)
  80. await client.send_message(member, insult_text.text)
  81. for remaining in range(31, 0, -1):# Changes how fast the messages are sent. (Discord has a 10 minute cool down for every 10 users)
  82. sys.stdout.write("\r")
  83. sys.stdout.write("{:2d} seconds remaining.".format(remaining))
  84. sys.stdout.flush()
  85. await asyncio.sleep(1)
  86. sys.stdout.write("\rComplete! \n")
  87. except Exception:
  88. print('Something went wrong (;3;) relaunching...')
  89. if ':' in token:
  90. enp = token.split(':')
  91. if autojoinServer == True:
  92. if sys.platform == "win32":
  93. p = subprocess.Popen(['python','bots/misc/joinServer.py',enp[0],enp[1],inviteLink,useBrowser],shell=True)
  94. p.wait()
  95. else:
  96. p = subprocess.Popen(['python','bots\misc\joinServer.py',enp[0],enp[1],inviteLink,useBrowser],shell=False)
  97. p.wait()
  98. client.run(enp[0],enp[1], bot=False)
  99. else:
  100. if autojoinServer == True:
  101. if sys.platform == "win32":
  102. p = subprocess.Popen([pythonCommand,'bots\misc\joinServer2.0.py',token,inviteLink,sys.argv[3]],shell=True)
  103. p.wait()
  104. else:
  105. p = subprocess.Popen([pythonCommand,'bots\misc\joinServer2.0.py',token,inviteLink,sys.argv[3]],shell=False)
  106. p.wait()
  107. client.run(token, bot=False)