Advertisement
Guest User

HelperBot

a guest
Oct 18th, 2019
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.27 KB | None | 0 0
  1. import time
  2. import discord
  3. from discord.ext import commands
  4. from discord import Embed
  5. import random
  6. from profanity import profanity
  7. # import time
  8. from bs4 import BeautifulSoup
  9. import requests
  10. from html.parser import HTMLParser
  11. import math as m
  12. from discord.voice_client import VoiceClient
  13. from discord.ext.commands import Bot
  14. import pprint
  15. import asyncio
  16. from PIL import Image
  17. from random import randint
  18. import urllib.request
  19. import geocoder
  20. import aiohttp
  21. import urllib
  22. import PyPDF2
  23. import openpyxl
  24. import wikipedia
  25. import random
  26. import pyjokes
  27. import json
  28. from discord.ext.commands import Bot
  29.  
  30. prefix = '$'
  31. des = 'I am your personal helper, I can help you with queries you have.'
  32. # Make the client
  33. client = commands.Bot(description=des, command_prefix=prefix)
  34. #Invalid Syntax Error
  35. @client.event
  36. async def on_ready():
  37. print("----------------------")
  38. print("Logged In As")
  39. print("Username: %s" % client.user.name)
  40. print("ID: %s" % client.user.id)
  41. print("----------------------")
  42.  
  43. @commands.command()
  44. async def choose(ctx, *choices: str):
  45. await ctx.send(random.choice(choices))
  46.  
  47. @commands.command()
  48. async def decryptSC(ctx, arg):
  49. enc = arg
  50.  
  51. for displacement in range(127):
  52. for char in enc:
  53. decimal = ord(char)
  54. if decimal - displacement > 0:
  55. await ctx.send(chr(decimal - displacement))
  56. await ctx.send(": " + str(displacement))
  57.  
  58. @commands.command()
  59. async def dadjoke(ctx):
  60. r = requests.get('https://icanhazdadjoke.com', headers={"Accept":"application/json"})
  61. raw_joke = r.json();
  62. joke = raw_joke['joke']
  63. await ctx.send(joke)
  64.  
  65. @commands.command()
  66. async def numbers(ctx, arg):
  67. url = 'http://numbersapi.com/'
  68. apiurl = url + arg
  69. await ctx.send(json.dumps(apiurl))
  70.  
  71. @commands.command()
  72. async def fuckOff(ctx, arg):
  73. response = "```\"Fuck off " + arg + " - Everyone```"
  74. await ctx.send(response)
  75.  
  76. @commands.command()
  77. async def randomPerson(ctx):
  78. response = requests.get("https://mightyalex-ui-faces-v1.p.rapidapi.com/?limit=5",
  79. headers={
  80. "X-RapidAPI-Host": "mightyalex-ui-faces-v1.p.rapidapi.com",
  81. "X-RapidAPI-Key": "5e7a3747e1msh68ee79a8afc00cep1c6704jsn416df28913f7",
  82. "X-API-KEY": "9497433be95c260dcf6295af47172c"
  83. }
  84. )
  85. print(response.text)
  86.  
  87. @commands.command()
  88. async def Cat(ctx):
  89. api_address='https://aws.random.cat/meow'
  90. json_data = requests.get(api_address).json()
  91. katten = json_data["file"]
  92. await ctx.send(katten)
  93.  
  94. @commands.command()
  95. async def Dog(ctx):
  96. api_address='https://random.dog/woof.json'
  97. json_data = requests.get(api_address).json()
  98. katten = json_data["url"]
  99. await ctx.send(katten)
  100.  
  101. @commands.command()
  102. async def Fox(ctx):
  103. api_address='https://randomfox.ca/floof/'
  104. json_data = requests.get(api_address).json()
  105. katten = json_data["link"]
  106. await ctx.send(katten)
  107.  
  108. @commands.command()
  109. async def joke(ctx):
  110. await ctx.send(pyjokes.get_joke())
  111.  
  112. @commands.command()
  113. async def genderName(ctx, arg):
  114. url = 'https://api.genderize.io/?name='
  115. apiurl = url + arg
  116. ressponse = requests.get(apiurl).json()
  117. Recwest = ressponse["gender"]
  118. await ctx.send(Recwest)
  119. await ctx.send("The probability of this is: ", ressponse["probability"])
  120.  
  121. @commands.command()
  122. async def defineUD(ctx, arg):
  123. UD_DEFINE_URL = 'https://api.urbandictionary.com/v0/define?term={}'.format(arg)
  124. ressponse = requests.get(UD_DEFINE_URL).json()
  125. Recwest = ressponse["list"][0]["definition"]
  126. await ctx.send(Recwest)
  127.  
  128. @commands.command()
  129. async def checkUrl(ctx, arg):
  130. url = 'https://www.virustotal.com/vtapi/v2/url/report'
  131. params = {'apikey': '5f697b730cfd317a7e2e3663e0b65f5ceb5ed90984e22567d142c0cfcfa9b2f2', 'resource':arg}
  132. ressponse = requests.get(url, params=params).json()
  133. Recwest = ressponse["positives"]
  134. if Recwest == 0:
  135. await ctx.send("```This website is to be trusted.```")
  136. else:
  137. await ctx.send("This site has {} found issues. I would not trust it".format(str(Recwest)))
  138.  
  139. with open("fullrequests.txt", "w+") as f:
  140. f.write(str(ressponse))
  141. await ctx.send(file=discord.File(f, 'fullrequests.txt'))
  142.  
  143. @commands.command()
  144. async def helpme(ctx):
  145. await ctx.send("""```Here are some commands you can try:
  146. 1. $weather
  147. 2. $helpme
  148. 3. $lookup
  149. 4. $joke
  150. 5. $decryptSC, for decrypting Shift Cypher
  151. 6. $repeat x
  152. 8. $choose x x
  153. 9. $Cat
  154. 10. $Dog
  155. 11. $Fox
  156. 12. $genderName x
  157. 13. $checkUrl x
  158. 14. $defineUD x
  159. 15. $advice
  160. 16. $fuckOff x
  161. 17. $randomPerson
  162. 18. $dadjoke
  163. That's all I have for now, but I am still in béta testing```""")
  164.  
  165. @commands.command()
  166. async def repeat(ctx, times: int, content='repeating...'):
  167. """Repeats a message multiple times."""
  168. for i in range(times):
  169. await ctx.send(content)
  170.  
  171. @commands.command()
  172. async def lookup(ctx, arg):
  173. thingy35 = wikipedia.page(arg)
  174. thingy34 = str(wikipedia.page(arg).content).split(".")[0]
  175. await ctx.send('Here is what came back from a search: \n\n {0}. \n \n Here is the link: {1}'.format(thingy34, thingy35.url))
  176.  
  177. @commands.command()
  178. async def advice(ctx):
  179. url = 'https://api.adviceslip.com/advice'
  180. ressponse = requests.get(url).json()
  181. Recwest = ressponse["slip"]
  182. await ctx.send("Advice: {}".format(Recwest))
  183.  
  184.  
  185. @commands.command()
  186. async def weather(ctx):
  187. g = geocoder.ip('me')
  188. rg = geocoder.yandex(g.latlng, method='reverse')
  189. data = rg.json
  190. add_format = data['city']
  191. api_address='http://api.openweathermap.org/data/2.5/weather?appid=34f0968e5b315c84a6a6cbbe4ec9f1bf&q='
  192. city = add_format
  193. url = api_address + city
  194. json_data = requests.get(url).json()
  195. realtime_weather = json_data["weather"][0]["description"]
  196. await ctx.send("```Today we are going to have some {}```".format(realtime_weather))
  197.  
  198. client.add_command(weather)
  199. client.add_command(helpme)
  200. client.add_command(lookup)
  201. client.add_command(joke)
  202. client.add_command(choose)
  203. client.add_command(repeat)
  204. client.add_command(decryptSC)
  205. client.add_command(Cat)
  206. client.add_command(Dog)
  207. client.add_command(Fox)
  208. client.add_command(checkUrl)
  209. client.add_command(genderName)
  210. client.add_command(defineUD)
  211. client.add_command(advice)
  212. client.add_command(dadjoke)
  213. client.add_command(numbers)
  214. client.add_command(fuckOff)
  215. client.add_command(randomPerson)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement