From d796c4ba8afe3be3db845e1ca14482137d2bf721 Mon Sep 17 00:00:00 2001 From: RohanRadia Date: Thu, 4 Apr 2019 00:35:44 +0100 Subject: Created conversationstarters and created a convo_starter command easter --- conversationstarters.py | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 conversationstarters.py diff --git a/conversationstarters.py b/conversationstarters.py new file mode 100644 index 00000000..7c1fe860 --- /dev/null +++ b/conversationstarters.py @@ -0,0 +1,50 @@ +import logging +import random +from pathlib import Path + +from discord.ext import commands + +log = logging.getLogger(__name__) + +starters = [ + 'What is your favourite Easter candy or treat?', + 'What is your earliest memory of Easter?', + 'What is the title of the last book you read?', + 'What is better: Milk, Dark or White chocolate?', + 'What is your favourite holiday?', + 'If you could have any superpower, what would it be?', + 'Name one thing you like about a person to your right.', + 'If you could be anyone else for one day, who would it be?', + 'What Easter tradition do you enjoy most?', + "What is the best gift you've been given?", + 'Name one famous person you would like to have at your easter dinner.', + 'What was the last movie you saw in a cinema?', + 'What is your favourite food?', + 'If you could travel anywhere in the world, where would you go?', + 'Tell us 5 things you do well.', + 'What is your favourite place that you have visited?', + 'What is your favourite color?', + 'If you had $100 bill in your Easter Basket, what would you do with it?', + 'What would you do if you know you could succeed at anything you chose to do?', + 'If you could take only three things from your house, what would they be?' +] + + +class ConvoStarters(commands.Cog): + """A cog which posts easter conversation starters""" + + def __init__(self, bot): + self.bot = bot + + @commands.command(aliases=('conversation_starters', 'convo_starters')) + async def convo_starter(self, ctx): + """Responds with a random conversation starter""" + + await ctx.send(f"{random.choice(starters)}") + + +def setup(bot): + """ConversationStarters Cog load.""" + + bot.add_cog(ConvoStarters(bot)) + log.info("ConversationStarters cog loaded") -- cgit v1.2.3 From 9bf62aaac818edd58d4dd2d6e84a5dbdb4468ea3 Mon Sep 17 00:00:00 2001 From: RohanRadia Date: Thu, 4 Apr 2019 00:42:48 +0100 Subject: Fixed flake8 formatting. --- conversationstarters.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/conversationstarters.py b/conversationstarters.py index 7c1fe860..9713598c 100644 --- a/conversationstarters.py +++ b/conversationstarters.py @@ -1,6 +1,5 @@ import logging import random -from pathlib import Path from discord.ext import commands @@ -44,7 +43,7 @@ class ConvoStarters(commands.Cog): def setup(bot): - """ConversationStarters Cog load.""" + """Conversation starters Cog load.""" bot.add_cog(ConvoStarters(bot)) - log.info("ConversationStarters cog loaded") + log.info("Conversation starters cog loaded") -- cgit v1.2.3 From 6dc9b4e7b232c095cb07108d5a37e075af50d2ee Mon Sep 17 00:00:00 2001 From: RohanRadia Date: Thu, 4 Apr 2019 13:17:41 +0100 Subject: JSON file to store all conversation starters in as requested. --- bot/resources/easter/starter.json | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 bot/resources/easter/starter.json diff --git a/bot/resources/easter/starter.json b/bot/resources/easter/starter.json new file mode 100644 index 00000000..31e2cbc9 --- /dev/null +++ b/bot/resources/easter/starter.json @@ -0,0 +1,24 @@ +{ + "starters": [ + "What is your favourite Easter candy or treat?", + "What is your earliest memory of Easter?", + "What is the title of the last book you read?", + "What is better: Milk, Dark or White chocolate?", + "What is your favourite holiday?", + "If you could have any superpower, what would it be?", + "Name one thing you like about a person to your right.", + "If you could be anyone else for one day, who would it be?", + "What Easter tradition do you enjoy most?", + "What is the best gift you've been given?", + "Name one famous person you would like to have at your easter dinner.", + "What was the last movie you saw in a cinema?", + "What is your favourite food?", + "If you could travel anywhere in the world, where would you go?", + "Tell us 5 things you do well.", + "What is your favourite place that you have visited?", + "What is your favourite color?", + "If you had $100 bill in your Easter Basket, what would you do with it?", + "What would you do if you know you could succeed at anything you chose to do?", + "If you could take only three things from your house, what would they be?" + ] +} -- cgit v1.2.3 From 9e2da79fcd5e0d54f13459cd8301631789719ef2 Mon Sep 17 00:00:00 2001 From: RohanRadia Date: Thu, 4 Apr 2019 13:17:58 +0100 Subject: Updated the file and added dependancies for accesing the new JSON file --- conversationstarters.py | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/conversationstarters.py b/conversationstarters.py index 9713598c..38226557 100644 --- a/conversationstarters.py +++ b/conversationstarters.py @@ -1,32 +1,14 @@ +import json import logging import random +from pathlib import Path from discord.ext import commands log = logging.getLogger(__name__) -starters = [ - 'What is your favourite Easter candy or treat?', - 'What is your earliest memory of Easter?', - 'What is the title of the last book you read?', - 'What is better: Milk, Dark or White chocolate?', - 'What is your favourite holiday?', - 'If you could have any superpower, what would it be?', - 'Name one thing you like about a person to your right.', - 'If you could be anyone else for one day, who would it be?', - 'What Easter tradition do you enjoy most?', - "What is the best gift you've been given?", - 'Name one famous person you would like to have at your easter dinner.', - 'What was the last movie you saw in a cinema?', - 'What is your favourite food?', - 'If you could travel anywhere in the world, where would you go?', - 'Tell us 5 things you do well.', - 'What is your favourite place that you have visited?', - 'What is your favourite color?', - 'If you had $100 bill in your Easter Basket, what would you do with it?', - 'What would you do if you know you could succeed at anything you chose to do?', - 'If you could take only three things from your house, what would they be?' -] +with open(Path('bot', 'resources', 'easter', 'starter.json'), 'r', encoding="utf8") as f: + starters = json.load(f) class ConvoStarters(commands.Cog): @@ -39,7 +21,7 @@ class ConvoStarters(commands.Cog): async def convo_starter(self, ctx): """Responds with a random conversation starter""" - await ctx.send(f"{random.choice(starters)}") + await ctx.send(f"{random.choice(starters['starters'])}") def setup(bot): -- cgit v1.2.3 From ed863cdbcc4d79bfc374d146973d594cb8181972 Mon Sep 17 00:00:00 2001 From: scragly <29337040+scragly@users.noreply.github.com> Date: Thu, 4 Apr 2019 13:59:12 +0100 Subject: Changed 'starters' -> 'topic' Co-Authored-By: RohanRadia --- conversationstarters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conversationstarters.py b/conversationstarters.py index 38226557..064c67d2 100644 --- a/conversationstarters.py +++ b/conversationstarters.py @@ -12,7 +12,7 @@ with open(Path('bot', 'resources', 'easter', 'starter.json'), 'r', encoding="utf class ConvoStarters(commands.Cog): - """A cog which posts easter conversation starters""" + """Easter conversation topics.""" def __init__(self, bot): self.bot = bot -- cgit v1.2.3 From 9540279bdcd9990acd514ca82aed20d09d7facf1 Mon Sep 17 00:00:00 2001 From: scragly <29337040+scragly@users.noreply.github.com> Date: Thu, 4 Apr 2019 13:59:25 +0100 Subject: Changed 'starters' -> 'topic' Co-Authored-By: RohanRadia --- conversationstarters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conversationstarters.py b/conversationstarters.py index 064c67d2..251f798f 100644 --- a/conversationstarters.py +++ b/conversationstarters.py @@ -19,7 +19,7 @@ class ConvoStarters(commands.Cog): @commands.command(aliases=('conversation_starters', 'convo_starters')) async def convo_starter(self, ctx): - """Responds with a random conversation starter""" + """Responds with a random topic to start a conversation.""" await ctx.send(f"{random.choice(starters['starters'])}") -- cgit v1.2.3 From 9b69f5dca8463e136bb71ffe9adb455a391156d4 Mon Sep 17 00:00:00 2001 From: scragly <29337040+scragly@users.noreply.github.com> Date: Thu, 4 Apr 2019 13:59:56 +0100 Subject: Changed 'starters' -> 'topic' Co-Authored-By: RohanRadia --- conversationstarters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conversationstarters.py b/conversationstarters.py index 251f798f..ef0fbc2c 100644 --- a/conversationstarters.py +++ b/conversationstarters.py @@ -28,4 +28,4 @@ def setup(bot): """Conversation starters Cog load.""" bot.add_cog(ConvoStarters(bot)) - log.info("Conversation starters cog loaded") + log.info("ConvoStarters cog loaded") -- cgit v1.2.3 From e6d6b87a49473cacb54b0d6f7f9af7cc6e32bcb6 Mon Sep 17 00:00:00 2001 From: scragly <29337040+scragly@users.noreply.github.com> Date: Thu, 4 Apr 2019 14:00:37 +0100 Subject: Removed f-string Co-Authored-By: RohanRadia --- conversationstarters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conversationstarters.py b/conversationstarters.py index ef0fbc2c..4a2a3527 100644 --- a/conversationstarters.py +++ b/conversationstarters.py @@ -21,7 +21,7 @@ class ConvoStarters(commands.Cog): async def convo_starter(self, ctx): """Responds with a random topic to start a conversation.""" - await ctx.send(f"{random.choice(starters['starters'])}") + await ctx.send(random.choice(starters['starters'])) def setup(bot): -- cgit v1.2.3 From 1d052ece960f9fb518ee4f35ab290d5d0b252892 Mon Sep 17 00:00:00 2001 From: scragly <29337040+scragly@users.noreply.github.com> Date: Thu, 4 Apr 2019 14:00:55 +0100 Subject: Removed aliases Co-Authored-By: RohanRadia --- conversationstarters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conversationstarters.py b/conversationstarters.py index 4a2a3527..0c2df1c7 100644 --- a/conversationstarters.py +++ b/conversationstarters.py @@ -17,7 +17,7 @@ class ConvoStarters(commands.Cog): def __init__(self, bot): self.bot = bot - @commands.command(aliases=('conversation_starters', 'convo_starters')) + @commands.command() async def convo_starter(self, ctx): """Responds with a random topic to start a conversation.""" -- cgit v1.2.3 From 9ff61f25a624bd11f9f882b49bc846c73b204018 Mon Sep 17 00:00:00 2001 From: scragly <29337040+scragly@users.noreply.github.com> Date: Thu, 4 Apr 2019 14:01:34 +0100 Subject: Changed 'starters' -> 'topic' Co-Authored-By: RohanRadia --- conversationstarters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conversationstarters.py b/conversationstarters.py index 0c2df1c7..b479406b 100644 --- a/conversationstarters.py +++ b/conversationstarters.py @@ -18,7 +18,7 @@ class ConvoStarters(commands.Cog): self.bot = bot @commands.command() - async def convo_starter(self, ctx): + async def topic(self, ctx): """Responds with a random topic to start a conversation.""" await ctx.send(random.choice(starters['starters'])) -- cgit v1.2.3 From b58def41b6b30d0291d99eec434fdcf4c98a7fed Mon Sep 17 00:00:00 2001 From: RohanRadia Date: Thu, 4 Apr 2019 14:11:45 +0100 Subject: Just changed the conversation starters directory. --- bot/seasons/easter/conversationstarters.py | 31 ++++++++++++++++++++++++++++++ conversationstarters.py | 31 ------------------------------ 2 files changed, 31 insertions(+), 31 deletions(-) create mode 100644 bot/seasons/easter/conversationstarters.py delete mode 100644 conversationstarters.py diff --git a/bot/seasons/easter/conversationstarters.py b/bot/seasons/easter/conversationstarters.py new file mode 100644 index 00000000..b479406b --- /dev/null +++ b/bot/seasons/easter/conversationstarters.py @@ -0,0 +1,31 @@ +import json +import logging +import random +from pathlib import Path + +from discord.ext import commands + +log = logging.getLogger(__name__) + +with open(Path('bot', 'resources', 'easter', 'starter.json'), 'r', encoding="utf8") as f: + starters = json.load(f) + + +class ConvoStarters(commands.Cog): + """Easter conversation topics.""" + + def __init__(self, bot): + self.bot = bot + + @commands.command() + async def topic(self, ctx): + """Responds with a random topic to start a conversation.""" + + await ctx.send(random.choice(starters['starters'])) + + +def setup(bot): + """Conversation starters Cog load.""" + + bot.add_cog(ConvoStarters(bot)) + log.info("ConvoStarters cog loaded") diff --git a/conversationstarters.py b/conversationstarters.py deleted file mode 100644 index b479406b..00000000 --- a/conversationstarters.py +++ /dev/null @@ -1,31 +0,0 @@ -import json -import logging -import random -from pathlib import Path - -from discord.ext import commands - -log = logging.getLogger(__name__) - -with open(Path('bot', 'resources', 'easter', 'starter.json'), 'r', encoding="utf8") as f: - starters = json.load(f) - - -class ConvoStarters(commands.Cog): - """Easter conversation topics.""" - - def __init__(self, bot): - self.bot = bot - - @commands.command() - async def topic(self, ctx): - """Responds with a random topic to start a conversation.""" - - await ctx.send(random.choice(starters['starters'])) - - -def setup(bot): - """Conversation starters Cog load.""" - - bot.add_cog(ConvoStarters(bot)) - log.info("ConvoStarters cog loaded") -- cgit v1.2.3