From 7331dc552acc94d6839571083c36899d5d6e41eb Mon Sep 17 00:00:00 2001 From: Rohan Date: Fri, 23 Mar 2018 18:43:48 +0530 Subject: [PATCH 01/29] added welcome msg --- bot/cogs/logging.py | 1 + bot/cogs/snakes.py | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/bot/cogs/logging.py b/bot/cogs/logging.py index 5f5cd85c..62566663 100644 --- a/bot/cogs/logging.py +++ b/bot/cogs/logging.py @@ -1,6 +1,7 @@ # coding=utf-8 import logging + from discord.ext.commands import AutoShardedBot log = logging.getLogger(__name__) diff --git a/bot/cogs/snakes.py b/bot/cogs/snakes.py index c9ed8042..1cf91bf8 100644 --- a/bot/cogs/snakes.py +++ b/bot/cogs/snakes.py @@ -1,6 +1,9 @@ # coding=utf-8 + import logging from typing import Any, Dict +import discord + from discord.ext.commands import AutoShardedBot, Context, command @@ -16,6 +19,7 @@ def __init__(self, bot: AutoShardedBot): self.bot = bot async def get_snek(self, name: str = None) -> Dict[str, Any]: + """ Go online and fetch information about a snake @@ -31,6 +35,8 @@ async def get_snek(self, name: str = None) -> Dict[str, Any]: @command() async def get(self, ctx: Context, name: str = None): + + await ctx.send("hola") """ Go online and fetch information about a snake @@ -42,7 +48,9 @@ async def get(self, ctx: Context, name: str = None): """ # Any additional commands can be placed here. Be creative, but keep it to a reasonable amount! - + @command(name="welcome") + async def welcome(self,ctx: Context): + return await ctx.send("Welcome! I dont what to say ,but ill say Hello !") def setup(bot): bot.add_cog(Snakes(bot)) From 387b504660e10228286db07ae0481bb1e58f62fc Mon Sep 17 00:00:00 2001 From: HarjotR <37369440+HarjotR@users.noreply.github.com> Date: Fri, 23 Mar 2018 18:59:05 +0530 Subject: [PATCH 02/29] Add files via upload --- bot/cogs/snakes.py | 110 ++++++++++++++++++++++----------------------- 1 file changed, 53 insertions(+), 57 deletions(-) diff --git a/bot/cogs/snakes.py b/bot/cogs/snakes.py index 1cf91bf8..ae41d559 100644 --- a/bot/cogs/snakes.py +++ b/bot/cogs/snakes.py @@ -1,57 +1,53 @@ -# coding=utf-8 - -import logging -from typing import Any, Dict -import discord - - -from discord.ext.commands import AutoShardedBot, Context, command - -log = logging.getLogger(__name__) - - -class Snakes: - """ - Snake-related commands - """ - - def __init__(self, bot: AutoShardedBot): - self.bot = bot - - async def get_snek(self, name: str = None) -> Dict[str, Any]: - - """ - Go online and fetch information about a snake - - The information includes the name of the snake, a picture of the snake, and various other pieces of info. - What information you get for the snake is up to you. Be creative! - - If "python" is given as the snake name, you should return information about the programming language, but with - all the information you'd provide for a real snake. Try to have some fun with this! - - :param name: Optional, the name of the snake to get information for - omit for a random snake - :return: A dict containing information on a snake - """ - - @command() - async def get(self, ctx: Context, name: str = None): - - await ctx.send("hola") - """ - Go online and fetch information about a snake - - This should make use of your `get_snek` method, using it to get information about a snake. This information - should be sent back to Discord in an embed. - - :param ctx: Context object passed from discord.py - :param name: Optional, the name of the snake to get information for - omit for a random snake - """ - - # Any additional commands can be placed here. Be creative, but keep it to a reasonable amount! - @command(name="welcome") - async def welcome(self,ctx: Context): - return await ctx.send("Welcome! I dont what to say ,but ill say Hello !") - -def setup(bot): - bot.add_cog(Snakes(bot)) - log.info("Cog loaded: Snakes") +# coding=utf-8 +import logging +from typing import Any, Dict + +from discord.ext.commands import AutoShardedBot, Context, command + +log = logging.getLogger(__name__) + +@command(name="welcome") +async def welcome(self,ctx: Context): + return await ctx.send("Welcome! I dont what to say ,but ill say Hello !") + + +class Snakes: + """ + Snake-related commands + """ + + def __init__(self, bot: AutoShardedBot): + self.bot = bot + + async def get_snek(self, name: str = None) -> Dict[str, Any]: + """ + Go online and fetch information about a snake + + The information includes the name of the snake, a picture of the snake, and various other pieces of info. + What information you get for the snake is up to you. Be creative! + + If "python" is given as the snake name, you should return information about the programming language, but with + all the information you'd provide for a real snake. Try to have some fun with this! + + :param name: Optional, the name of the snake to get information for - omit for a random snake + :return: A dict containing information on a snake + """ + + @command() + async def get(self, ctx: Context, name: str = None): + """ + Go online and fetch information about a snake + + This should make use of your `get_snek` method, using it to get information about a snake. This information + should be sent back to Discord in an embed. + + :param ctx: Context object passed from discord.py + :param name: Optional, the name of the snake to get information for - omit for a random snake + """ + + # Any additional commands can be placed here. Be creative, but keep it to a reasonable amount! + + +def setup(bot): + bot.add_cog(Snakes(bot)) + log.info("Cog loaded: Snakes") From bcf2211d585c50bc0312192dbcab30483f1f2b02 Mon Sep 17 00:00:00 2001 From: HarjotR <37369440+HarjotR@users.noreply.github.com> Date: Fri, 23 Mar 2018 19:02:23 +0530 Subject: [PATCH 03/29] Update snakes.py --- bot/cogs/snakes.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/bot/cogs/snakes.py b/bot/cogs/snakes.py index ae41d559..6d8d4793 100644 --- a/bot/cogs/snakes.py +++ b/bot/cogs/snakes.py @@ -6,11 +6,6 @@ log = logging.getLogger(__name__) -@command(name="welcome") -async def welcome(self,ctx: Context): - return await ctx.send("Welcome! I dont what to say ,but ill say Hello !") - - class Snakes: """ Snake-related commands From 82cfd2f0e154ca6170496bfe4f195507700cf56c Mon Sep 17 00:00:00 2001 From: Rohan Date: Fri, 23 Mar 2018 19:51:13 +0530 Subject: [PATCH 04/29] added more cmds --- bot/cogs/snakes.py | 51 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 9 deletions(-) diff --git a/bot/cogs/snakes.py b/bot/cogs/snakes.py index 6d8d4793..226ae4eb 100644 --- a/bot/cogs/snakes.py +++ b/bot/cogs/snakes.py @@ -1,7 +1,8 @@ # coding=utf-8 import logging from typing import Any, Dict - +import discord +import random from discord.ext.commands import AutoShardedBot, Context, command log = logging.getLogger(__name__) @@ -28,21 +29,53 @@ async def get_snek(self, name: str = None) -> Dict[str, Any]: :return: A dict containing information on a snake """ - @command() + @command(name="get") async def get(self, ctx: Context, name: str = None): - """ - Go online and fetch information about a snake + if name=="cobra": + msg=""" A Cobra is a species of venomous snake in the + family Elapidae, endemic to forests from India + through Southeast Asia. This serpent is the + world's longest venomous snake.""" + return await ctx.send(msg) + """ + Go online and fetch information about a snake - This should make use of your `get_snek` method, using it to get information about a snake. This information - should be sent back to Discord in an embed. + This should make use of your `get_snek` method, using it to get information about a snake. This information + should be sent back to Discord in an embed. - :param ctx: Context object passed from discord.py - :param name: Optional, the name of the snake to get information for - omit for a random snake - """ + :param ctx: Context object passed from discord.py + :param name: Optional, the name of the snake to get information for - omit for a random snake + """ # Any additional commands can be placed here. Be creative, but keep it to a reasonable amount! + @command(name="snakerandom") + async def SnakeRandom(self, ctx: Context): + #snakes=['Cobra','Python','Anaconda','Black Mamba','Rattle Snake'] + randsnake=random.choice(['cobra','python','black mamba']) + print(randsnake) + embed = discord.Embed( + title="print_stuff", + description="You get a "+randsnake, + color=0x00ff00, + ) + + if randsnake=="python": + + return await ctx.send("Your a lucky dude !", embed=embed) + elif randsnake=="cobra": + return await ctx.send("Good old cobra !", embed=embed) + elif randsnake.startswith("blac"): + return await ctx.send("Shiny liitle fella !", embed=embed) + + + + + + + + def setup(bot): bot.add_cog(Snakes(bot)) log.info("Cog loaded: Snakes") From ca5cd023b39a1b2760fcb0df37d4e4068bd99747 Mon Sep 17 00:00:00 2001 From: Rohan Date: Fri, 23 Mar 2018 20:09:28 +0530 Subject: [PATCH 05/29] modified snakerandom --- bot/cogs/snakes.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/bot/cogs/snakes.py b/bot/cogs/snakes.py index 226ae4eb..47986c2c 100644 --- a/bot/cogs/snakes.py +++ b/bot/cogs/snakes.py @@ -3,6 +3,7 @@ from typing import Any, Dict import discord import random +import time from discord.ext.commands import AutoShardedBot, Context, command log = logging.getLogger(__name__) @@ -51,23 +52,26 @@ async def get(self, ctx: Context, name: str = None): @command(name="snakerandom") - async def SnakeRandom(self, ctx: Context): + async def SnakeRandom(self, ctx: Context , name: str= None): #snakes=['Cobra','Python','Anaconda','Black Mamba','Rattle Snake'] randsnake=random.choice(['cobra','python','black mamba']) print(randsnake) embed = discord.Embed( - title="print_stuff", - description="You get a "+randsnake, + title="Snake Random !", + description="lets see what snake you got !", color=0x00ff00, ) + embed.add_field(name="Result", value="You got yourself a "+randsnake, inline=False) + embed.add_field(name="Expectation", value=f"@{ctx.author} expected {name}", inline=False) + if randsnake=="python": - return await ctx.send("Your a lucky dude !", embed=embed) + return await ctx.send("Your a lucky dude !",embed=embed) elif randsnake=="cobra": - return await ctx.send("Good old cobra !", embed=embed) + return await ctx.send("Good old cobra !",embed=embed) elif randsnake.startswith("blac"): - return await ctx.send("Shiny liitle fella !", embed=embed) + return await ctx.send("Shiny liitle fella !",embed=embed) From 6884ba5a08042a316372d06ca4704fdb9ab70f87 Mon Sep 17 00:00:00 2001 From: Rohan Date: Sat, 24 Mar 2018 16:10:32 +0530 Subject: [PATCH 06/29] edited get --- bot/cogs/snakes.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/bot/cogs/snakes.py b/bot/cogs/snakes.py index 47986c2c..35100bf7 100644 --- a/bot/cogs/snakes.py +++ b/bot/cogs/snakes.py @@ -17,7 +17,8 @@ def __init__(self, bot: AutoShardedBot): self.bot = bot async def get_snek(self, name: str = None) -> Dict[str, Any]: - """ + + """ Go online and fetch information about a snake The information includes the name of the snake, a picture of the snake, and various other pieces of info. @@ -28,16 +29,21 @@ async def get_snek(self, name: str = None) -> Dict[str, Any]: :param name: Optional, the name of the snake to get information for - omit for a random snake :return: A dict containing information on a snake - """ + """ @command(name="get") async def get(self, ctx: Context, name: str = None): - if name=="cobra": - msg=""" A Cobra is a species of venomous snake in the - family Elapidae, endemic to forests from India - through Southeast Asia. This serpent is the - world's longest venomous snake.""" - return await ctx.send(msg) + name1 = name.lower() + cobra = 'Cobra is the common name of various elapid snakes, most of which belonging to the genus Naja.' + pythonidae = 'The Pythonidae, commonly known simply as pythons,\n from the Greek word python (πυθων), are\n a family of nonvenomous snakes found in Africa, Asia, and Australia.\n Among its members are some of the largest snakes in the world.\n Eight genera and 31 species are currently recognized.' + + + embed = discord.Embed( + title=name1, + description=cobra, + color=0x00ff00, + ) + return await ctx.send(embed=embed) """ Go online and fetch information about a snake From f66327c4e075f8996a2287871b9bb726251c85aa Mon Sep 17 00:00:00 2001 From: Rohan Date: Sat, 24 Mar 2018 17:01:48 +0530 Subject: [PATCH 07/29] adding random name --- bot/cogs/snakes.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bot/cogs/snakes.py b/bot/cogs/snakes.py index 35100bf7..7638cfa7 100644 --- a/bot/cogs/snakes.py +++ b/bot/cogs/snakes.py @@ -17,7 +17,7 @@ def __init__(self, bot: AutoShardedBot): self.bot = bot async def get_snek(self, name: str = None) -> Dict[str, Any]: - + """ Go online and fetch information about a snake @@ -80,6 +80,15 @@ async def SnakeRandom(self, ctx: Context , name: str= None): return await ctx.send("Shiny liitle fella !",embed=embed) + @command(name="randname") + async def RandName(self,ctx:Context , name: str=None): + p = len(name) + front_back=random.randint(1,3) + if front_back==1:#so the users name in substring from the front and snake random substring from back + #do something + elif front_back==2:#so the users name in substring from the back and snake random substring from front + #do something + From d941e7e31209bb928afc3c0f730e7e6d06f1d16f Mon Sep 17 00:00:00 2001 From: Rohan Date: Sat, 24 Mar 2018 17:19:28 +0530 Subject: [PATCH 08/29] randname --- bot/cogs/snakes.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/bot/cogs/snakes.py b/bot/cogs/snakes.py index 7638cfa7..7307f09a 100644 --- a/bot/cogs/snakes.py +++ b/bot/cogs/snakes.py @@ -82,14 +82,23 @@ async def SnakeRandom(self, ctx: Context , name: str= None): @command(name="randname") async def RandName(self,ctx:Context , name: str=None): + snakes=['Cobra','Python','Anaconda','Viper','Mamba'] + snk=random.choice[snakes] + snLen=len(snk) p = len(name) + result="" front_back=random.randint(1,3) if front_back==1:#so the users name in substring from the front and snake random substring from back - #do something - elif front_back==2:#so the users name in substring from the back and snake random substring from front - #do something - + ran = random.randint(0,p-2) + ranSnk=random.randint(2,snLen) + result=name[ :ran] + snk[ranSnk: ] + return await ctx.send(result) + elif front_back==2:#so the users name in substring from the back and snake random substring from front + ran=random.randint(2,p) + ranSnk=random.randint(0,snLen-2) + result = name[ran: ] + snk[ :ranSnk] + return await ctx.send(result) From 476836c58476754c70726341900734f26514b06f Mon Sep 17 00:00:00 2001 From: Rohan Date: Sat, 24 Mar 2018 18:01:30 +0530 Subject: [PATCH 09/29] make get() simpler --- bot/cogs/snakes.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/bot/cogs/snakes.py b/bot/cogs/snakes.py index 7307f09a..4a482820 100644 --- a/bot/cogs/snakes.py +++ b/bot/cogs/snakes.py @@ -37,12 +37,18 @@ async def get(self, ctx: Context, name: str = None): cobra = 'Cobra is the common name of various elapid snakes, most of which belonging to the genus Naja.' pythonidae = 'The Pythonidae, commonly known simply as pythons,\n from the Greek word python (πυθων), are\n a family of nonvenomous snakes found in Africa, Asia, and Australia.\n Among its members are some of the largest snakes in the world.\n Eight genera and 31 species are currently recognized.' - - embed = discord.Embed( - title=name1, - description=cobra, - color=0x00ff00, - ) + first_line={ + 'cobra':cobra, + 'python':pythonidae, + } + + for key,value in first_line.items(): + if key==name.lower(): + embed = discord.Embed( + title=name1, + description=value, + color=0x00ff00, + ) return await ctx.send(embed=embed) """ Go online and fetch information about a snake From 1b9cf13ee340467c9f244cd3f3646b58293249fc Mon Sep 17 00:00:00 2001 From: Rohan Date: Sat, 24 Mar 2018 18:58:39 +0530 Subject: [PATCH 10/29] added wikipedia --- Pipfile | 1 + Pipfile.lock | 44 +++++++++++++++++++++++++++++++---- bot/cogs/snakes.py | 57 ++++++++++++++++++++-------------------------- 3 files changed, 66 insertions(+), 36 deletions(-) diff --git a/Pipfile b/Pipfile index 096fb9b3..3feb1dec 100644 --- a/Pipfile +++ b/Pipfile @@ -8,6 +8,7 @@ name = "pypi" aiodns = "*" aiohttp = "<2.3.0,>=2.0.0" websockets = ">=4.0,<5.0" +wikipedia = "*" [dev-packages] "flake8" = "*" diff --git a/Pipfile.lock b/Pipfile.lock index 4e5214bb..fd1b8d4f 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "d797e580ddcddc99bf058109ab0306ad584c2902752a3d4076ba713fdc580fb7" + "sha256": "738768c7b3fa9b26b2b995f90b9324d0d058394442c75e2407bc3b010d290de3" }, "pipfile-spec": 6, "requires": { @@ -53,6 +53,21 @@ ], "version": "==2.0.1" }, + "beautifulsoup4": { + "hashes": [ + "sha256:11a9a27b7d3bddc6d86f59fb76afb70e921a25ac2d6cc55b40d072bd68435a76", + "sha256:7015e76bf32f1f574636c4288399a6de66ce08fb7b2457f628a8d70c0fbabb11", + "sha256:808b6ac932dccb0a4126558f7dfdcf41710dd44a4ef497a0bb59a77f9f078e89" + ], + "version": "==4.6.0" + }, + "certifi": { + "hashes": [ + "sha256:14131608ad2fd56836d33a71ee60fa1c82bc9d2c8d98b7bdbc631fe1b3cd1296", + "sha256:edbc3f203427eef571f79a7692bb160a2b0f7ccaa31953e99bd17e307cf63f7d" + ], + "version": "==2018.1.18" + }, "chardet": { "hashes": [ "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae", @@ -120,6 +135,20 @@ ], "version": "==2.3.0" }, + "requests": { + "hashes": [ + "sha256:6a1b267aa90cac58ac3a765d067950e7dbbf75b1da07e895d1f594193a40a38b", + "sha256:9c443e7324ba5b85070c4a818ade28bfabedf16ea10206da1132edaa6dda237e" + ], + "version": "==2.18.4" + }, + "urllib3": { + "hashes": [ + "sha256:06330f386d6e4b195fbfc736b297f58c5a892e4440e54d294d7004e3a9bbea1b", + "sha256:cc44da8e1145637334317feebd728bd869a35285b93cbb4cca2577da7e62db4f" + ], + "version": "==1.22" + }, "websockets": { "hashes": [ "sha256:0c31bc832d529dc7583d324eb6c836a4f362032a1902723c112cf57883488d8c", @@ -142,6 +171,13 @@ "index": "pypi", "version": "==4.0.1" }, + "wikipedia": { + "hashes": [ + "sha256:db0fad1829fdd441b1852306e9856398204dc0786d2996dd2e0c8bb8e26133b2" + ], + "index": "pypi", + "version": "==1.4.0" + }, "yarl": { "hashes": [ "sha256:045dbba18c9142278113d5dc62622978a6f718ba662392d406141c59b540c514", @@ -282,10 +318,10 @@ }, "gitpython": { "hashes": [ - "sha256:ad61bc25deadb535b047684d06f3654c001d9415e1971e51c9c20f5b510076e9", - "sha256:b8367c432de995dc330b5b146c5bfdc0926b8496e100fda6692134e00c0dcdc5" + "sha256:05069e26177c650b3cb945dd543a7ef7ca449f8db5b73038b465105673c1ef61", + "sha256:c47cc31af6e88979c57a33962cbc30a7c25508d74a1b3a19ec5aa7ed64b03129" ], - "version": "==2.1.8" + "version": "==2.1.9" }, "idna": { "hashes": [ diff --git a/bot/cogs/snakes.py b/bot/cogs/snakes.py index 4a482820..46f668ad 100644 --- a/bot/cogs/snakes.py +++ b/bot/cogs/snakes.py @@ -4,6 +4,7 @@ import discord import random import time +import wikipedia from discord.ext.commands import AutoShardedBot, Context, command log = logging.getLogger(__name__) @@ -33,32 +34,23 @@ async def get_snek(self, name: str = None) -> Dict[str, Any]: @command(name="get") async def get(self, ctx: Context, name: str = None): - name1 = name.lower() - cobra = 'Cobra is the common name of various elapid snakes, most of which belonging to the genus Naja.' - pythonidae = 'The Pythonidae, commonly known simply as pythons,\n from the Greek word python (πυθων), are\n a family of nonvenomous snakes found in Africa, Asia, and Australia.\n Among its members are some of the largest snakes in the world.\n Eight genera and 31 species are currently recognized.' - - first_line={ - 'cobra':cobra, - 'python':pythonidae, - } - - for key,value in first_line.items(): - if key==name.lower(): - embed = discord.Embed( - title=name1, - description=value, - color=0x00ff00, - ) + if name.lower()=="python": + name_rechange="Python Programming Language" + else: + name_rechange=name + test=wikipedia.page(name_rechange) + embed=discord.Embed( + title=test.title, + description= wikipedia.summary(name_rechange, sentences=1), + color=0x00ff00, + ) + embed.add_field(name="Image", value=test.images, inline=False) return await ctx.send(embed=embed) - """ - Go online and fetch information about a snake - This should make use of your `get_snek` method, using it to get information about a snake. This information - should be sent back to Discord in an embed. - :param ctx: Context object passed from discord.py - :param name: Optional, the name of the snake to get information for - omit for a random snake - """ + + + # Any additional commands can be placed here. Be creative, but keep it to a reasonable amount! @@ -88,23 +80,24 @@ async def SnakeRandom(self, ctx: Context , name: str= None): @command(name="randname") async def RandName(self,ctx:Context , name: str=None): - snakes=['Cobra','Python','Anaconda','Viper','Mamba'] - snk=random.choice[snakes] + + snk=random.choice(['Cobra','Python','Anaconda','Viper','Mamba']) snLen=len(snk) p = len(name) result="" front_back=random.randint(1,3) - if front_back==1:#so the users name in substring from the front and snake random substring from back - ran = random.randint(0,p-2) + if front_back==1:#so the users name is substring from the front and snake random substring from back + ran = random.randint(1,p-2) ranSnk=random.randint(2,snLen) result=name[ :ran] + snk[ranSnk: ] - return await ctx.send(result) - elif front_back==2:#so the users name in substring from the back and snake random substring from front - ran=random.randint(2,p) - ranSnk=random.randint(0,snLen-2) + + elif front_back==2:#so the users name is substring from the back and snake random substring from front + ran=random.randint(1,p) + ranSnk=random.randint(0,snLen-1) result = name[ran: ] + snk[ :ranSnk] - return await ctx.send(result) + + return await ctx.send(result) From 6bc663677b6d0c2163e334419f51c6d860a19a3f Mon Sep 17 00:00:00 2001 From: Rohan Date: Sat, 24 Mar 2018 19:33:29 +0530 Subject: [PATCH 11/29] wiki --- Pipfile | 1 + Pipfile.lock | 71 +++++++++++++++++++++++++++++++++++++++++++++- bot/cogs/snakes.py | 3 +- 3 files changed, 73 insertions(+), 2 deletions(-) diff --git a/Pipfile b/Pipfile index 3feb1dec..dcb8a4e7 100644 --- a/Pipfile +++ b/Pipfile @@ -9,6 +9,7 @@ aiodns = "*" aiohttp = "<2.3.0,>=2.0.0" websockets = ">=4.0,<5.0" wikipedia = "*" +wikiapi = "*" [dev-packages] "flake8" = "*" diff --git a/Pipfile.lock b/Pipfile.lock index fd1b8d4f..0ee9f9c1 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "738768c7b3fa9b26b2b995f90b9324d0d058394442c75e2407bc3b010d290de3" + "sha256": "62d75a7a8754ea81f6056f5fbb1f6124b7d2d8ade4e9f656ee3b53990149503f" }, "pipfile-spec": 6, "requires": { @@ -75,6 +75,13 @@ ], "version": "==3.0.4" }, + "cssselect": { + "hashes": [ + "sha256:066d8bc5229af09617e24b3ca4d52f1f9092d9e061931f4184cd572885c23204", + "sha256:3b5103e8789da9e936a68d993b70df732d06b8bb9a337a05ed4eb52c17ef7206" + ], + "version": "==1.0.3" + }, "idna": { "hashes": [ "sha256:2c6a5de3089009e3da7c5dde64a141dbc8551d5b7f6cf4ed7c2568d0cc520a8f", @@ -82,6 +89,39 @@ ], "version": "==2.6" }, + "lxml": { + "hashes": [ + "sha256:01c45df6d90497c20aa2a07789a41941f9a1029faa30bf725fc7f6d515b1afe9", + "sha256:0c9fef4f8d444e337df96c54544aeb85b7215b2ed7483bb6c35de97ac99f1bcd", + "sha256:0e3cd94c95d30ba9ca3cff40e9b2a14e1a10a4fd8131105b86c6b61648f57e4b", + "sha256:0e7996e9b46b4d8b4ac1c329a00e2d10edcd8380b95d2a676fccabf4c1dd0512", + "sha256:1858b1933d483ec5727549d3fe166eeb54229fbd6a9d3d7ea26d2c8a28048058", + "sha256:1b164bba1320b14905dcff77da10d5ce9c411ac4acc4fb4ed9a2a4d10fae38c9", + "sha256:1b46f37927fa6cd1f3fe34b54f1a23bd5bea1d905657289e08e1297069a1a597", + "sha256:231047b05907315ae9a9b6925751f9fd2c479cf7b100fff62485a25e382ca0d4", + "sha256:28f0c6652c1b130f1e576b60532f84b19379485eb8da6185c29bd8c9c9bc97bf", + "sha256:34d49d0f72dd82b9530322c48b70ac78cca0911275da741c3b1d2f3603c5f295", + "sha256:3682a17fbf72d56d7e46db2e80ca23850b79c28cfe75dcd9b82f58808f730909", + "sha256:3cf2830b9a6ad7f6e965fa53a768d4d2372a7856f20ffa6ce43d2fe9c0d34b19", + "sha256:5b653c9379ce29ce271fbe1010c5396670f018e78b643e21beefbb3dc6d291de", + "sha256:65a272821d5d8194358d6b46f3ca727fa56a6b63981606eac737c86d27309cdd", + "sha256:691f2cd97cf026c611df1ea5055755eec7f878f2d4f4330dc8686583de6fc5fd", + "sha256:6b6379495d3baacf7ed755ac68547c8dff6ce5d37bf370f0b7678888dc1283f9", + "sha256:75322a531504d4f383264391d89993a42e286da8821ddc5ac315e57305cb84f0", + "sha256:7f457cbda964257f443bac861d3a36732dcba8183149e7818ee2fb7c86901b94", + "sha256:7ff1fc76d8804e0f870c343a72007ff587090c218b0f92d8ee784ac2b6eaf5b9", + "sha256:8523fbde9c2216f3f2b950cb01ebe52e785eaa8a07ffeb456dd3576ca1b4fb9b", + "sha256:8f37627f16e026523fca326f1b5c9a43534862fede6c3e99c2ba6a776d75c1ab", + "sha256:a7182ea298cc3555ea56ffbb0748fe0d5e0d81451e2bc16d7f4645cd01b1ca70", + "sha256:abbd2fb4a5a04c11b5e04eb146659a0cf67bb237dd3d7ca3b9994d3a9f826e55", + "sha256:accc9f6b77bed0a6f267b4fae120f6008a951193d548cdbe9b61fc98a08b1cf8", + "sha256:bd88c8ce0d1504fdfd96a35911dd4f3edfb2e560d7cfdb5a3d09aa571ae5fbae", + "sha256:c557ad647facb3c0027a9d0af58853f905e85a0a2f04dcb73f8e665272fcdc3a", + "sha256:defabb7fbb99f9f7b3e0b24b286a46855caef4776495211b066e9e6592d12b04", + "sha256:e2629cdbcad82b83922a3488937632a4983ecc0fed3e5cfbf430d069382eeb9b" + ], + "version": "==4.2.1" + }, "multidict": { "hashes": [ "sha256:0462372fc74e4c061335118a4a5992b9a618d6c584b028ef03cf3e9b88a960e2", @@ -135,6 +175,13 @@ ], "version": "==2.3.0" }, + "pyquery": { + "hashes": [ + "sha256:07987c2ed2aed5cba29ff18af95e56e9eb04a2249f42ce47bddfb37f487229a3", + "sha256:4771db76bd14352eba006463656aef990a0147a0eeaf094725097acfa90442bf" + ], + "version": "==1.4.0" + }, "requests": { "hashes": [ "sha256:6a1b267aa90cac58ac3a765d067950e7dbbf75b1da07e895d1f594193a40a38b", @@ -142,6 +189,13 @@ ], "version": "==2.18.4" }, + "six": { + "hashes": [ + "sha256:70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9", + "sha256:832dc0e10feb1aa2c68dcc57dbb658f1c7e65b9b61af69048abc87a2db00a0eb" + ], + "version": "==1.11.0" + }, "urllib3": { "hashes": [ "sha256:06330f386d6e4b195fbfc736b297f58c5a892e4440e54d294d7004e3a9bbea1b", @@ -171,6 +225,21 @@ "index": "pypi", "version": "==4.0.1" }, + "wheel": { + "hashes": [ + "sha256:9515fe0a94e823fd90b08d22de45d7bde57c90edce705b22f5e1ecf7e1b653c8", + "sha256:e721e53864f084f956f40f96124a74da0631ac13fbbd1ba99e8e2b5e9cafdf64" + ], + "version": "==0.30.0" + }, + "wikiapi": { + "hashes": [ + "sha256:1b6885d29586b728e850ffa4d85486949aaec0eedfe7306a68061c2f0723f5b6", + "sha256:a7d7be4efad7d000834a8c00d64c04803879bf4bc23a825a43c0ca93e9b97ce5" + ], + "index": "pypi", + "version": "==1.2.5" + }, "wikipedia": { "hashes": [ "sha256:db0fad1829fdd441b1852306e9856398204dc0786d2996dd2e0c8bb8e26133b2" diff --git a/bot/cogs/snakes.py b/bot/cogs/snakes.py index 46f668ad..26d00ed5 100644 --- a/bot/cogs/snakes.py +++ b/bot/cogs/snakes.py @@ -39,12 +39,13 @@ async def get(self, ctx: Context, name: str = None): else: name_rechange=name test=wikipedia.page(name_rechange) + embed=discord.Embed( title=test.title, description= wikipedia.summary(name_rechange, sentences=1), color=0x00ff00, ) - embed.add_field(name="Image", value=test.images, inline=False) + embed.add_field(name="Image", value=test.images[0], inline=False) return await ctx.send(embed=embed) From 1a033f4383bf03911da170150cbcb4f8fce8304f Mon Sep 17 00:00:00 2001 From: Rohan Date: Sat, 24 Mar 2018 19:40:50 +0530 Subject: [PATCH 12/29] edited randname --- bot/cogs/snakes.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/bot/cogs/snakes.py b/bot/cogs/snakes.py index 26d00ed5..3881df3a 100644 --- a/bot/cogs/snakes.py +++ b/bot/cogs/snakes.py @@ -86,17 +86,14 @@ async def RandName(self,ctx:Context , name: str=None): snLen=len(snk) p = len(name) result="" - front_back=random.randint(1,3) + front_back=1 if front_back==1:#so the users name is substring from the front and snake random substring from back ran = random.randint(1,p-2) - ranSnk=random.randint(2,snLen) + ranSnk=random.randint(1,snLen-1) result=name[ :ran] + snk[ranSnk: ] - elif front_back==2:#so the users name is substring from the back and snake random substring from front - ran=random.randint(1,p) - ranSnk=random.randint(0,snLen-1) - result = name[ran: ] + snk[ :ranSnk] + return await ctx.send(result) From 058cef2e8ce76f83327515c69688dbc71e2015b5 Mon Sep 17 00:00:00 2001 From: Rohan Date: Sat, 24 Mar 2018 21:12:37 +0530 Subject: [PATCH 13/29] some editing --- bot/cogs/snakes.py | 83 +++++++++++++++++++--------------------------- 1 file changed, 35 insertions(+), 48 deletions(-) diff --git a/bot/cogs/snakes.py b/bot/cogs/snakes.py index 3881df3a..75254763 100644 --- a/bot/cogs/snakes.py +++ b/bot/cogs/snakes.py @@ -1,14 +1,14 @@ # coding=utf-8 import logging from typing import Any, Dict -import discord import random -import time import wikipedia +import discord from discord.ext.commands import AutoShardedBot, Context, command log = logging.getLogger(__name__) + class Snakes: """ Snake-related commands @@ -19,47 +19,41 @@ def __init__(self, bot: AutoShardedBot): async def get_snek(self, name: str = None) -> Dict[str, Any]: - """ - Go online and fetch information about a snake + """ + Go online and fetch information about a snake - The information includes the name of the snake, a picture of the snake, and various other pieces of info. - What information you get for the snake is up to you. Be creative! + The information includes the name of the snake, a picture of the snake, and various other pieces of info. + What information you get for the snake is up to you. Be creative! - If "python" is given as the snake name, you should return information about the programming language, but with - all the information you'd provide for a real snake. Try to have some fun with this! + If "python" is given as the snake name, you should return information about the programming language, but with + all the information you'd provide for a real snake. Try to have some fun with this! - :param name: Optional, the name of the snake to get information for - omit for a random snake - :return: A dict containing information on a snake - """ + :param name: Optional, the name of the snake to get information for - omit for a random snake + :return: A dict containing information on a snake + """ @command(name="get") async def get(self, ctx: Context, name: str = None): - if name.lower()=="python": - name_rechange="Python Programming Language" + if name.lower() == "python": + name_rechange = "Python Programming Language" else: - name_rechange=name - test=wikipedia.page(name_rechange) + name_rechange = name + test = wikipedia.page(name_rechange) - embed=discord.Embed( + embed = discord.Embed( title=test.title, - description= wikipedia.summary(name_rechange, sentences=1), + description=wikipedia.summary(name_rechange, sentences=1), color=0x00ff00, ) embed.add_field(name="Image", value=test.images[0], inline=False) return await ctx.send(embed=embed) - - - - - # Any additional commands can be placed here. Be creative, but keep it to a reasonable amount! - @command(name="snakerandom") - async def SnakeRandom(self, ctx: Context , name: str= None): - #snakes=['Cobra','Python','Anaconda','Black Mamba','Rattle Snake'] - randsnake=random.choice(['cobra','python','black mamba']) + async def SnakeRandom(self, ctx: Context, name: str = None): + # snakes=['Cobra','Python','Anaconda','Black Mamba','Rattle Snake'] + randsnake = random.choice(['cobra', 'python', 'black mamba']) print(randsnake) embed = discord.Embed( title="Snake Random !", @@ -67,40 +61,33 @@ async def SnakeRandom(self, ctx: Context , name: str= None): color=0x00ff00, ) - embed.add_field(name="Result", value="You got yourself a "+randsnake, inline=False) + embed.add_field(name="Result", value="You got yourself a " + randsnake, inline=False) embed.add_field(name="Expectation", value=f"@{ctx.author} expected {name}", inline=False) - if randsnake=="python": + if randsnake == "python": - return await ctx.send("Your a lucky dude !",embed=embed) - elif randsnake=="cobra": - return await ctx.send("Good old cobra !",embed=embed) + return await ctx.send("Your a lucky dude !", embed=embed) + elif randsnake == "cobra": + return await ctx.send("Good old cobra !", embed=embed) elif randsnake.startswith("blac"): - return await ctx.send("Shiny liitle fella !",embed=embed) - + return await ctx.send("Shiny liitle fella !", embed=embed) @command(name="randname") - async def RandName(self,ctx:Context , name: str=None): + async def RandName(self, ctx: Context, name: str = None): - snk=random.choice(['Cobra','Python','Anaconda','Viper','Mamba']) - snLen=len(snk) + snk = random.choice(['Cobra', 'Python', 'Anaconda', 'Viper', 'Mamba']) + snLen = len(snk) p = len(name) - result="" - front_back=1 - if front_back==1:#so the users name is substring from the front and snake random substring from back - ran = random.randint(1,p-2) - ranSnk=random.randint(1,snLen-1) - result=name[ :ran] + snk[ranSnk: ] - - - + result = "" + front_back = 1 + if front_back == 1: # so the users name is substring from the front and snake random substring from back + ran = random.randint(1, p - 2) + ranSnk = random.randint(1, snLen - 1) + result = name[:ran] + snk[ranSnk:] return await ctx.send(result) - - - def setup(bot): bot.add_cog(Snakes(bot)) log.info("Cog loaded: Snakes") From 04fe13281fbaf5a466a33cc822302bc1d0879398 Mon Sep 17 00:00:00 2001 From: Rohan Date: Sun, 25 Mar 2018 13:17:07 +0530 Subject: [PATCH 14/29] editing --- bot/cogs/snakes.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/bot/cogs/snakes.py b/bot/cogs/snakes.py index 75254763..9ad14e54 100644 --- a/bot/cogs/snakes.py +++ b/bot/cogs/snakes.py @@ -3,6 +3,8 @@ from typing import Any, Dict import random import wikipedia +import aiohttp +import requests import discord from discord.ext.commands import AutoShardedBot, Context, command @@ -33,8 +35,18 @@ async def get_snek(self, name: str = None) -> Dict[str, Any]: """ @command(name="get") - async def get(self, ctx: Context, name: str = None): - if name.lower() == "python": + async def get(self, ctx: Context):#, name: str = None): + + async with aiohttp.ClientSession() as session: + async with session.get('https://en.wikipedia.org/wiki/Cobra') as resp: + return await ctx.send(yield from resp.text) + #return await resp.() + #r = yield from aiohttp.request('get', 'http://python.org') + #raw = yield from r.text() + + #print(raw) + + """if name.lower() == "python": name_rechange = "Python Programming Language" else: name_rechange = name @@ -47,6 +59,7 @@ async def get(self, ctx: Context, name: str = None): ) embed.add_field(name="Image", value=test.images[0], inline=False) return await ctx.send(embed=embed) + """ # Any additional commands can be placed here. Be creative, but keep it to a reasonable amount! From 9440cb1a6b88ccec1205f5150e2d3d8538fbf9ad Mon Sep 17 00:00:00 2001 From: Rohan Date: Sun, 25 Mar 2018 14:20:01 +0530 Subject: [PATCH 15/29] adding another random name with better code --- bot/cogs/snakes.py | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/bot/cogs/snakes.py b/bot/cogs/snakes.py index 9ad14e54..9c62ff81 100644 --- a/bot/cogs/snakes.py +++ b/bot/cogs/snakes.py @@ -4,7 +4,6 @@ import random import wikipedia import aiohttp -import requests import discord from discord.ext.commands import AutoShardedBot, Context, command @@ -35,31 +34,10 @@ async def get_snek(self, name: str = None) -> Dict[str, Any]: """ @command(name="get") - async def get(self, ctx: Context):#, name: str = None): - + async def get(self, ctx: Context, name: str = None): async with aiohttp.ClientSession() as session: async with session.get('https://en.wikipedia.org/wiki/Cobra') as resp: - return await ctx.send(yield from resp.text) - #return await resp.() - #r = yield from aiohttp.request('get', 'http://python.org') - #raw = yield from r.text() - - #print(raw) - - """if name.lower() == "python": - name_rechange = "Python Programming Language" - else: - name_rechange = name - test = wikipedia.page(name_rechange) - - embed = discord.Embed( - title=test.title, - description=wikipedia.summary(name_rechange, sentences=1), - color=0x00ff00, - ) - embed.add_field(name="Image", value=test.images[0], inline=False) - return await ctx.send(embed=embed) - """ + return await ctx.send(await resp.text) # Any additional commands can be placed here. Be creative, but keep it to a reasonable amount! @@ -87,8 +65,8 @@ async def SnakeRandom(self, ctx: Context, name: str = None): @command(name="randname") async def RandName(self, ctx: Context, name: str = None): - - snk = random.choice(['Cobra', 'Python', 'Anaconda', 'Viper', 'Mamba']) + snakes=['cobra', 'python', 'anaconda', 'viper', 'mamba','taipan','rattle','garter','cylindrophis','colubridae'] + snk = random.choice(snakes) snLen = len(snk) p = len(name) result = "" @@ -100,6 +78,10 @@ async def RandName(self, ctx: Context, name: str = None): return await ctx.send(result) + @command(name="RandomName") + async def randomName(selfself,ctx:Context, name:str= None): + + def setup(bot): bot.add_cog(Snakes(bot)) From 4a18eaef0f9a6393e28ad2cd85dc7c8745128076 Mon Sep 17 00:00:00 2001 From: LaVieEstDure Date: Sun, 25 Mar 2018 20:14:48 +1000 Subject: [PATCH 16/29] get command --- Pipfile | 7 +++++++ bot/cogs/snakes.py | 39 ++++++++++++++++++++------------------- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/Pipfile b/Pipfile index dcb8a4e7..97bdb150 100644 --- a/Pipfile +++ b/Pipfile @@ -1,9 +1,12 @@ [[source]] + url = "https://pypi.python.org/simple" verify_ssl = true name = "pypi" + [packages] + "72eb2aa" = {file = "https://github.com/Rapptz/discord.py/archive/rewrite.zip"} aiodns = "*" aiohttp = "<2.3.0,>=2.0.0" @@ -11,7 +14,9 @@ websockets = ">=4.0,<5.0" wikipedia = "*" wikiapi = "*" + [dev-packages] + "flake8" = "*" "flake8-bugbear" = "*" "flake8-bandit" = "*" @@ -22,5 +27,7 @@ wikiapi = "*" safety = "*" dodgy = "*" + [requires] + python_version = "3.6" diff --git a/bot/cogs/snakes.py b/bot/cogs/snakes.py index 9ad14e54..fea090b5 100644 --- a/bot/cogs/snakes.py +++ b/bot/cogs/snakes.py @@ -2,14 +2,14 @@ import logging from typing import Any, Dict import random -import wikipedia import aiohttp -import requests import discord from discord.ext.commands import AutoShardedBot, Context, command +import wikipedia log = logging.getLogger(__name__) +SNAKE_LIST = ['cobra', 'python', 'anaconda', 'viper', 'mamba', 'taipan', 'rattle', 'garter', 'cylindrophis','colubridae'] class Snakes: """ @@ -33,33 +33,34 @@ async def get_snek(self, name: str = None) -> Dict[str, Any]: :param name: Optional, the name of the snake to get information for - omit for a random snake :return: A dict containing information on a snake """ + if name is None: + name = random.choice(SNAKE_LIST) + elif name.lower() == "python": + name = "Python (Programming Language)" + try: + text = wikipedia.summary(name) + except Exception as e: + text = wikipedia.summary(e.options[0]) + return (name, text) @command(name="get") - async def get(self, ctx: Context):#, name: str = None): - - async with aiohttp.ClientSession() as session: - async with session.get('https://en.wikipedia.org/wiki/Cobra') as resp: - return await ctx.send(yield from resp.text) - #return await resp.() - #r = yield from aiohttp.request('get', 'http://python.org') - #raw = yield from r.text() - - #print(raw) - - """if name.lower() == "python": + async def get(self, ctx: Context, name: str=None): + """if name.lower() == "python": name_rechange = "Python Programming Language" else: name_rechange = name test = wikipedia.page(name_rechange) - embed = discord.Embed( - title=test.title, - description=wikipedia.summary(name_rechange, sentences=1), - color=0x00ff00, - ) embed.add_field(name="Image", value=test.images[0], inline=False) return await ctx.send(embed=embed) """ + name, text = await self.get_snek(name) + embed = discord.Embed( + title=name, + description=text, + color=0x00ff00 + ) + await ctx.send(embed=embed) # Any additional commands can be placed here. Be creative, but keep it to a reasonable amount! From 8045186448a39c75bd0388ff4aecf6501a63f825 Mon Sep 17 00:00:00 2001 From: Rohan Date: Sun, 25 Mar 2018 16:59:00 +0530 Subject: [PATCH 17/29] commiting --- bot/cogs/snakes.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/bot/cogs/snakes.py b/bot/cogs/snakes.py index 9c62ff81..1a619dc2 100644 --- a/bot/cogs/snakes.py +++ b/bot/cogs/snakes.py @@ -3,7 +3,6 @@ from typing import Any, Dict import random import wikipedia -import aiohttp import discord from discord.ext.commands import AutoShardedBot, Context, command @@ -34,10 +33,7 @@ async def get_snek(self, name: str = None) -> Dict[str, Any]: """ @command(name="get") - async def get(self, ctx: Context, name: str = None): - async with aiohttp.ClientSession() as session: - async with session.get('https://en.wikipedia.org/wiki/Cobra') as resp: - return await ctx.send(await resp.text) + # Any additional commands can be placed here. Be creative, but keep it to a reasonable amount! @@ -75,11 +71,19 @@ async def RandName(self, ctx: Context, name: str = None): ran = random.randint(1, p - 2) ranSnk = random.randint(1, snLen - 1) result = name[:ran] + snk[ranSnk:] + embed=discord.Embed( + title="Name Generator !", + description="You have been hooked up with the snake "+snk+"and your name is "+result, + color=0x00ff00 + ) return await ctx.send(result) @command(name="RandomName") async def randomName(selfself,ctx:Context, name:str= None): + snakes = ['cobra', 'python', 'anaconda', 'viper', 'mamba', 'taipan', 'rattle', 'garter', 'cylindrophis','colubridae'] + snk = random.choice(snakes) + From 3ef6e5e83710023742227309935ec0f6b41860ce Mon Sep 17 00:00:00 2001 From: Rohan Date: Sun, 25 Mar 2018 17:09:53 +0530 Subject: [PATCH 18/29] removed import aiohttp --- bot/cogs/snakes.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bot/cogs/snakes.py b/bot/cogs/snakes.py index 0b754be3..542b1a85 100644 --- a/bot/cogs/snakes.py +++ b/bot/cogs/snakes.py @@ -2,7 +2,6 @@ import logging from typing import Any, Dict import random -import aiohttp import discord from discord.ext.commands import AutoShardedBot, Context, command import wikipedia @@ -62,7 +61,7 @@ async def get(self, ctx: Context, name: str=None): @command(name="snakerandom") async def SnakeRandom(self, ctx: Context, name: str = None): - + randsnake = random.choice(SNAKE_LIST) print(randsnake) embed = discord.Embed( From aa2a625cbb1e18ab071a2b700745fee670ab745a Mon Sep 17 00:00:00 2001 From: Rohan Date: Sun, 25 Mar 2018 19:08:18 +0530 Subject: [PATCH 19/29] added python pic --- bot/cogs/snakes.py | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/bot/cogs/snakes.py b/bot/cogs/snakes.py index 542b1a85..9e1f18a7 100644 --- a/bot/cogs/snakes.py +++ b/bot/cogs/snakes.py @@ -29,14 +29,19 @@ async def get_snek(self, name: str = None) -> Dict[str, Any]: :param name: Optional, the name of the snake to get information for - omit for a random snake :return: A dict containing information on a snake """ + if name is None: name = random.choice(SNAKE_LIST) + elif name.lower() == "python": - name = "Python (Programming Language)" + name = "Python(Programming Language)" + + + try: - text = wikipedia.summary(name) + text = wikipedia.summary(name,sentences=2) except Exception as e: - text = wikipedia.summary(e.options[0]) + text = wikipedia.summary(e.options[0],sentences=2) return (name, text) @command(name="get") @@ -49,13 +54,21 @@ async def get(self, ctx: Context, name: str=None): embed.add_field(name="Image", value=test.images[0], inline=False) return await ctx.send(embed=embed) """ - name, text = await self.get_snek(name) - embed = discord.Embed( - title=name, - description=text, - color=0x00ff00 - ) - await ctx.send(embed=embed) + name, text = await self.get_snek(name) + for_image='' + if name=="Python(Programming Language)": + for_image ='https://raw.githubusercontent.com/discord-python/branding/master/logos/logo_full.png' + embed = discord.Embed(title="Programming !!", color=0x00ff00) + embed.add_field(name=name, value=text) + embed.set_image(url=for_image) + await ctx.send(embed=embed) + else: + webpage=wikipedia.WikipediaPage(name) + for_image=webpage.images[0] + embed=discord.Embed(title="Snake !!",color=0x00ff00) + embed.add_field(name=name,value=text) + embed.set_image(url=for_image) + await ctx.send(embed=embed) # Any additional commands can be placed here. Be creative, but keep it to a reasonable amount! From 6a0c1ed62e91b5ce0d9b2c590b13a27bdbf9641a Mon Sep 17 00:00:00 2001 From: Rohan Date: Sun, 25 Mar 2018 19:10:26 +0530 Subject: [PATCH 20/29] removed some spaces --- bot/cogs/snakes.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/bot/cogs/snakes.py b/bot/cogs/snakes.py index 9e1f18a7..e87329c3 100644 --- a/bot/cogs/snakes.py +++ b/bot/cogs/snakes.py @@ -36,8 +36,6 @@ async def get_snek(self, name: str = None) -> Dict[str, Any]: elif name.lower() == "python": name = "Python(Programming Language)" - - try: text = wikipedia.summary(name,sentences=2) except Exception as e: From 376547e5393ac6568b7fb7729afaccfc421cde1d Mon Sep 17 00:00:00 2001 From: Rohan Date: Sun, 25 Mar 2018 20:58:12 +0530 Subject: [PATCH 21/29] final submit --- Pipfile | 10 +--- Pipfile.lock | 112 ++++++++++++--------------------------------- bot/cogs/snakes.py | 83 ++++++++++++++++++++++----------- 3 files changed, 86 insertions(+), 119 deletions(-) diff --git a/Pipfile b/Pipfile index 97bdb150..10c6fd56 100644 --- a/Pipfile +++ b/Pipfile @@ -1,22 +1,16 @@ [[source]] - url = "https://pypi.python.org/simple" verify_ssl = true name = "pypi" - [packages] - "72eb2aa" = {file = "https://github.com/Rapptz/discord.py/archive/rewrite.zip"} aiodns = "*" -aiohttp = "<2.3.0,>=2.0.0" websockets = ">=4.0,<5.0" wikipedia = "*" -wikiapi = "*" - +aiohttp = "*" [dev-packages] - "flake8" = "*" "flake8-bugbear" = "*" "flake8-bandit" = "*" @@ -27,7 +21,5 @@ wikiapi = "*" safety = "*" dodgy = "*" - [requires] - python_version = "3.6" diff --git a/Pipfile.lock b/Pipfile.lock index 0ee9f9c1..6e1fabdf 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "62d75a7a8754ea81f6056f5fbb1f6124b7d2d8ade4e9f656ee3b53990149503f" + "sha256": "71337d959acc1cf7725dabf5b49701da64e6482aa69261394f29b1fd233575b4" }, "pipfile-spec": 6, "requires": { @@ -29,22 +29,24 @@ }, "aiohttp": { "hashes": [ - "sha256:129d83dd067760cec3cfd4456b5c6d7ac29f2c639d856884568fd539bed5a51f", - "sha256:33c62afd115c456b0cf1e890fe6753055effe0f31a28321efd4f787378d6f4ab", - "sha256:666756e1d4cf161ed1486b82f65fdd386ac07dd20fb10f025abf4be54be12746", - "sha256:9705ded5a0faa25c8f14c6afb7044002d66c9120ed7eadb4aa9ca4aad32bd00c", - "sha256:af5bfdd164256118a0a306b3f7046e63207d1f8cba73a67dcc0bd858dcfcd3bc", - "sha256:b80f44b99fa3c9b4530fcfa324a99b84843043c35b084e0b653566049974435d", - "sha256:c67e105ec74b85c8cb666b6877569dee6f55b9548f982983b9bee80b3d47e6f3", - "sha256:d15c6658de5b7783c2538407278fa062b079a46d5f814a133ae0f09bbb2cfbc4", - "sha256:d611ebd1ef48498210b65486306e065fde031040a1f3c455ca1b6baa7bf32ad3", - "sha256:dcc7e4dcec6b0012537b9f8a0726f8b111188894ab0f924b680d40b13d3298a0", - "sha256:de8ef106e130b94ca143fdfc6f27cda1d8ba439462542377738af4d99d9f5dd2", - "sha256:eb6f1405b607fff7e44168e3ceb5d3c8a8c5a2d3effe0a27f843b16ec047a6d7", - "sha256:f0e2ac69cb709367400008cebccd5d48161dd146096a009a632a132babe5714c" + "sha256:04ec521058055b2501b5c31419c8bd6212e10785653834838981fcd234402364", + "sha256:3f197bcdc0a801ecfa48d2ed0a0a49842668da1cbec25745cf65da68f7e62069", + "sha256:44373fee917bafe243aed7e4831eface7fa10dd54f7205f091d22c3bc6ae95e9", + "sha256:4f94b2b9e70a2e91e7ba2caf05c21251741af9db9c837e5ec874042bef34879a", + "sha256:73beb2efcce172af584ba233c4448f6860947aa81a4db8867bb8211124859777", + "sha256:7e74f2f0c5c8c9da14ffd224dbdcef0b315201e3986f5b9961ea30f6d1754b1f", + "sha256:8d87c610dc8c762e2f9e5fbe127fd0e0e850cf36141db939788558a225596506", + "sha256:8fe4cb34b734377d1e64070a7eea50a3776dd9478f91722f4dbb1a57ff9e6d99", + "sha256:9c68046dd6f986619942149b87e13e6be5272fbcb268d791dc8f2015eb9e30cc", + "sha256:a66c36fd969336278ccb8398c891e268e9fb2ee9e5866433fa4e0b7436d747e7", + "sha256:b27f5f1d93dc05e25b3dc315ab76c7bd106fd0d58d4bb7ed0256e3a538300e65", + "sha256:b99c8286770bbec5f226786d453a4e5602a052843f0865735b22ac6be5c20972", + "sha256:c0c12ca08d97e5a19a4e65573eaee70d3d371f2f1a8059e5229684d3eef1d10c", + "sha256:d69ead4d1a9ad02c4164cb3ff75b6e95793540517f9085430d25d521f50bcd1c", + "sha256:feb57395cacf87cc4b621d4b4cf8eb2dfb0dc97b47e7443d2b3349dff4c3769e" ], "index": "pypi", - "version": "==2.2.5" + "version": "==3.1.0" }, "async-timeout": { "hashes": [ @@ -53,6 +55,13 @@ ], "version": "==2.0.1" }, + "attrs": { + "hashes": [ + "sha256:1c7960ccfd6a005cd9f7ba884e6316b5e430a3f1a6c37c5f87d8b43f83b54ec9", + "sha256:a17a9573a6f475c99b551c0e0a812707ddda1ec9653bed04c13841404ed6f450" + ], + "version": "==17.4.0" + }, "beautifulsoup4": { "hashes": [ "sha256:11a9a27b7d3bddc6d86f59fb76afb70e921a25ac2d6cc55b40d072bd68435a76", @@ -75,13 +84,6 @@ ], "version": "==3.0.4" }, - "cssselect": { - "hashes": [ - "sha256:066d8bc5229af09617e24b3ca4d52f1f9092d9e061931f4184cd572885c23204", - "sha256:3b5103e8789da9e936a68d993b70df732d06b8bb9a337a05ed4eb52c17ef7206" - ], - "version": "==1.0.3" - }, "idna": { "hashes": [ "sha256:2c6a5de3089009e3da7c5dde64a141dbc8551d5b7f6cf4ed7c2568d0cc520a8f", @@ -89,38 +91,11 @@ ], "version": "==2.6" }, - "lxml": { - "hashes": [ - "sha256:01c45df6d90497c20aa2a07789a41941f9a1029faa30bf725fc7f6d515b1afe9", - "sha256:0c9fef4f8d444e337df96c54544aeb85b7215b2ed7483bb6c35de97ac99f1bcd", - "sha256:0e3cd94c95d30ba9ca3cff40e9b2a14e1a10a4fd8131105b86c6b61648f57e4b", - "sha256:0e7996e9b46b4d8b4ac1c329a00e2d10edcd8380b95d2a676fccabf4c1dd0512", - "sha256:1858b1933d483ec5727549d3fe166eeb54229fbd6a9d3d7ea26d2c8a28048058", - "sha256:1b164bba1320b14905dcff77da10d5ce9c411ac4acc4fb4ed9a2a4d10fae38c9", - "sha256:1b46f37927fa6cd1f3fe34b54f1a23bd5bea1d905657289e08e1297069a1a597", - "sha256:231047b05907315ae9a9b6925751f9fd2c479cf7b100fff62485a25e382ca0d4", - "sha256:28f0c6652c1b130f1e576b60532f84b19379485eb8da6185c29bd8c9c9bc97bf", - "sha256:34d49d0f72dd82b9530322c48b70ac78cca0911275da741c3b1d2f3603c5f295", - "sha256:3682a17fbf72d56d7e46db2e80ca23850b79c28cfe75dcd9b82f58808f730909", - "sha256:3cf2830b9a6ad7f6e965fa53a768d4d2372a7856f20ffa6ce43d2fe9c0d34b19", - "sha256:5b653c9379ce29ce271fbe1010c5396670f018e78b643e21beefbb3dc6d291de", - "sha256:65a272821d5d8194358d6b46f3ca727fa56a6b63981606eac737c86d27309cdd", - "sha256:691f2cd97cf026c611df1ea5055755eec7f878f2d4f4330dc8686583de6fc5fd", - "sha256:6b6379495d3baacf7ed755ac68547c8dff6ce5d37bf370f0b7678888dc1283f9", - "sha256:75322a531504d4f383264391d89993a42e286da8821ddc5ac315e57305cb84f0", - "sha256:7f457cbda964257f443bac861d3a36732dcba8183149e7818ee2fb7c86901b94", - "sha256:7ff1fc76d8804e0f870c343a72007ff587090c218b0f92d8ee784ac2b6eaf5b9", - "sha256:8523fbde9c2216f3f2b950cb01ebe52e785eaa8a07ffeb456dd3576ca1b4fb9b", - "sha256:8f37627f16e026523fca326f1b5c9a43534862fede6c3e99c2ba6a776d75c1ab", - "sha256:a7182ea298cc3555ea56ffbb0748fe0d5e0d81451e2bc16d7f4645cd01b1ca70", - "sha256:abbd2fb4a5a04c11b5e04eb146659a0cf67bb237dd3d7ca3b9994d3a9f826e55", - "sha256:accc9f6b77bed0a6f267b4fae120f6008a951193d548cdbe9b61fc98a08b1cf8", - "sha256:bd88c8ce0d1504fdfd96a35911dd4f3edfb2e560d7cfdb5a3d09aa571ae5fbae", - "sha256:c557ad647facb3c0027a9d0af58853f905e85a0a2f04dcb73f8e665272fcdc3a", - "sha256:defabb7fbb99f9f7b3e0b24b286a46855caef4776495211b066e9e6592d12b04", - "sha256:e2629cdbcad82b83922a3488937632a4983ecc0fed3e5cfbf430d069382eeb9b" - ], - "version": "==4.2.1" + "idna-ssl": { + "hashes": [ + "sha256:1293f030bc608e9aa9cdee72aa93c1521bbb9c7698068c61c9ada6772162b979" + ], + "version": "==1.0.1" }, "multidict": { "hashes": [ @@ -175,13 +150,6 @@ ], "version": "==2.3.0" }, - "pyquery": { - "hashes": [ - "sha256:07987c2ed2aed5cba29ff18af95e56e9eb04a2249f42ce47bddfb37f487229a3", - "sha256:4771db76bd14352eba006463656aef990a0147a0eeaf094725097acfa90442bf" - ], - "version": "==1.4.0" - }, "requests": { "hashes": [ "sha256:6a1b267aa90cac58ac3a765d067950e7dbbf75b1da07e895d1f594193a40a38b", @@ -189,13 +157,6 @@ ], "version": "==2.18.4" }, - "six": { - "hashes": [ - "sha256:70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9", - "sha256:832dc0e10feb1aa2c68dcc57dbb658f1c7e65b9b61af69048abc87a2db00a0eb" - ], - "version": "==1.11.0" - }, "urllib3": { "hashes": [ "sha256:06330f386d6e4b195fbfc736b297f58c5a892e4440e54d294d7004e3a9bbea1b", @@ -225,21 +186,6 @@ "index": "pypi", "version": "==4.0.1" }, - "wheel": { - "hashes": [ - "sha256:9515fe0a94e823fd90b08d22de45d7bde57c90edce705b22f5e1ecf7e1b653c8", - "sha256:e721e53864f084f956f40f96124a74da0631ac13fbbd1ba99e8e2b5e9cafdf64" - ], - "version": "==0.30.0" - }, - "wikiapi": { - "hashes": [ - "sha256:1b6885d29586b728e850ffa4d85486949aaec0eedfe7306a68061c2f0723f5b6", - "sha256:a7d7be4efad7d000834a8c00d64c04803879bf4bc23a825a43c0ca93e9b97ce5" - ], - "index": "pypi", - "version": "==1.2.5" - }, "wikipedia": { "hashes": [ "sha256:db0fad1829fdd441b1852306e9856398204dc0786d2996dd2e0c8bb8e26133b2" diff --git a/bot/cogs/snakes.py b/bot/cogs/snakes.py index e87329c3..37ce74fc 100644 --- a/bot/cogs/snakes.py +++ b/bot/cogs/snakes.py @@ -8,7 +8,9 @@ log = logging.getLogger(__name__) -SNAKE_LIST = ['cobra', 'python', 'anaconda', 'viper', 'mamba', 'taipan', 'rattle', 'garter', 'cylindrophis','colubridae'] +SNAKE_LIST = ['cobra', 'python', 'anaconda', 'viper', 'mamba', 'taipan', 'rattle', 'garter', 'cylindrophis', + 'colubridae'] + class Snakes: """ @@ -37,41 +39,34 @@ async def get_snek(self, name: str = None) -> Dict[str, Any]: name = "Python(Programming Language)" try: - text = wikipedia.summary(name,sentences=2) + text = wikipedia.summary(name, sentences=2) except Exception as e: - text = wikipedia.summary(e.options[0],sentences=2) + text = wikipedia.summary(e.options[0], sentences=2) return (name, text) @command(name="get") - async def get(self, ctx: Context, name: str=None): - """if name.lower() == "python": - name_rechange = "Python Programming Language" - else: - name_rechange = name - test = wikipedia.page(name_rechange) - embed.add_field(name="Image", value=test.images[0], inline=False) - return await ctx.send(embed=embed) - """ - name, text = await self.get_snek(name) - for_image='' - if name=="Python(Programming Language)": - for_image ='https://raw.githubusercontent.com/discord-python/branding/master/logos/logo_full.png' + async def get(self, ctx: Context, name: str = None): + + name, text = await self.get_snek(name) + for_image = '' + if name == "Python(Programming Language)": + for_image = 'https://raw.githubusercontent.com/discord-python/branding/master/logos/logo_full.png' embed = discord.Embed(title="Programming !!", color=0x00ff00) embed.add_field(name=name, value=text) embed.set_image(url=for_image) await ctx.send(embed=embed) else: - webpage=wikipedia.WikipediaPage(name) - for_image=webpage.images[0] - embed=discord.Embed(title="Snake !!",color=0x00ff00) - embed.add_field(name=name,value=text) + webpage = wikipedia.WikipediaPage(name) + for_image = webpage.images[0] + embed = discord.Embed(title="Snake !!", color=0x00ff00) + embed.add_field(name=name, value=text) embed.set_image(url=for_image) await ctx.send(embed=embed) # Any additional commands can be placed here. Be creative, but keep it to a reasonable amount! @command(name="snakerandom") - async def SnakeRandom(self, ctx: Context, name: str = None): + async def snake_random(self, ctx: Context, name: str = None): randsnake = random.choice(SNAKE_LIST) print(randsnake) @@ -83,17 +78,15 @@ async def SnakeRandom(self, ctx: Context, name: str = None): embed.add_field(name="Result", value="You got yourself a " + randsnake, inline=False) embed.add_field(name="Expectation", value=f"@{ctx.author} expected {name}", inline=False) - if randsnake == "python": - - return await ctx.send("Your a lucky dude !", embed=embed) + return await ctx.send("You're a lucky dude ! ", embed=embed) elif randsnake == "cobra": return await ctx.send("Good old cobra !", embed=embed) elif randsnake.startswith("blac"): return await ctx.send("Shiny liitle fella !", embed=embed) - @command(name="randname") - async def RandName(self, ctx: Context, name: str = None): + @command(name="randname")#this name generator randomply slics strings and joins them + async def Random_name(self, ctx: Context, name: str = None): snk = random.choice(SNAKE_LIST) snLen = len(snk) @@ -107,7 +100,43 @@ async def RandName(self, ctx: Context, name: str = None): return await ctx.send(result) + @command(name="namegen")#this name generator looks at vowels + async def name_generator(self, ctx: Context, name: str = None): + snk = random.choice(SNAKE_LIST) + s = name + str1 = "" + str2 = "" + for i in s: + str1 = i + str1 + + index2 = 0 + index1 = 0 + for index, char in enumerate(str1): + if char in 'aeiou': + + index1 = index + break + + name_index = len(s) - index1 + + name_sub_string = s[:name_index-1] + + snake = snk + for i in snake: + str2 = i + str2 + + + for index, char in enumerate(str2): + if char in 'aeiou': + + index2 = index + break + + sub_string_index = len(snake) - index2 + snake_sub_string = snake[1:sub_string_index] + + return await ctx.send(name_sub_string+snake_sub_string) def setup(bot): bot.add_cog(Snakes(bot)) - log.info("Cog loaded: Snakes") \ No newline at end of file + log.info("Cog loaded: Snakes") From 3d1bfbab56b1e8c2136a4a6a23bc0d86a9eb444f Mon Sep 17 00:00:00 2001 From: Rohan Date: Sun, 25 Mar 2018 20:59:03 +0530 Subject: [PATCH 22/29] reformatted --- bot/cogs/snakes.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/bot/cogs/snakes.py b/bot/cogs/snakes.py index 37ce74fc..8dde3d54 100644 --- a/bot/cogs/snakes.py +++ b/bot/cogs/snakes.py @@ -85,7 +85,7 @@ async def snake_random(self, ctx: Context, name: str = None): elif randsnake.startswith("blac"): return await ctx.send("Shiny liitle fella !", embed=embed) - @command(name="randname")#this name generator randomply slics strings and joins them + @command(name="randname") # this name generator randomply slics strings and joins them async def Random_name(self, ctx: Context, name: str = None): snk = random.choice(SNAKE_LIST) @@ -100,7 +100,7 @@ async def Random_name(self, ctx: Context, name: str = None): return await ctx.send(result) - @command(name="namegen")#this name generator looks at vowels + @command(name="namegen") # this name generator looks at vowels async def name_generator(self, ctx: Context, name: str = None): snk = random.choice(SNAKE_LIST) s = name @@ -113,29 +113,27 @@ async def name_generator(self, ctx: Context, name: str = None): index1 = 0 for index, char in enumerate(str1): if char in 'aeiou': - index1 = index break name_index = len(s) - index1 - name_sub_string = s[:name_index-1] + name_sub_string = s[:name_index - 1] snake = snk for i in snake: str2 = i + str2 - for index, char in enumerate(str2): if char in 'aeiou': - index2 = index break sub_string_index = len(snake) - index2 snake_sub_string = snake[1:sub_string_index] - return await ctx.send(name_sub_string+snake_sub_string) + return await ctx.send(name_sub_string + snake_sub_string) + def setup(bot): bot.add_cog(Snakes(bot)) From 79fbb86cfb6ae5fad5a09aa737ff4624c1c5a9de Mon Sep 17 00:00:00 2001 From: Rohan Date: Sun, 25 Mar 2018 21:18:11 +0530 Subject: [PATCH 23/29] final editing done !!! --- bot/cogs/snakes.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/bot/cogs/snakes.py b/bot/cogs/snakes.py index 8dde3d54..7ecebaa2 100644 --- a/bot/cogs/snakes.py +++ b/bot/cogs/snakes.py @@ -98,7 +98,13 @@ async def Random_name(self, ctx: Context, name: str = None): ranSnk = random.randint(1, snLen - 1) result = name[:ran] + snk[ranSnk:] - return await ctx.send(result) + embed = discord.Embed( + title="Random Name", + description="You're that is generated is " + result, + color=0x00ff00 + ) + embed.add_field(name="Snake", value="Your name was merged with the snake " + snk) + return await ctx.send(embed=embed) @command(name="namegen") # this name generator looks at vowels async def name_generator(self, ctx: Context, name: str = None): @@ -115,7 +121,7 @@ async def name_generator(self, ctx: Context, name: str = None): if char in 'aeiou': index1 = index break - + name_index = len(s) - index1 name_sub_string = s[:name_index - 1] @@ -131,8 +137,15 @@ async def name_generator(self, ctx: Context, name: str = None): sub_string_index = len(snake) - index2 snake_sub_string = snake[1:sub_string_index] + result = name_sub_string + snake_sub_string + embed = discord.Embed( + title="NAME GENERATOR", + description="You're that is generated is " + result, + color=0x00ff00 + ) + embed.add_field(name="Snake", value="Your name was merged with the snake " + snake) - return await ctx.send(name_sub_string + snake_sub_string) + return await ctx.send(embed=embed) def setup(bot): From c4975fa6449529b1c4eb6fd375a7898aa282049b Mon Sep 17 00:00:00 2001 From: Rohan Date: Sun, 25 Mar 2018 21:24:20 +0530 Subject: [PATCH 24/29] format --- bot/cogs/snakes.py | 1 - 1 file changed, 1 deletion(-) diff --git a/bot/cogs/snakes.py b/bot/cogs/snakes.py index 7ecebaa2..9811d012 100644 --- a/bot/cogs/snakes.py +++ b/bot/cogs/snakes.py @@ -97,7 +97,6 @@ async def Random_name(self, ctx: Context, name: str = None): ran = random.randint(1, p - 2) ranSnk = random.randint(1, snLen - 1) result = name[:ran] + snk[ranSnk:] - embed = discord.Embed( title="Random Name", description="You're that is generated is " + result, From c0b5b960d05981f8f16d2dbdca8fbea4628ad1f1 Mon Sep 17 00:00:00 2001 From: Rohan Date: Sun, 25 Mar 2018 21:28:43 +0530 Subject: [PATCH 25/29] format according to travis --- bot/cogs/snakes.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bot/cogs/snakes.py b/bot/cogs/snakes.py index 9811d012..d37e360d 100644 --- a/bot/cogs/snakes.py +++ b/bot/cogs/snakes.py @@ -1,10 +1,12 @@ # coding=utf-8 import logging -from typing import Any, Dict import random +from typing import Any, Dict +import wikipedia import discord + from discord.ext.commands import AutoShardedBot, Context, command -import wikipedia + log = logging.getLogger(__name__) @@ -26,7 +28,8 @@ async def get_snek(self, name: str = None) -> Dict[str, Any]: Go online and fetch information about a snake The information includes the name of the snake, a picture of the snake, and various other pieces of info. What information you get for the snake is up to you. Be creative! - If "python" is given as the snake name, you should return information about the programming language, but with + If "python" is given as the snake name, you should return information about the programming language, + but with all the information you'd provide for a real snake. Try to have some fun with this! :param name: Optional, the name of the snake to get information for - omit for a random snake :return: A dict containing information on a snake From a0154b76ac263226a7d8633277934146e9ccd843 Mon Sep 17 00:00:00 2001 From: Rohan Date: Sun, 25 Mar 2018 21:40:40 +0530 Subject: [PATCH 26/29] formatting --- bot/cogs/snakes.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bot/cogs/snakes.py b/bot/cogs/snakes.py index d37e360d..d4ea7c99 100644 --- a/bot/cogs/snakes.py +++ b/bot/cogs/snakes.py @@ -3,8 +3,8 @@ import random from typing import Any, Dict import wikipedia -import discord +from discord import Embed from discord.ext.commands import AutoShardedBot, Context, command @@ -54,14 +54,14 @@ async def get(self, ctx: Context, name: str = None): for_image = '' if name == "Python(Programming Language)": for_image = 'https://raw.githubusercontent.com/discord-python/branding/master/logos/logo_full.png' - embed = discord.Embed(title="Programming !!", color=0x00ff00) + embed = Embed(title="Programming !!", color=0x00ff00) embed.add_field(name=name, value=text) embed.set_image(url=for_image) await ctx.send(embed=embed) else: webpage = wikipedia.WikipediaPage(name) for_image = webpage.images[0] - embed = discord.Embed(title="Snake !!", color=0x00ff00) + embed = Embed(title="Snake !!", color=0x00ff00) embed.add_field(name=name, value=text) embed.set_image(url=for_image) await ctx.send(embed=embed) @@ -73,7 +73,7 @@ async def snake_random(self, ctx: Context, name: str = None): randsnake = random.choice(SNAKE_LIST) print(randsnake) - embed = discord.Embed( + embed = Embed( title="Snake Random !", description="lets see what snake you got !", color=0x00ff00, @@ -100,7 +100,7 @@ async def Random_name(self, ctx: Context, name: str = None): ran = random.randint(1, p - 2) ranSnk = random.randint(1, snLen - 1) result = name[:ran] + snk[ranSnk:] - embed = discord.Embed( + embed = Embed( title="Random Name", description="You're that is generated is " + result, color=0x00ff00 @@ -140,7 +140,7 @@ async def name_generator(self, ctx: Context, name: str = None): sub_string_index = len(snake) - index2 snake_sub_string = snake[1:sub_string_index] result = name_sub_string + snake_sub_string - embed = discord.Embed( + embed = Embed( title="NAME GENERATOR", description="You're that is generated is " + result, color=0x00ff00 From 530d761c9c7a6116b65e9625a1cbbe59f1fe06be Mon Sep 17 00:00:00 2001 From: Rohan Date: Sun, 25 Mar 2018 21:41:41 +0530 Subject: [PATCH 27/29] added to txi --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 028645b4..b843f5d7 100644 --- a/tox.ini +++ b/tox.ini @@ -2,3 +2,4 @@ max-line-length=120 application_import_names=bot exclude=.venv +import-order-style=pep8 From a5e5f22c47370b10c73095a58604dcbfcb9ce5cf Mon Sep 17 00:00:00 2001 From: Rohan Date: Sun, 25 Mar 2018 21:45:15 +0530 Subject: [PATCH 28/29] hopefully the format,plz travis --- bot/cogs/snakes.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bot/cogs/snakes.py b/bot/cogs/snakes.py index d4ea7c99..7eba9a09 100644 --- a/bot/cogs/snakes.py +++ b/bot/cogs/snakes.py @@ -2,9 +2,10 @@ import logging import random from typing import Any, Dict +from discord import Embed + import wikipedia -from discord import Embed from discord.ext.commands import AutoShardedBot, Context, command From f8b0862e6f71aa160dd62886974b40c73bdbaa5a Mon Sep 17 00:00:00 2001 From: Rohan Date: Sun, 25 Mar 2018 21:58:51 +0530 Subject: [PATCH 29/29] FINAL FORMAT --- bot/cogs/snakes.py | 3 +-- run.py | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/bot/cogs/snakes.py b/bot/cogs/snakes.py index 7eba9a09..3f4e669f 100644 --- a/bot/cogs/snakes.py +++ b/bot/cogs/snakes.py @@ -2,10 +2,9 @@ import logging import random from typing import Any, Dict -from discord import Embed +from discord import Embed import wikipedia - from discord.ext.commands import AutoShardedBot, Context, command diff --git a/run.py b/run.py index 2ec711fd..22edf4f2 100644 --- a/run.py +++ b/run.py @@ -2,7 +2,6 @@ import os from aiohttp import AsyncResolver, ClientSession, TCPConnector - from discord import Game from discord.ext.commands import AutoShardedBot, when_mentioned_or