KiTTY, un bot Discord qui est un petit chat :) Il est basé sur une ancienne version du bot Red, sous Python 3.6 et qui a des fonctionnalités bien sympatiques !
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
Den här utvecklingskatalogen är arkiverad. Du kan se filer och klona katalogen, men inte öppna ärenden eller genomföra push- eller pull-förfrågningar.

87 rader
3.5 KiB

  1. import asyncio
  2. import discord
  3. from discord.ext import commands
  4. import aiohttp
  5. import asyncio
  6. import random
  7. import os
  8. import speedtest
  9. import requests
  10. from bs4 import BeautifulSoup
  11. class text:
  12. """My custom cog that does stuff!"""
  13. def __init__(self, bot):
  14. self.bot = bot
  15. @commands.command()
  16. async def invite(self):
  17. """need nekos api for python"""
  18. embed=discord.Embed(title="Invite a cat !", url='https://bit.ly/2LoyicC', color=0xff0000)
  19. embed.add_field(name="Hey! Thanks for inviting me over! Click on 'Invite a cat' to start the adventure!", value=":cat:", inline=False)
  20. await self.bot.say(embed=embed)
  21. @commands.command()
  22. async def speedtest(self):
  23. loader = await self.bot.say("Testing the most efficient server for connection testing !")
  24. s = speedtest.Speedtest()
  25. s.get_best_server()
  26. await self.bot.edit_message(loader, "I measure the download speed ! :cat:")
  27. s.download()
  28. await self.bot.edit_message(loader, "I measure the upload speed ! :cat:")
  29. s.upload()
  30. await self.bot.edit_message(loader, "Calclulating... :cat:")
  31. url = s.results.share()
  32. await self.bot.delete_message(loader)
  33. await self.bot.say(url)
  34. @commands.command()
  35. async def mraw(self):
  36. """Meow !"""
  37. mraws = await self.bot.say(':regional_indicator_m: :regional_indicator_r: :regional_indicator_a: :regional_indicator_w:')
  38. @commands.command()
  39. async def kop1(self):
  40. """KOP1 !"""
  41. await self.bot.say(":regional_indicator_k: :regional_indicator_o: :regional_indicator_p: :one:")
  42. @commands.command()
  43. async def vdm(self):
  44. """The French FML website"""
  45. source = requests.Session().get("https://www.viedemerde.fr/aleatoire", headers={"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0"}).content
  46. soup = BeautifulSoup(source, "html.parser")
  47. vdm = list(random.choice(soup.find_all("p", class_="block hidden-xs")).children)[1].string
  48. await self.bot.say("```" + vdm + "```")
  49. @commands.command()
  50. async def dtc(self):
  51. source = requests.get("https://www.danstonchat.com/random0.html").content
  52. soup = BeautifulSoup(source, "html.parser")
  53. lst = soup.find_all("div", class_="addthis_inline_share_toolbox")
  54. await self.bot.say("```" + random.choice(lst)["data-description"] + "```")
  55. @commands.command()
  56. async def fml(self):
  57. source = requests.Session().get("http://www.fmylife.com/random", headers={"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0"}).content
  58. soup = BeautifulSoup(source, "html.parser")
  59. fml = list(random.choice(soup.find_all("p", class_="block hidden-xs")).children)[1].string
  60. await self.bot.say("```" + fml + "```")
  61. @commands.command()
  62. async def katology(self):
  63. katology = "Tu connais katology ? Un blog francais traitant de l'actualité technologique, avec un aspect communautaire !\n http://katolo.gy !"
  64. await self.bot.say(katology)
  65. @client.command()
  66. async def bitcoin():
  67. url = 'https://api.coindesk.com/v1/bpi/currentprice/BTC.json'
  68. async with aiohttp.ClientSession() as session: # Async HTTP request
  69. raw_response = await session.get(url)
  70. response = await raw_response.text()
  71. response = json.loads(response)
  72. await client.say("Bitcoin price is: " + response['bpi']['EUR']['rate'] + " €")
  73. def setup(bot):
  74. bot.add_cog(text(bot))