From fc88e94a48a91bf728fd169a6b9f2d84029d9a9d Mon Sep 17 00:00:00 2001 From: "Mohammed Uddin (uddinm47)" Date: Sat, 28 Nov 2020 01:26:07 +0000 Subject: [PATCH] Update Chatbot.py --- Chatbot.py | 194 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 194 insertions(+) diff --git a/Chatbot.py b/Chatbot.py index 9712ca7..82b6661 100644 --- a/Chatbot.py +++ b/Chatbot.py @@ -10,6 +10,13 @@ import urllib.parse from steam.webapi import WebAPI from dotenv import load_dotenv #only used so we can have the token outside of the source code from steam.steamid import * + #================== Shafee uddin Stuff ===================# + +import reddit +from steamwebapi import ISteamUser, IPlayerService, ISteamUserStats +import pylanguagetool + + #================== Shafee uddin Stuff ===================# tempIDArraySteam = [] #These two lists are intended to be replaced by a relational database to store the users SteamID and DiscordID tempIDArrayDiscord = []#============================================================================================================ @@ -590,6 +597,193 @@ async def on_ready(): client.loop.create_task(getMembers()) client.loop.create_task(deployNotifs()) + #================== Shafee uddin Stuff ===================# + +@client.command() +async def load(ctx, extention): + client.load_extention(f'cogs.{extention}') + +@client.command() +async def unload(ctx, extention): + client.unload_extention(f'cogs.{extention}') + +for filename in os.listdir('./cogs'): + if filename.endswith('.py'): + client.load_extention(f'cogs.{filename[:-3]}') + +@client.event +async def on_ready(): + await client.chage_presence(status=discord.status.idle, activity=discord.game('Hello there')) + print('Bot is ready.') + +@client.event +async def on_command_error(ctx, error): + if isinstance(error, commands.ComamandNotFound): + await ctx.send("please check for missing requirements") + +@client.command() +async def clear(ctx, amount=5): + await ctx.channel.purge(limit=amount) + +@client.event +async def on_member_join(member): + print(F'{member} has joined the server.') + +@client.event +async def on_member_remove(member): + print(F'{member} has left the sever.') + +@client.command() +@is_owner() +async def kill(self, ctx): + try: + self.bot.clear() + await self.bot.close() + except Exception as e: + await ctx.send("Couldn't kill the bot for some reason, maybe this will help:\n" + + F"{type(e)._name_} - {e}") + +@client.command() +@command.cooldown(1, standard_cooldown, command.BucketType.member) +async def floor(self, ctx): + """Get a random image of a dog or cat.""" + + url = random.choice(["https://some-random-api.ml/img/dog" , "https://some-random-api.ml/img/cat"]) + async with request("GET", url, headers={}) as r: + if r.status !=200: + return await ctx.send(F"The API returned a {r.status} status.") + data = await r.json() + image = data["link"] + + embed = utils.embed_message() + embed.set_image(url=image) + await ctx.send(embed=embed) + +@client.command() +async def hello(ctx): + await ctx.send(F'Sup! {round(client.latency * 1000)}ms') + +@client.command() +async def sosalty(self, ctx): + """"gives you your sosalty number.""" + # random number between 0 and 100 + num1 = random.randrange(100) + print('your saltiness rank is:', num1) + await ctx.send(F'question: {question}\nAnswer: {random.choice(responses)}') + +@client.command(aliases=['Snarky comment']) +async def Snarky(ctx, *, question): + responses = ['wow u noob.' + 'cmon grow up.' + 'playing games for years and still bad at the game.' + 'ngl games dont make you violent, lag does.' + ''] + await ctx.send(F'question: {question}/nAnswer: {random.choice(responses)}') + +@client.command(aliases=['8ball']) +async def _8ball(ctx, *, question): + responses = ['it is certain.', + 'it is decidedly so.', + 'without a doubt.', + 'yh yh.', + 'keep trying buddy.', + 'most likely.', + 'major cap.', + 'my sources say no.', + 'very doubtful.', + 'keep trying you will never succeed', + await ctx.send(F'question: {question}\nAnswer: {random.choice(responses)}') + +# Mention the language keyword +tool = language_check.LanguageTool('en-UK') +i = 0 + +# Path of file which needs to be checked +with open(r'transcript1.txt', 'r') as fin: + + for line in fin: + matches = tool.check(line) + i = i + len(matches) + pass + +# prints total mistakes which are found +# from the document +print("No. of mistakes found in document is ", i) +print() + +# prints mistake one by one +for mistake in matches: + print(mistake) + print() + +api = ISteamUser('https://decapi.me/steam/hours?id=STEAM_ID_HERE&appid=252950') +steamid = api.resolve_vanity_url('profile url') ['response']['steamid'] +summary = api.get_player_summaries(steamid) ['response']['players'][0] +print(summary) + #####Gives basic info on discord##### +@commands.command() +@commands.guild_only() +async def whois(self, ctx, user: discord.member = none): + """Gives you basic infomation on somone""" + + user = user or ctx.author + user_id = user.id + user_roles = [] + created_at_str = f"{user.created_at.day}/{user.created_at.month}/{user.created_at.year} {user.created_at.hour}:{user.created_at.minute}:{user.created_at.second} + joined_at_str = f"(user.joined_at.day)/{user.created_at.month}/{user.created_at.year} {user.created_at.hour}:{user.created_at.minute}:{user.created_at.second} + #####End Comment##### + + ##########SHOWS STEAM PROFILE OF USER########## +@commands.command() +async def steam(self, ctx, profile: str): + """Gets a users steam profile and puts it in an embed.""" + + complete_api_url = f"https://api.alexflipnote.dev/steam/user/{profile}" + async with request("GET", complete_api_url, headers={}) as r: + if r.status != 200: + return await ctx.send("I could not find that profile.") + data = await r.json() + url = data["profile"]["url"] + background = data["profile"]["background"] + avatar = data["avatars"]["avatarfull"] + steam_id = data["id"]["steamid32"] + + fields = [ + ["Username", data["profile"]["username"], True], + ["Real Name", data["profile"]["realname"], True], + ["Location", data["profile"]["location"], True], + ["State", data["profile"]["state"], True], + ["Date Created", data["profile"]["timecreated"], True], + ["Vac Banned", data["profile"]["vacbanned"], True], + ["Summary", "```\n" + data["profile"]["summary"] + "```", False], + ] + + embed = utils.embed_message(title=f"Profile of {profile}", + footer_text=f"Steam ID: {steam_id}", + thumbnail=avatar, + url=url) + embed.set_image(url=background) + + [embed.add_field(name=n, value=str(v), inline=il) for n, v, il in fields] + + await ctx.send(embed=embed) + ##########END OF STEAM CODE########## + +@commands.command() +async def Poll(self, ctx, *,query): + """Starts a poll with a given request""" + + embed = utils.embed_message(message=str(request), + footer_text="") + embed.set_author(name=ctx.author, icon_url=ctx.author.avatar_url) + msg = await ctx.send(embed=embed) + + await msg.add_reaction("✅") + await msg.add_reaction("❌") + await msg.add_reaction("🤷‍♀️") + + #================== Shafee Uddin Stuff End ===================# + client.run(TOKEN) #this is the token of the discord bot. You can create your own bot and put that token in here or the .env file to run the code #================================