Compare commits
92 Commits
ww_develop
...
master
Author | SHA1 | Date | |
---|---|---|---|
![]() |
0aaffbf5f0 | ||
![]() |
771d1457e5 | ||
![]() |
d191abf6bd | ||
![]() |
aba9840bcb | ||
![]() |
0064e6e9b5 | ||
![]() |
955624ad1a | ||
![]() |
a6e0646b85 | ||
![]() |
269266ce04 | ||
![]() |
db3ce30122 | ||
![]() |
1e87eacf83 | ||
![]() |
61fa006e33 | ||
![]() |
4183607372 | ||
![]() |
2421c4e9bf | ||
![]() |
b2e843e781 | ||
![]() |
a7ce815e14 | ||
![]() |
1e535c2f3e | ||
![]() |
fd80819618 | ||
![]() |
a5ff888f4c | ||
![]() |
3eb499bf0e | ||
![]() |
698dafade4 | ||
![]() |
15ecf72c64 | ||
![]() |
1d514f80c6 | ||
![]() |
b752bfd153 | ||
![]() |
47269ba8f4 | ||
![]() |
e0a361b952 | ||
![]() |
2a18760a83 | ||
![]() |
b26afdf2db | ||
![]() |
86cc1fa35a | ||
![]() |
b331238c1c | ||
![]() |
6f0c88b1ac | ||
![]() |
c165313031 | ||
![]() |
9c63c12656 | ||
![]() |
a55ae8a511 | ||
![]() |
1ffac638ed | ||
![]() |
5b75002c88 | ||
![]() |
7c08a5de0c | ||
![]() |
bc12aa866e | ||
![]() |
dbafd6ffd7 | ||
![]() |
52ca2f6a45 | ||
![]() |
2937b6ac92 | ||
![]() |
dbf84c8b81 | ||
![]() |
2f21de6a97 | ||
![]() |
ed6cc433c8 | ||
![]() |
e1a30359d8 | ||
![]() |
506a79c6d6 | ||
![]() |
1ddcd98078 | ||
![]() |
7bd004c78e | ||
![]() |
184833421a | ||
![]() |
f04ff6886b | ||
![]() |
28edcc1fdd | ||
![]() |
10ed1f9b9f | ||
![]() |
93b403b35f | ||
![]() |
5f30bc1234 | ||
![]() |
9f22dfb790 | ||
![]() |
ea126db0c5 | ||
![]() |
e1297a4dca | ||
![]() |
87187abbb3 | ||
![]() |
db24bb4db4 | ||
![]() |
1319d98972 | ||
![]() |
802929d757 | ||
![]() |
59fd96fc5a | ||
![]() |
b4f20dd7d2 | ||
![]() |
ac9cf1e589 | ||
![]() |
8feb21e34b | ||
![]() |
04ccb435f8 | ||
![]() |
eac7aee82c | ||
![]() |
8200cd9af1 | ||
![]() |
ff9610ff77 | ||
![]() |
95931d24f3 | ||
![]() |
dad14fe972 | ||
![]() |
ea88addc42 | ||
![]() |
0475b18437 | ||
![]() |
7811c71edb | ||
![]() |
8acbc5d964 | ||
![]() |
59090b9eaa | ||
![]() |
11eb4a9dbf | ||
![]() |
d32de1586f | ||
![]() |
578ea4a555 | ||
![]() |
920f8817d7 | ||
![]() |
42bdc64028 | ||
![]() |
f7dad0aa3f | ||
![]() |
cc199c395d | ||
![]() |
5a26b48fda | ||
![]() |
bf9115e13c | ||
![]() |
337def2fa3 | ||
![]() |
14f8b825d8 | ||
![]() |
4634210960 | ||
![]() |
a6ebe02233 | ||
![]() |
26234e3b18 | ||
![]() |
37c699eeee | ||
![]() |
960b66a5b8 | ||
![]() |
762b0fd320 |
@ -53,7 +53,7 @@ Check out *Deprecated* my V2 cogs at [Fox-Cogs v2](https://github.com/bobloy/Fox
|
|||||||
# Contact
|
# Contact
|
||||||
Get support on the [Third Party Cog Server](https://discord.gg/GET4DVk)
|
Get support on the [Third Party Cog Server](https://discord.gg/GET4DVk)
|
||||||
|
|
||||||
Feel free to @ me in the #support_othercogs channel
|
Feel free to @ me in the #support_fox-v3 channel
|
||||||
|
|
||||||
Discord: Bobloy#6513
|
Discord: Bobloy#6513
|
||||||
|
|
||||||
|
@ -54,7 +54,6 @@ class AnnounceDaily(Cog):
|
|||||||
|
|
||||||
Do `[p]help annd <subcommand>` for more details
|
Do `[p]help annd <subcommand>` for more details
|
||||||
"""
|
"""
|
||||||
if ctx.invoked_subcommand is None:
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
|
@ -168,7 +168,7 @@ class AudioTrivia(Trivia):
|
|||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
async def audiotrivia_list(self, ctx: commands.Context):
|
async def audiotrivia_list(self, ctx: commands.Context):
|
||||||
"""List available trivia including audio categories."""
|
"""List available trivia including audio categories."""
|
||||||
lists = set(p.stem for p in self._all_audio_lists())
|
lists = {p.stem for p in self._all_audio_lists()}
|
||||||
if await ctx.embed_requested():
|
if await ctx.embed_requested():
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
embed=discord.Embed(
|
embed=discord.Embed(
|
||||||
|
@ -3,6 +3,7 @@ import logging
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
|
from discord.ext.commands import RoleConverter, Greedy, CommandError, ArgumentParsingError
|
||||||
from discord.ext.commands.view import StringView
|
from discord.ext.commands.view import StringView
|
||||||
from redbot.core import Config, checks, commands
|
from redbot.core import Config, checks, commands
|
||||||
from redbot.core.bot import Red
|
from redbot.core.bot import Red
|
||||||
@ -13,15 +14,38 @@ log = logging.getLogger("red.fox_v3.ccrole")
|
|||||||
|
|
||||||
|
|
||||||
async def _get_roles_from_content(ctx, content):
|
async def _get_roles_from_content(ctx, content):
|
||||||
content_list = content.split(",")
|
# greedy = Greedy[RoleConverter]
|
||||||
|
view = StringView(content)
|
||||||
|
rc = RoleConverter()
|
||||||
|
|
||||||
|
# "Borrowed" from discord.ext.commands.Command._transform_greedy_pos
|
||||||
|
result = []
|
||||||
|
while not view.eof:
|
||||||
|
# for use with a manual undo
|
||||||
|
previous = view.index
|
||||||
|
|
||||||
|
view.skip_ws()
|
||||||
try:
|
try:
|
||||||
role_list = [
|
argument = view.get_quoted_word()
|
||||||
discord.utils.get(ctx.guild.roles, name=role.strip(" ")).id for role in content_list
|
value = await rc.convert(ctx, argument)
|
||||||
]
|
except (CommandError, ArgumentParsingError):
|
||||||
except (discord.HTTPException, AttributeError): # None.id is attribute error
|
view.index = previous
|
||||||
return None
|
break
|
||||||
else:
|
else:
|
||||||
return role_list
|
result.append(value)
|
||||||
|
|
||||||
|
return [r.id for r in result]
|
||||||
|
|
||||||
|
# Old method
|
||||||
|
# content_list = content.split(",")
|
||||||
|
# try:
|
||||||
|
# role_list = [
|
||||||
|
# discord.utils.get(ctx.guild.roles, name=role.strip(" ")).id for role in content_list
|
||||||
|
# ]
|
||||||
|
# except (discord.HTTPException, AttributeError): # None.id is attribute error
|
||||||
|
# return None
|
||||||
|
# else:
|
||||||
|
# return role_list
|
||||||
|
|
||||||
|
|
||||||
class CCRole(commands.Cog):
|
class CCRole(commands.Cog):
|
||||||
@ -48,7 +72,6 @@ class CCRole(commands.Cog):
|
|||||||
"""Custom commands management with roles
|
"""Custom commands management with roles
|
||||||
|
|
||||||
Highly customizable custom commands with role management."""
|
Highly customizable custom commands with role management."""
|
||||||
if not ctx.invoked_subcommand:
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ccrole.command(name="add")
|
@ccrole.command(name="add")
|
||||||
@ -85,7 +108,7 @@ class CCRole(commands.Cog):
|
|||||||
|
|
||||||
# Roles to add
|
# Roles to add
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
"What roles should it add? (Must be **comma separated**)\n"
|
"What roles should it add?\n"
|
||||||
"Say `None` to skip adding roles"
|
"Say `None` to skip adding roles"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -107,7 +130,7 @@ class CCRole(commands.Cog):
|
|||||||
|
|
||||||
# Roles to remove
|
# Roles to remove
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
"What roles should it remove? (Must be comma separated)\n"
|
"What roles should it remove?\n"
|
||||||
"Say `None` to skip removing roles"
|
"Say `None` to skip removing roles"
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
@ -125,7 +148,7 @@ class CCRole(commands.Cog):
|
|||||||
|
|
||||||
# Roles to use
|
# Roles to use
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
"What roles are allowed to use this command? (Must be comma separated)\n"
|
"What roles are allowed to use this command?\n"
|
||||||
"Say `None` to allow all roles"
|
"Say `None` to allow all roles"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -228,7 +251,7 @@ class CCRole(commands.Cog):
|
|||||||
if not role_list:
|
if not role_list:
|
||||||
return "None"
|
return "None"
|
||||||
return ", ".join(
|
return ", ".join(
|
||||||
[discord.utils.get(ctx.guild.roles, id=roleid).name for roleid in role_list]
|
discord.utils.get(ctx.guild.roles, id=roleid).name for roleid in role_list
|
||||||
)
|
)
|
||||||
|
|
||||||
embed.add_field(name="Text", value="```{}```".format(cmd["text"]), inline=False)
|
embed.add_field(name="Text", value="```{}```".format(cmd["text"]), inline=False)
|
||||||
@ -252,7 +275,7 @@ class CCRole(commands.Cog):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
cmd_list = ", ".join([ctx.prefix + c for c in sorted(cmd_list.keys())])
|
cmd_list = ", ".join(ctx.prefix + c for c in sorted(cmd_list.keys()))
|
||||||
cmd_list = "Custom commands:\n\n" + cmd_list
|
cmd_list = "Custom commands:\n\n" + cmd_list
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@ -325,9 +348,7 @@ class CCRole(commands.Cog):
|
|||||||
|
|
||||||
async def eval_cc(self, cmd, message: discord.Message, ctx: commands.Context):
|
async def eval_cc(self, cmd, message: discord.Message, ctx: commands.Context):
|
||||||
"""Does all the work"""
|
"""Does all the work"""
|
||||||
if cmd["proles"] and not (
|
if cmd["proles"] and not {role.id for role in message.author.roles} & set(cmd["proles"]):
|
||||||
set(role.id for role in message.author.roles) & set(cmd["proles"])
|
|
||||||
):
|
|
||||||
log.debug(f"{message.author} missing required role to execute {ctx.invoked_with}")
|
log.debug(f"{message.author} missing required role to execute {ctx.invoked_with}")
|
||||||
return # Not authorized, do nothing
|
return # Not authorized, do nothing
|
||||||
|
|
||||||
|
@ -59,63 +59,50 @@ Install these on your windows machine before attempting the installation:
|
|||||||
[Pandoc - Universal Document Converter](https://pandoc.org/installing.html)
|
[Pandoc - Universal Document Converter](https://pandoc.org/installing.html)
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
### Windows - Manually
|
### Automatic
|
||||||
#### Step 1: Built-in Downloader
|
|
||||||
|
|
||||||
You need to get a copy of the requirements.txt provided with chatter, I recommend this method.
|
This method requires some luck to pull off.
|
||||||
|
|
||||||
|
#### Step 1: Add repo and install cog
|
||||||
|
|
||||||
```
|
```
|
||||||
[p]repo add Fox https://github.com/bobloy/Fox-V3
|
[p]repo add Fox https://github.com/bobloy/Fox-V3
|
||||||
```
|
|
||||||
|
|
||||||
#### Step 2: Install Requirements
|
|
||||||
|
|
||||||
Make sure you have your virtual environment that you installed Red on activated before starting this step. See the Red Docs for details on how.
|
|
||||||
|
|
||||||
In a terminal running as an admin, navigate to the directory containing this repo.
|
|
||||||
|
|
||||||
I've used my install directory as an example.
|
|
||||||
|
|
||||||
```
|
|
||||||
cd C:\Users\Bobloy\AppData\Local\Red-DiscordBot\Red-DiscordBot\data\bobbot\cogs\RepoManager\repos\Fox\chatter
|
|
||||||
pip install -r requirements.txt
|
|
||||||
pip install --no-deps "chatterbot>=1.1"
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Step 3: Load Chatter
|
|
||||||
|
|
||||||
```
|
|
||||||
[p]repo add Fox https://github.com/bobloy/Fox-V3 # If you didn't already do this in step 1
|
|
||||||
[p]cog install Fox chatter
|
[p]cog install Fox chatter
|
||||||
|
```
|
||||||
|
|
||||||
|
If you get an error at this step, stop and skip to one of the manual methods below.
|
||||||
|
|
||||||
|
#### Step 2: Install additional dependencies
|
||||||
|
|
||||||
|
Here you need to decide which training models you want to have available to you.
|
||||||
|
|
||||||
|
Shutdown the bot and run any number of these in the console:
|
||||||
|
|
||||||
|
```
|
||||||
|
python -m spacy download en_core_web_sm # ~15 MB
|
||||||
|
|
||||||
|
python -m spacy download en_core_web_md # ~50 MB
|
||||||
|
|
||||||
|
python -m spacy download en_core_web_lg # ~750 MB (CPU Optimized)
|
||||||
|
|
||||||
|
python -m spacy download en_core_web_trf # ~500 MB (GPU Optimized)
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Step 3: Load the cog and get started
|
||||||
|
|
||||||
|
```
|
||||||
[p]load chatter
|
[p]load chatter
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Windows - Manually
|
||||||
|
Deprecated
|
||||||
|
|
||||||
### Linux - Manually
|
### Linux - Manually
|
||||||
|
Deprecated
|
||||||
#### Step 1: Built-in Downloader
|
|
||||||
|
|
||||||
```
|
|
||||||
[p]repo add Fox https://github.com/bobloy/Fox-V3
|
|
||||||
[p]cog install Fox chatter
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Step 2: Install Requirements
|
|
||||||
|
|
||||||
In your console with your virtual environment activated:
|
|
||||||
|
|
||||||
```
|
|
||||||
pip install --no-deps "chatterbot>=1.1"
|
|
||||||
```
|
|
||||||
|
|
||||||
### Step 3: Load Chatter
|
|
||||||
|
|
||||||
```
|
|
||||||
[p]load chatter
|
|
||||||
```
|
|
||||||
|
|
||||||
# Configuration
|
# Configuration
|
||||||
|
|
||||||
Chatter works out the the box without any training by learning as it goes,
|
Chatter works out the box without any training by learning as it goes,
|
||||||
but will have very poor and repetitive responses at first.
|
but will have very poor and repetitive responses at first.
|
||||||
|
|
||||||
Initial training is recommended to speed up its learning.
|
Initial training is recommended to speed up its learning.
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
from .chat import Chatter
|
from .chat import Chatter
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
async def setup(bot):
|
||||||
bot.add_cog(Chatter(bot))
|
cog = Chatter(bot)
|
||||||
|
await cog.initialize()
|
||||||
|
bot.add_cog(cog)
|
||||||
|
|
||||||
|
|
||||||
# __all__ = (
|
# __all__ = (
|
||||||
|
398
chatter/chat.py
398
chatter/chat.py
@ -2,8 +2,10 @@ import asyncio
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
|
from collections import defaultdict
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from typing import Optional
|
from functools import partial
|
||||||
|
from typing import Dict, List, Optional
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
from chatterbot import ChatBot
|
from chatterbot import ChatBot
|
||||||
@ -15,6 +17,9 @@ from redbot.core.commands import Cog
|
|||||||
from redbot.core.data_manager import cog_data_path
|
from redbot.core.data_manager import cog_data_path
|
||||||
from redbot.core.utils.predicates import MessagePredicate
|
from redbot.core.utils.predicates import MessagePredicate
|
||||||
|
|
||||||
|
from chatter.trainers import MovieTrainer, TwitterCorpusTrainer, UbuntuCorpusTrainer2
|
||||||
|
|
||||||
|
chatterbot_log = logging.getLogger("red.fox_v3.chatterbot")
|
||||||
log = logging.getLogger("red.fox_v3.chatter")
|
log = logging.getLogger("red.fox_v3.chatter")
|
||||||
|
|
||||||
|
|
||||||
@ -25,6 +30,12 @@ def my_local_get_prefix(prefixes, content):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
class ENG_TRF:
|
||||||
|
ISO_639_1 = "en_core_web_trf"
|
||||||
|
ISO_639 = "eng"
|
||||||
|
ENGLISH_NAME = "English"
|
||||||
|
|
||||||
|
|
||||||
class ENG_LG:
|
class ENG_LG:
|
||||||
ISO_639_1 = "en_core_web_lg"
|
ISO_639_1 = "en_core_web_lg"
|
||||||
ISO_639 = "eng"
|
ISO_639 = "eng"
|
||||||
@ -48,50 +59,77 @@ class Chatter(Cog):
|
|||||||
This cog trains a chatbot that will talk like members of your Guild
|
This cog trains a chatbot that will talk like members of your Guild
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
models = [ENG_SM, ENG_MD, ENG_LG, ENG_TRF]
|
||||||
|
algos = [SpacySimilarity, JaccardSimilarity, LevenshteinDistance]
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.config = Config.get_conf(self, identifier=6710497116116101114)
|
self.config = Config.get_conf(self, identifier=6710497116116101114)
|
||||||
default_global = {}
|
default_global = {"learning": True, "model_number": 0, "algo_number": 0, "threshold": 0.90}
|
||||||
default_guild = {"whitelist": None, "days": 1, "convo_delta": 15, "chatchannel": None}
|
self.default_guild = {
|
||||||
|
"whitelist": None,
|
||||||
|
"days": 1,
|
||||||
|
"convo_delta": 15,
|
||||||
|
"chatchannel": None,
|
||||||
|
"reply": True,
|
||||||
|
}
|
||||||
path: pathlib.Path = cog_data_path(self)
|
path: pathlib.Path = cog_data_path(self)
|
||||||
self.data_path = path / "database.sqlite3"
|
self.data_path = path / "database.sqlite3"
|
||||||
|
|
||||||
# TODO: Move training_model and similarity_algo to config
|
# TODO: Move training_model and similarity_algo to config
|
||||||
# TODO: Add an option to see current settings
|
# TODO: Add an option to see current settings
|
||||||
|
|
||||||
self.tagger_language = ENG_MD
|
self.tagger_language = ENG_SM
|
||||||
self.similarity_algo = SpacySimilarity
|
self.similarity_algo = SpacySimilarity
|
||||||
self.similarity_threshold = 0.90
|
self.similarity_threshold = 0.90
|
||||||
self.chatbot = self._create_chatbot()
|
self.chatbot = None
|
||||||
# self.chatbot.set_trainer(ListTrainer)
|
# self.chatbot.set_trainer(ListTrainer)
|
||||||
|
|
||||||
# self.trainer = ListTrainer(self.chatbot)
|
# self.trainer = ListTrainer(self.chatbot)
|
||||||
|
|
||||||
self.config.register_global(**default_global)
|
self.config.register_global(**default_global)
|
||||||
self.config.register_guild(**default_guild)
|
self.config.register_guild(**self.default_guild)
|
||||||
|
|
||||||
self.loop = asyncio.get_event_loop()
|
self.loop = asyncio.get_event_loop()
|
||||||
|
|
||||||
|
self._guild_cache = defaultdict(dict)
|
||||||
|
self._global_cache = {}
|
||||||
|
|
||||||
|
self._last_message_per_channel: Dict[Optional[discord.Message]] = defaultdict(lambda: None)
|
||||||
|
|
||||||
async def red_delete_data_for_user(self, **kwargs):
|
async def red_delete_data_for_user(self, **kwargs):
|
||||||
"""Nothing to delete"""
|
"""Nothing to delete"""
|
||||||
return
|
return
|
||||||
|
|
||||||
|
async def initialize(self):
|
||||||
|
all_config = dict(self.config.defaults["GLOBAL"])
|
||||||
|
all_config.update(await self.config.all())
|
||||||
|
model_number = all_config["model_number"]
|
||||||
|
algo_number = all_config["algo_number"]
|
||||||
|
threshold = all_config["threshold"]
|
||||||
|
|
||||||
|
self.tagger_language = self.models[model_number]
|
||||||
|
self.similarity_algo = self.algos[algo_number]
|
||||||
|
self.similarity_threshold = threshold
|
||||||
|
self.chatbot = self._create_chatbot()
|
||||||
|
|
||||||
def _create_chatbot(self):
|
def _create_chatbot(self):
|
||||||
|
|
||||||
return ChatBot(
|
return ChatBot(
|
||||||
"ChatterBot",
|
"ChatterBot",
|
||||||
storage_adapter="chatterbot.storage.SQLStorageAdapter",
|
# storage_adapter="chatterbot.storage.SQLStorageAdapter",
|
||||||
|
storage_adapter="chatter.storage_adapters.MyDumbSQLStorageAdapter",
|
||||||
database_uri="sqlite:///" + str(self.data_path),
|
database_uri="sqlite:///" + str(self.data_path),
|
||||||
statement_comparison_function=self.similarity_algo,
|
statement_comparison_function=self.similarity_algo,
|
||||||
response_selection_method=get_random_response,
|
response_selection_method=get_random_response,
|
||||||
logic_adapters=["chatterbot.logic.BestMatch"],
|
logic_adapters=["chatterbot.logic.BestMatch"],
|
||||||
maximum_similarity_threshold=self.similarity_threshold,
|
maximum_similarity_threshold=self.similarity_threshold,
|
||||||
tagger_language=self.tagger_language,
|
tagger_language=self.tagger_language,
|
||||||
logger=log,
|
logger=chatterbot_log,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def _get_conversation(self, ctx, in_channel: discord.TextChannel = None):
|
async def _get_conversation(self, ctx, in_channels: List[discord.TextChannel]):
|
||||||
"""
|
"""
|
||||||
Compiles all conversation in the Guild this bot can get it's hands on
|
Compiles all conversation in the Guild this bot can get it's hands on
|
||||||
Currently takes a stupid long time
|
Currently takes a stupid long time
|
||||||
@ -105,20 +143,12 @@ class Chatter(Cog):
|
|||||||
return msg.clean_content
|
return msg.clean_content
|
||||||
|
|
||||||
def new_conversation(msg, sent, out_in, delta):
|
def new_conversation(msg, sent, out_in, delta):
|
||||||
# if sent is None:
|
# Should always be positive numbers
|
||||||
# return False
|
|
||||||
|
|
||||||
# Don't do "too short" processing here. Sometimes people don't respond.
|
|
||||||
# if len(out_in) < 2:
|
|
||||||
# return False
|
|
||||||
|
|
||||||
# print(msg.created_at - sent)
|
|
||||||
|
|
||||||
return msg.created_at - sent >= delta
|
return msg.created_at - sent >= delta
|
||||||
|
|
||||||
for channel in ctx.guild.text_channels:
|
for channel in in_channels:
|
||||||
if in_channel:
|
# if in_channel:
|
||||||
channel = in_channel
|
# channel = in_channel
|
||||||
await ctx.maybe_send_embed("Gathering {}".format(channel.mention))
|
await ctx.maybe_send_embed("Gathering {}".format(channel.mention))
|
||||||
user = None
|
user = None
|
||||||
i = 0
|
i = 0
|
||||||
@ -153,11 +183,16 @@ class Chatter(Cog):
|
|||||||
except discord.HTTPException:
|
except discord.HTTPException:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if in_channel:
|
# if in_channel:
|
||||||
break
|
# break
|
||||||
|
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
def _train_twitter(self, *args, **kwargs):
|
||||||
|
trainer = TwitterCorpusTrainer(self.chatbot)
|
||||||
|
trainer.train(*args, **kwargs)
|
||||||
|
return True
|
||||||
|
|
||||||
def _train_ubuntu(self):
|
def _train_ubuntu(self):
|
||||||
trainer = UbuntuCorpusTrainer(
|
trainer = UbuntuCorpusTrainer(
|
||||||
self.chatbot, ubuntu_corpus_data_directory=cog_data_path(self) / "ubuntu_data"
|
self.chatbot, ubuntu_corpus_data_directory=cog_data_path(self) / "ubuntu_data"
|
||||||
@ -165,6 +200,30 @@ class Chatter(Cog):
|
|||||||
trainer.train()
|
trainer.train()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
async def _train_movies(self):
|
||||||
|
trainer = MovieTrainer(self.chatbot, cog_data_path(self))
|
||||||
|
return await trainer.asynctrain()
|
||||||
|
|
||||||
|
async def _train_ubuntu2(self, intensity):
|
||||||
|
train_kwarg = {}
|
||||||
|
if intensity == 196:
|
||||||
|
train_kwarg["train_dialogue"] = False
|
||||||
|
train_kwarg["train_196"] = True
|
||||||
|
elif intensity == 301:
|
||||||
|
train_kwarg["train_dialogue"] = False
|
||||||
|
train_kwarg["train_301"] = True
|
||||||
|
elif intensity == 497:
|
||||||
|
train_kwarg["train_dialogue"] = False
|
||||||
|
train_kwarg["train_196"] = True
|
||||||
|
train_kwarg["train_301"] = True
|
||||||
|
elif intensity >= 9000: # NOT 9000!
|
||||||
|
train_kwarg["train_dialogue"] = True
|
||||||
|
train_kwarg["train_196"] = True
|
||||||
|
train_kwarg["train_301"] = True
|
||||||
|
|
||||||
|
trainer = UbuntuCorpusTrainer2(self.chatbot, cog_data_path(self))
|
||||||
|
return await trainer.asynctrain(**train_kwarg)
|
||||||
|
|
||||||
def _train_english(self):
|
def _train_english(self):
|
||||||
trainer = ChatterBotCorpusTrainer(self.chatbot)
|
trainer = ChatterBotCorpusTrainer(self.chatbot)
|
||||||
# try:
|
# try:
|
||||||
@ -176,13 +235,10 @@ class Chatter(Cog):
|
|||||||
def _train(self, data):
|
def _train(self, data):
|
||||||
trainer = ListTrainer(self.chatbot)
|
trainer = ListTrainer(self.chatbot)
|
||||||
total = len(data)
|
total = len(data)
|
||||||
# try:
|
|
||||||
for c, convo in enumerate(data, 1):
|
for c, convo in enumerate(data, 1):
|
||||||
|
log.info(f"{c} / {total}")
|
||||||
if len(convo) > 1: # TODO: Toggleable skipping short conversations
|
if len(convo) > 1: # TODO: Toggleable skipping short conversations
|
||||||
print(f"{c} / {total}")
|
|
||||||
trainer.train(convo)
|
trainer.train(convo)
|
||||||
# except:
|
|
||||||
# return False
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@commands.group(invoke_without_command=False)
|
@commands.group(invoke_without_command=False)
|
||||||
@ -190,10 +246,10 @@ class Chatter(Cog):
|
|||||||
"""
|
"""
|
||||||
Base command for this cog. Check help for the commands list.
|
Base command for this cog. Check help for the commands list.
|
||||||
"""
|
"""
|
||||||
if ctx.invoked_subcommand is None:
|
self._guild_cache[ctx.guild.id] = {} # Clear cache when modifying values
|
||||||
pass
|
self._global_cache = {}
|
||||||
|
|
||||||
@checks.admin()
|
@commands.admin()
|
||||||
@chatter.command(name="channel")
|
@chatter.command(name="channel")
|
||||||
async def chatter_channel(
|
async def chatter_channel(
|
||||||
self, ctx: commands.Context, channel: Optional[discord.TextChannel] = None
|
self, ctx: commands.Context, channel: Optional[discord.TextChannel] = None
|
||||||
@ -213,13 +269,55 @@ class Chatter(Cog):
|
|||||||
await self.config.guild(ctx.guild).chatchannel.set(channel.id)
|
await self.config.guild(ctx.guild).chatchannel.set(channel.id)
|
||||||
await ctx.maybe_send_embed(f"Chat channel is now {channel.mention}")
|
await ctx.maybe_send_embed(f"Chat channel is now {channel.mention}")
|
||||||
|
|
||||||
@checks.is_owner()
|
@commands.admin()
|
||||||
|
@chatter.command(name="reply")
|
||||||
|
async def chatter_reply(self, ctx: commands.Context, toggle: Optional[bool] = None):
|
||||||
|
"""
|
||||||
|
Toggle bot reply to messages if conversation continuity is not present
|
||||||
|
|
||||||
|
"""
|
||||||
|
reply = await self.config.guild(ctx.guild).reply()
|
||||||
|
if toggle is None:
|
||||||
|
toggle = not reply
|
||||||
|
await self.config.guild(ctx.guild).reply.set(toggle)
|
||||||
|
|
||||||
|
if toggle:
|
||||||
|
await ctx.maybe_send_embed(
|
||||||
|
"I will now respond to you if conversation continuity is not present"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
await ctx.maybe_send_embed(
|
||||||
|
"I will not reply to your message if conversation continuity is not present, anymore"
|
||||||
|
)
|
||||||
|
|
||||||
|
@commands.is_owner()
|
||||||
|
@chatter.command(name="learning")
|
||||||
|
async def chatter_learning(self, ctx: commands.Context, toggle: Optional[bool] = None):
|
||||||
|
"""
|
||||||
|
Toggle the bot learning from its conversations.
|
||||||
|
|
||||||
|
This is a global setting.
|
||||||
|
This is on by default.
|
||||||
|
"""
|
||||||
|
learning = await self.config.learning()
|
||||||
|
if toggle is None:
|
||||||
|
toggle = not learning
|
||||||
|
await self.config.learning.set(toggle)
|
||||||
|
|
||||||
|
if toggle:
|
||||||
|
await ctx.maybe_send_embed("I will now learn from conversations.")
|
||||||
|
else:
|
||||||
|
await ctx.maybe_send_embed("I will no longer learn from conversations.")
|
||||||
|
|
||||||
|
@commands.is_owner()
|
||||||
@chatter.command(name="cleardata")
|
@chatter.command(name="cleardata")
|
||||||
async def chatter_cleardata(self, ctx: commands.Context, confirm: bool = False):
|
async def chatter_cleardata(self, ctx: commands.Context, confirm: bool = False):
|
||||||
"""
|
"""
|
||||||
This command will erase all training data and reset your configuration settings
|
This command will erase all training data and reset your configuration settings.
|
||||||
|
|
||||||
Use `[p]chatter cleardata True`
|
This applies to all guilds.
|
||||||
|
|
||||||
|
Use `[p]chatter cleardata True` to confirm.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not confirm:
|
if not confirm:
|
||||||
@ -246,21 +344,18 @@ class Chatter(Cog):
|
|||||||
|
|
||||||
await ctx.tick()
|
await ctx.tick()
|
||||||
|
|
||||||
@checks.is_owner()
|
@commands.is_owner()
|
||||||
@chatter.command(name="algorithm", aliases=["algo"])
|
@chatter.command(name="algorithm", aliases=["algo"])
|
||||||
async def chatter_algorithm(
|
async def chatter_algorithm(
|
||||||
self, ctx: commands.Context, algo_number: int, threshold: float = None
|
self, ctx: commands.Context, algo_number: int, threshold: float = None
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Switch the active logic algorithm to one of the three. Default after reload is Spacy
|
Switch the active logic algorithm to one of the three. Default is Spacy
|
||||||
|
|
||||||
0: Spacy
|
0: Spacy
|
||||||
1: Jaccard
|
1: Jaccard
|
||||||
2: Levenshtein
|
2: Levenshtein
|
||||||
"""
|
"""
|
||||||
|
|
||||||
algos = [SpacySimilarity, JaccardSimilarity, LevenshteinDistance]
|
|
||||||
|
|
||||||
if algo_number < 0 or algo_number > 2:
|
if algo_number < 0 or algo_number > 2:
|
||||||
await ctx.send_help()
|
await ctx.send_help()
|
||||||
return
|
return
|
||||||
@ -273,31 +368,32 @@ class Chatter(Cog):
|
|||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
self.similarity_threshold = threshold
|
self.similarity_threshold = threshold
|
||||||
|
await self.config.threshold.set(self.similarity_threshold)
|
||||||
|
|
||||||
|
self.similarity_algo = self.algos[algo_number]
|
||||||
|
await self.config.algo_number.set(algo_number)
|
||||||
|
|
||||||
self.similarity_algo = algos[algo_number]
|
|
||||||
async with ctx.typing():
|
async with ctx.typing():
|
||||||
self.chatbot = self._create_chatbot()
|
self.chatbot = self._create_chatbot()
|
||||||
|
|
||||||
await ctx.tick()
|
await ctx.tick()
|
||||||
|
|
||||||
@checks.is_owner()
|
@commands.is_owner()
|
||||||
@chatter.command(name="model")
|
@chatter.command(name="model")
|
||||||
async def chatter_model(self, ctx: commands.Context, model_number: int):
|
async def chatter_model(self, ctx: commands.Context, model_number: int):
|
||||||
"""
|
"""
|
||||||
Switch the active model to one of the three. Default after reload is Medium
|
Switch the active model to one of the three. Default is Small
|
||||||
|
|
||||||
0: Small
|
0: Small
|
||||||
1: Medium
|
1: Medium (Requires additional setup)
|
||||||
2: Large (Requires additional setup)
|
2: Large (Requires additional setup)
|
||||||
|
3. Accurate (Requires additional setup)
|
||||||
"""
|
"""
|
||||||
|
if model_number < 0 or model_number > 3:
|
||||||
models = [ENG_SM, ENG_MD, ENG_LG]
|
|
||||||
|
|
||||||
if model_number < 0 or model_number > 2:
|
|
||||||
await ctx.send_help()
|
await ctx.send_help()
|
||||||
return
|
return
|
||||||
|
|
||||||
if model_number == 2:
|
if model_number >= 0:
|
||||||
await ctx.maybe_send_embed(
|
await ctx.maybe_send_embed(
|
||||||
"Additional requirements needed. See guide before continuing.\n" "Continue?"
|
"Additional requirements needed. See guide before continuing.\n" "Continue?"
|
||||||
)
|
)
|
||||||
@ -310,7 +406,8 @@ class Chatter(Cog):
|
|||||||
if not pred.result:
|
if not pred.result:
|
||||||
return
|
return
|
||||||
|
|
||||||
self.tagger_language = models[model_number]
|
self.tagger_language = self.models[model_number]
|
||||||
|
await self.config.model_number.set(model_number)
|
||||||
async with ctx.typing():
|
async with ctx.typing():
|
||||||
self.chatbot = self._create_chatbot()
|
self.chatbot = self._create_chatbot()
|
||||||
|
|
||||||
@ -318,8 +415,14 @@ class Chatter(Cog):
|
|||||||
f"Model has been switched to {self.tagger_language.ISO_639_1}"
|
f"Model has been switched to {self.tagger_language.ISO_639_1}"
|
||||||
)
|
)
|
||||||
|
|
||||||
@checks.is_owner()
|
@commands.is_owner()
|
||||||
@chatter.command(name="minutes")
|
@chatter.group(name="trainset")
|
||||||
|
async def chatter_trainset(self, ctx: commands.Context):
|
||||||
|
"""Commands for configuring training"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
@commands.is_owner()
|
||||||
|
@chatter_trainset.command(name="minutes")
|
||||||
async def minutes(self, ctx: commands.Context, minutes: int):
|
async def minutes(self, ctx: commands.Context, minutes: int):
|
||||||
"""
|
"""
|
||||||
Sets the number of minutes the bot will consider a break in a conversation during training
|
Sets the number of minutes the bot will consider a break in a conversation during training
|
||||||
@ -330,12 +433,12 @@ class Chatter(Cog):
|
|||||||
await ctx.send_help()
|
await ctx.send_help()
|
||||||
return
|
return
|
||||||
|
|
||||||
await self.config.guild(ctx.guild).convo_length.set(minutes)
|
await self.config.guild(ctx.guild).convo_delta.set(minutes)
|
||||||
|
|
||||||
await ctx.tick()
|
await ctx.tick()
|
||||||
|
|
||||||
@checks.is_owner()
|
@commands.is_owner()
|
||||||
@chatter.command(name="age")
|
@chatter_trainset.command(name="age")
|
||||||
async def age(self, ctx: commands.Context, days: int):
|
async def age(self, ctx: commands.Context, days: int):
|
||||||
"""
|
"""
|
||||||
Sets the number of days to look back
|
Sets the number of days to look back
|
||||||
@ -349,7 +452,16 @@ class Chatter(Cog):
|
|||||||
await self.config.guild(ctx.guild).days.set(days)
|
await self.config.guild(ctx.guild).days.set(days)
|
||||||
await ctx.tick()
|
await ctx.tick()
|
||||||
|
|
||||||
@checks.is_owner()
|
@commands.is_owner()
|
||||||
|
@chatter.command(name="kaggle")
|
||||||
|
async def chatter_kaggle(self, ctx: commands.Context):
|
||||||
|
"""Register with the kaggle API to download additional datasets for training"""
|
||||||
|
if not await self.check_for_kaggle():
|
||||||
|
await ctx.maybe_send_embed(
|
||||||
|
"[Click here for instructions to setup the kaggle api](https://github.com/Kaggle/kaggle-api#api-credentials)"
|
||||||
|
)
|
||||||
|
|
||||||
|
@commands.is_owner()
|
||||||
@chatter.command(name="backup")
|
@chatter.command(name="backup")
|
||||||
async def backup(self, ctx, backupname):
|
async def backup(self, ctx, backupname):
|
||||||
"""
|
"""
|
||||||
@ -371,8 +483,71 @@ class Chatter(Cog):
|
|||||||
else:
|
else:
|
||||||
await ctx.maybe_send_embed("Error occurred :(")
|
await ctx.maybe_send_embed("Error occurred :(")
|
||||||
|
|
||||||
@checks.is_owner()
|
@commands.is_owner()
|
||||||
@chatter.command(name="trainubuntu")
|
@chatter.group(name="train")
|
||||||
|
async def chatter_train(self, ctx: commands.Context):
|
||||||
|
"""Commands for training the bot"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
@chatter_train.group(name="kaggle")
|
||||||
|
async def chatter_train_kaggle(self, ctx: commands.Context):
|
||||||
|
"""
|
||||||
|
Base command for kaggle training sets.
|
||||||
|
|
||||||
|
See `[p]chatter kaggle` for details on how to enable this option
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
@chatter_train_kaggle.command(name="ubuntu")
|
||||||
|
async def chatter_train_kaggle_ubuntu(
|
||||||
|
self, ctx: commands.Context, confirmation: bool = False, intensity=0
|
||||||
|
):
|
||||||
|
"""
|
||||||
|
WARNING: Large Download! Trains the bot using *NEW* Ubuntu Dialog Corpus data.
|
||||||
|
"""
|
||||||
|
|
||||||
|
if not confirmation:
|
||||||
|
await ctx.maybe_send_embed(
|
||||||
|
"Warning: This command downloads ~800MB and is CPU intensive during training\n"
|
||||||
|
"If you're sure you want to continue, run `[p]chatter train kaggle ubuntu True`"
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
async with ctx.typing():
|
||||||
|
future = await self._train_ubuntu2(intensity)
|
||||||
|
|
||||||
|
if future:
|
||||||
|
await ctx.maybe_send_embed("Training successful!")
|
||||||
|
else:
|
||||||
|
await ctx.maybe_send_embed("Error occurred :(")
|
||||||
|
|
||||||
|
@chatter_train_kaggle.command(name="movies")
|
||||||
|
async def chatter_train_kaggle_movies(self, ctx: commands.Context, confirmation: bool = False):
|
||||||
|
"""
|
||||||
|
WARNING: Language! Trains the bot using Cornell University's "Movie Dialog Corpus".
|
||||||
|
|
||||||
|
This training set contains dialog from a spread of movies with different MPAA.
|
||||||
|
This dialog includes racism, sexism, and any number of sensitive topics.
|
||||||
|
|
||||||
|
Use at your own risk.
|
||||||
|
"""
|
||||||
|
|
||||||
|
if not confirmation:
|
||||||
|
await ctx.maybe_send_embed(
|
||||||
|
"Warning: This command downloads ~29MB and is CPU intensive during training\n"
|
||||||
|
"If you're sure you want to continue, run `[p]chatter train kaggle movies True`"
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
async with ctx.typing():
|
||||||
|
future = await self._train_movies()
|
||||||
|
|
||||||
|
if future:
|
||||||
|
await ctx.maybe_send_embed("Training successful!")
|
||||||
|
else:
|
||||||
|
await ctx.maybe_send_embed("Error occurred :(")
|
||||||
|
|
||||||
|
@chatter_train.command(name="ubuntu")
|
||||||
async def chatter_train_ubuntu(self, ctx: commands.Context, confirmation: bool = False):
|
async def chatter_train_ubuntu(self, ctx: commands.Context, confirmation: bool = False):
|
||||||
"""
|
"""
|
||||||
WARNING: Large Download! Trains the bot using Ubuntu Dialog Corpus data.
|
WARNING: Large Download! Trains the bot using Ubuntu Dialog Corpus data.
|
||||||
@ -380,8 +555,8 @@ class Chatter(Cog):
|
|||||||
|
|
||||||
if not confirmation:
|
if not confirmation:
|
||||||
await ctx.maybe_send_embed(
|
await ctx.maybe_send_embed(
|
||||||
"Warning: This command downloads ~500MB then eats your CPU for training\n"
|
"Warning: This command downloads ~500MB and is CPU intensive during training\n"
|
||||||
"If you're sure you want to continue, run `[p]chatter trainubuntu True`"
|
"If you're sure you want to continue, run `[p]chatter train ubuntu True`"
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -389,12 +564,11 @@ class Chatter(Cog):
|
|||||||
future = await self.loop.run_in_executor(None, self._train_ubuntu)
|
future = await self.loop.run_in_executor(None, self._train_ubuntu)
|
||||||
|
|
||||||
if future:
|
if future:
|
||||||
await ctx.send("Training successful!")
|
await ctx.maybe_send_embed("Training successful!")
|
||||||
else:
|
else:
|
||||||
await ctx.send("Error occurred :(")
|
await ctx.maybe_send_embed("Error occurred :(")
|
||||||
|
|
||||||
@checks.is_owner()
|
@chatter_train.command(name="english")
|
||||||
@chatter.command(name="trainenglish")
|
|
||||||
async def chatter_train_english(self, ctx: commands.Context):
|
async def chatter_train_english(self, ctx: commands.Context):
|
||||||
"""
|
"""
|
||||||
Trains the bot in english
|
Trains the bot in english
|
||||||
@ -407,12 +581,32 @@ class Chatter(Cog):
|
|||||||
else:
|
else:
|
||||||
await ctx.maybe_send_embed("Error occurred :(")
|
await ctx.maybe_send_embed("Error occurred :(")
|
||||||
|
|
||||||
@checks.is_owner()
|
@chatter_train.command(name="list")
|
||||||
@chatter.command()
|
async def chatter_train_list(self, ctx: commands.Context):
|
||||||
async def train(self, ctx: commands.Context, channel: discord.TextChannel):
|
"""Trains the bot based on an uploaded list.
|
||||||
|
|
||||||
|
Must be a file in the format of a python list: ['prompt', 'response1', 'response2']
|
||||||
"""
|
"""
|
||||||
Trains the bot based on language in this guild
|
if not ctx.message.attachments:
|
||||||
|
await ctx.maybe_send_embed("You must upload a file when using this command")
|
||||||
|
return
|
||||||
|
|
||||||
|
attachment: discord.Attachment = ctx.message.attachments[0]
|
||||||
|
|
||||||
|
a_bytes = await attachment.read()
|
||||||
|
|
||||||
|
await ctx.send("Not yet implemented")
|
||||||
|
|
||||||
|
@chatter_train.command(name="channel")
|
||||||
|
async def chatter_train_channel(
|
||||||
|
self, ctx: commands.Context, channels: commands.Greedy[discord.TextChannel]
|
||||||
|
):
|
||||||
"""
|
"""
|
||||||
|
Trains the bot based on language in this guild.
|
||||||
|
"""
|
||||||
|
if not channels:
|
||||||
|
await ctx.send_help()
|
||||||
|
return
|
||||||
|
|
||||||
await ctx.maybe_send_embed(
|
await ctx.maybe_send_embed(
|
||||||
"Warning: The cog may use significant RAM or CPU if trained on large data sets.\n"
|
"Warning: The cog may use significant RAM or CPU if trained on large data sets.\n"
|
||||||
@ -421,7 +615,7 @@ class Chatter(Cog):
|
|||||||
)
|
)
|
||||||
|
|
||||||
async with ctx.typing():
|
async with ctx.typing():
|
||||||
conversation = await self._get_conversation(ctx, channel)
|
conversation = await self._get_conversation(ctx, channels)
|
||||||
|
|
||||||
if not conversation:
|
if not conversation:
|
||||||
await ctx.maybe_send_embed("Failed to gather training data")
|
await ctx.maybe_send_embed("Failed to gather training data")
|
||||||
@ -463,7 +657,7 @@ class Chatter(Cog):
|
|||||||
|
|
||||||
guild: discord.Guild = getattr(message, "guild", None)
|
guild: discord.Guild = getattr(message, "guild", None)
|
||||||
|
|
||||||
if await self.bot.cog_disabled_in_guild(self, guild):
|
if guild is None or await self.bot.cog_disabled_in_guild(self, guild):
|
||||||
return
|
return
|
||||||
|
|
||||||
ctx: commands.Context = await self.bot.get_context(message)
|
ctx: commands.Context = await self.bot.get_context(message)
|
||||||
@ -475,7 +669,18 @@ class Chatter(Cog):
|
|||||||
# Thank you Cog-Creators
|
# Thank you Cog-Creators
|
||||||
channel: discord.TextChannel = message.channel
|
channel: discord.TextChannel = message.channel
|
||||||
|
|
||||||
if guild is not None and channel.id == await self.config.guild(guild).chatchannel():
|
if not self._guild_cache[guild.id]:
|
||||||
|
self._guild_cache[guild.id] = await self.config.guild(guild).all()
|
||||||
|
|
||||||
|
is_reply = False # this is only useful with in_response_to
|
||||||
|
if (
|
||||||
|
message.reference is not None
|
||||||
|
and isinstance(message.reference.resolved, discord.Message)
|
||||||
|
and message.reference.resolved.author.id == self.bot.user.id
|
||||||
|
):
|
||||||
|
is_reply = True # this is only useful with in_response_to
|
||||||
|
pass # this is a reply to the bot, good to go
|
||||||
|
elif guild is not None and channel.id == self._guild_cache[guild.id]["chatchannel"]:
|
||||||
pass # good to go
|
pass # good to go
|
||||||
else:
|
else:
|
||||||
when_mentionables = commands.when_mentioned(self.bot, message)
|
when_mentionables = commands.when_mentioned(self.bot, message)
|
||||||
@ -490,10 +695,57 @@ class Chatter(Cog):
|
|||||||
|
|
||||||
text = message.clean_content
|
text = message.clean_content
|
||||||
|
|
||||||
async with channel.typing():
|
async with ctx.typing():
|
||||||
future = await self.loop.run_in_executor(None, self.chatbot.get_response, text)
|
|
||||||
|
if is_reply:
|
||||||
|
in_response_to = message.reference.resolved.content
|
||||||
|
elif self._last_message_per_channel[ctx.channel.id] is not None:
|
||||||
|
last_m: discord.Message = self._last_message_per_channel[ctx.channel.id]
|
||||||
|
minutes = self._guild_cache[ctx.guild.id]["convo_delta"]
|
||||||
|
if (datetime.utcnow() - last_m.created_at).seconds > minutes * 60:
|
||||||
|
in_response_to = None
|
||||||
|
else:
|
||||||
|
in_response_to = last_m.content
|
||||||
|
else:
|
||||||
|
in_response_to = None
|
||||||
|
|
||||||
|
# Always use generate reponse
|
||||||
|
# Chatterbot tries to learn based on the result it comes up with, which is dumb
|
||||||
|
log.debug("Generating response")
|
||||||
|
Statement = self.chatbot.storage.get_object("statement")
|
||||||
|
future = await self.loop.run_in_executor(
|
||||||
|
None, self.chatbot.generate_response, Statement(text)
|
||||||
|
)
|
||||||
|
|
||||||
|
if not self._global_cache:
|
||||||
|
self._global_cache = await self.config.all()
|
||||||
|
|
||||||
|
if in_response_to is not None and self._global_cache["learning"]:
|
||||||
|
log.debug("learning response")
|
||||||
|
await self.loop.run_in_executor(
|
||||||
|
None,
|
||||||
|
partial(
|
||||||
|
self.chatbot.learn_response,
|
||||||
|
Statement(text),
|
||||||
|
previous_statement=in_response_to,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
replying = None
|
||||||
|
if (
|
||||||
|
"reply" not in self._guild_cache[guild.id] and self.default_guild["reply"]
|
||||||
|
) or self._guild_cache[guild.id]["reply"]:
|
||||||
|
if message != ctx.channel.last_message:
|
||||||
|
replying = message
|
||||||
|
|
||||||
if future and str(future):
|
if future and str(future):
|
||||||
await channel.send(str(future))
|
self._last_message_per_channel[ctx.channel.id] = await channel.send(
|
||||||
|
str(future), reference=replying
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
await channel.send(":thinking:")
|
await ctx.send(":thinking:")
|
||||||
|
|
||||||
|
async def check_for_kaggle(self):
|
||||||
|
"""Check whether Kaggle is installed and configured properly"""
|
||||||
|
# TODO: This
|
||||||
|
return False
|
||||||
|
@ -2,22 +2,15 @@
|
|||||||
"author": [
|
"author": [
|
||||||
"Bobloy"
|
"Bobloy"
|
||||||
],
|
],
|
||||||
"min_bot_version": "3.4.0",
|
"min_bot_version": "3.4.6",
|
||||||
"description": "Create an offline chatbot that talks like your average member using Machine Learning. See setup instructions at https://github.com/bobloy/Fox-V3/tree/master/chatter",
|
"description": "Create an offline chatbot that talks like your average member using Machine Learning. See setup instructions at https://github.com/bobloy/Fox-V3/tree/master/chatter",
|
||||||
"hidden": false,
|
"hidden": false,
|
||||||
"install_msg": "Thank you for installing Chatter! Please make sure you check the install instructions at https://github.com/bobloy/Fox-V3/blob/master/chatter/README.md\nAfter that, get started ith `[p]load chatter` and `[p]help Chatter`",
|
"install_msg": "Thank you for installing Chatter! Please make sure you check the install instructions at https://github.com/bobloy/Fox-V3/blob/master/chatter/README.md\nAfter that, get started ith `[p]load chatter` and `[p]help Chatter`",
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"git+git://github.com/gunthercox/chatterbot-corpus@master#egg=chatterbot_corpus",
|
"git+git://github.com/bobloy/ChatterBot@fox#egg=ChatterBot>=1.1.0.dev4",
|
||||||
"mathparse>=0.1,<0.2",
|
"kaggle",
|
||||||
"nltk>=3.2,<4.0",
|
"https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.1.0/en_core_web_sm-3.1.0.tar.gz#egg=en_core_web_sm",
|
||||||
"pint>=0.8.1",
|
"https://github.com/explosion/spacy-models/releases/download/en_core_web_md-3.1.0/en_core_web_md-3.1.0.tar.gz#egg=en_core_web_md"
|
||||||
"python-dateutil>=2.8,<2.9",
|
|
||||||
"pyyaml>=5.3,<5.4",
|
|
||||||
"sqlalchemy>=1.3,<1.4",
|
|
||||||
"pytz",
|
|
||||||
"https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.3.1/en_core_web_sm-2.3.1.tar.gz#egg=en_core_web_sm",
|
|
||||||
"https://github.com/explosion/spacy-models/releases/download/en_core_web_md-2.3.1/en_core_web_md-2.3.1.tar.gz#egg=en_core_web_md",
|
|
||||||
"spacy>=2.3,<2.4"
|
|
||||||
],
|
],
|
||||||
"short": "Local Chatbot run on machine learning",
|
"short": "Local Chatbot run on machine learning",
|
||||||
"end_user_data_statement": "This cog only stores anonymous conversations data; no End User Data is stored.",
|
"end_user_data_statement": "This cog only stores anonymous conversations data; no End User Data is stored.",
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
git+git://github.com/gunthercox/chatterbot-corpus@master#egg=chatterbot_corpus
|
|
||||||
mathparse>=0.1,<0.2
|
|
||||||
nltk>=3.2,<4.0
|
|
||||||
pint>=0.8.1
|
|
||||||
python-dateutil>=2.8,<2.9
|
|
||||||
pyyaml>=5.3,<5.4
|
|
||||||
sqlalchemy>=1.3,<1.4
|
|
||||||
pytz
|
|
||||||
spacy>=2.3,<2.4
|
|
||||||
https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.3.1/en_core_web_sm-2.3.1.tar.gz#egg=en_core_web_sm
|
|
||||||
https://github.com/explosion/spacy-models/releases/download/en_core_web_md-2.3.1/en_core_web_md-2.3.1.tar.gz#egg=en_core_web_md
|
|
||||||
# https://github.com/explosion/spacy-models/releases/download/en_core_web_lg-2.3.1/en_core_web_lg-2.3.1.tar.gz#egg=en_core_web_lg
|
|
71
chatter/storage_adapters.py
Normal file
71
chatter/storage_adapters.py
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
from chatterbot.storage import StorageAdapter, SQLStorageAdapter
|
||||||
|
|
||||||
|
|
||||||
|
class MyDumbSQLStorageAdapter(SQLStorageAdapter):
|
||||||
|
def __init__(self, **kwargs):
|
||||||
|
super(SQLStorageAdapter, self).__init__(**kwargs)
|
||||||
|
|
||||||
|
from sqlalchemy import create_engine, inspect
|
||||||
|
from sqlalchemy.orm import sessionmaker
|
||||||
|
|
||||||
|
self.database_uri = kwargs.get("database_uri", False)
|
||||||
|
|
||||||
|
# None results in a sqlite in-memory database as the default
|
||||||
|
if self.database_uri is None:
|
||||||
|
self.database_uri = "sqlite://"
|
||||||
|
|
||||||
|
# Create a file database if the database is not a connection string
|
||||||
|
if not self.database_uri:
|
||||||
|
self.database_uri = "sqlite:///db.sqlite3"
|
||||||
|
|
||||||
|
self.engine = create_engine(self.database_uri, connect_args={"check_same_thread": False})
|
||||||
|
|
||||||
|
if self.database_uri.startswith("sqlite://"):
|
||||||
|
from sqlalchemy.engine import Engine
|
||||||
|
from sqlalchemy import event
|
||||||
|
|
||||||
|
@event.listens_for(Engine, "connect")
|
||||||
|
def set_sqlite_pragma(dbapi_connection, connection_record):
|
||||||
|
dbapi_connection.execute("PRAGMA journal_mode=WAL")
|
||||||
|
dbapi_connection.execute("PRAGMA synchronous=NORMAL")
|
||||||
|
|
||||||
|
if not inspect(self.engine).has_table("Statement"):
|
||||||
|
self.create_database()
|
||||||
|
|
||||||
|
self.Session = sessionmaker(bind=self.engine, expire_on_commit=True)
|
||||||
|
|
||||||
|
|
||||||
|
class AsyncSQLStorageAdapter(SQLStorageAdapter):
|
||||||
|
def __init__(self, **kwargs):
|
||||||
|
super(SQLStorageAdapter, self).__init__(**kwargs)
|
||||||
|
|
||||||
|
self.database_uri = kwargs.get("database_uri", False)
|
||||||
|
|
||||||
|
# None results in a sqlite in-memory database as the default
|
||||||
|
if self.database_uri is None:
|
||||||
|
self.database_uri = "sqlite://"
|
||||||
|
|
||||||
|
# Create a file database if the database is not a connection string
|
||||||
|
if not self.database_uri:
|
||||||
|
self.database_uri = "sqlite:///db.sqlite3"
|
||||||
|
|
||||||
|
async def initialize(self):
|
||||||
|
# from sqlalchemy import create_engine
|
||||||
|
from aiomysql.sa import create_engine
|
||||||
|
from sqlalchemy.orm import sessionmaker
|
||||||
|
|
||||||
|
self.engine = await create_engine(self.database_uri, convert_unicode=True)
|
||||||
|
|
||||||
|
if self.database_uri.startswith("sqlite://"):
|
||||||
|
from sqlalchemy.engine import Engine
|
||||||
|
from sqlalchemy import event
|
||||||
|
|
||||||
|
@event.listens_for(Engine, "connect")
|
||||||
|
def set_sqlite_pragma(dbapi_connection, connection_record):
|
||||||
|
dbapi_connection.execute("PRAGMA journal_mode=WAL")
|
||||||
|
dbapi_connection.execute("PRAGMA synchronous=NORMAL")
|
||||||
|
|
||||||
|
if not self.engine.dialect.has_table(self.engine, "Statement"):
|
||||||
|
self.create_database()
|
||||||
|
|
||||||
|
self.Session = sessionmaker(bind=self.engine, expire_on_commit=True)
|
351
chatter/trainers.py
Normal file
351
chatter/trainers.py
Normal file
@ -0,0 +1,351 @@
|
|||||||
|
import asyncio
|
||||||
|
import csv
|
||||||
|
import html
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
import pathlib
|
||||||
|
import time
|
||||||
|
from functools import partial
|
||||||
|
|
||||||
|
from chatterbot import utils
|
||||||
|
from chatterbot.conversation import Statement
|
||||||
|
from chatterbot.tagging import PosLemmaTagger
|
||||||
|
from chatterbot.trainers import Trainer
|
||||||
|
from redbot.core.bot import Red
|
||||||
|
from dateutil import parser as date_parser
|
||||||
|
from redbot.core.utils import AsyncIter
|
||||||
|
|
||||||
|
log = logging.getLogger("red.fox_v3.chatter.trainers")
|
||||||
|
|
||||||
|
|
||||||
|
class KaggleTrainer(Trainer):
|
||||||
|
def __init__(self, chatbot, datapath: pathlib.Path, **kwargs):
|
||||||
|
super().__init__(chatbot, **kwargs)
|
||||||
|
|
||||||
|
self.data_directory = datapath / kwargs.get("downloadpath", "kaggle_download")
|
||||||
|
|
||||||
|
self.kaggle_dataset = kwargs.get(
|
||||||
|
"kaggle_dataset",
|
||||||
|
"Cornell-University/movie-dialog-corpus",
|
||||||
|
)
|
||||||
|
|
||||||
|
# Create the data directory if it does not already exist
|
||||||
|
if not os.path.exists(self.data_directory):
|
||||||
|
os.makedirs(self.data_directory)
|
||||||
|
|
||||||
|
def is_downloaded(self, file_path):
|
||||||
|
"""
|
||||||
|
Check if the data file is already downloaded.
|
||||||
|
"""
|
||||||
|
if os.path.exists(file_path):
|
||||||
|
self.chatbot.logger.info("File is already downloaded")
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
async def download(self, dataset):
|
||||||
|
import kaggle # This triggers the API token check
|
||||||
|
|
||||||
|
future = await asyncio.get_event_loop().run_in_executor(
|
||||||
|
None,
|
||||||
|
partial(
|
||||||
|
kaggle.api.dataset_download_files,
|
||||||
|
dataset=dataset,
|
||||||
|
path=self.data_directory,
|
||||||
|
quiet=False,
|
||||||
|
unzip=True,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
def train(self, *args, **kwargs):
|
||||||
|
log.error("See asynctrain instead")
|
||||||
|
|
||||||
|
def asynctrain(self, *args, **kwargs):
|
||||||
|
raise self.TrainerInitializationException()
|
||||||
|
|
||||||
|
|
||||||
|
class SouthParkTrainer(KaggleTrainer):
|
||||||
|
def __init__(self, chatbot, datapath: pathlib.Path, **kwargs):
|
||||||
|
super().__init__(
|
||||||
|
chatbot,
|
||||||
|
datapath,
|
||||||
|
downloadpath="ubuntu_data_v2",
|
||||||
|
kaggle_dataset="tovarischsukhov/southparklines",
|
||||||
|
**kwargs,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class MovieTrainer(KaggleTrainer):
|
||||||
|
def __init__(self, chatbot, datapath: pathlib.Path, **kwargs):
|
||||||
|
super().__init__(
|
||||||
|
chatbot,
|
||||||
|
datapath,
|
||||||
|
downloadpath="kaggle_movies",
|
||||||
|
kaggle_dataset="Cornell-University/movie-dialog-corpus",
|
||||||
|
**kwargs,
|
||||||
|
)
|
||||||
|
|
||||||
|
async def run_movie_training(self):
|
||||||
|
dialogue_file = "movie_lines.tsv"
|
||||||
|
conversation_file = "movie_conversations.tsv"
|
||||||
|
log.info(f"Beginning dialogue training on {dialogue_file}")
|
||||||
|
start_time = time.time()
|
||||||
|
|
||||||
|
tagger = PosLemmaTagger(language=self.chatbot.storage.tagger.language)
|
||||||
|
|
||||||
|
# [lineID, characterID, movieID, character name, text of utterance]
|
||||||
|
# File parsing from https://www.kaggle.com/mushaya/conversation-chatbot
|
||||||
|
|
||||||
|
with open(self.data_directory / conversation_file, "r", encoding="utf-8-sig") as conv_tsv:
|
||||||
|
conv_lines = conv_tsv.readlines()
|
||||||
|
with open(self.data_directory / dialogue_file, "r", encoding="utf-8-sig") as lines_tsv:
|
||||||
|
dialog_lines = lines_tsv.readlines()
|
||||||
|
|
||||||
|
# trans_dict = str.maketrans({"<u>": "__", "</u>": "__", '""': '"'})
|
||||||
|
|
||||||
|
lines_dict = {}
|
||||||
|
for line in dialog_lines:
|
||||||
|
_line = line[:-1].strip('"').split("\t")
|
||||||
|
if len(_line) >= 5: # Only good lines
|
||||||
|
lines_dict[_line[0]] = (
|
||||||
|
html.unescape(("".join(_line[4:])).strip())
|
||||||
|
.replace("<u>", "__")
|
||||||
|
.replace("</u>", "__")
|
||||||
|
.replace('""', '"')
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
log.debug(f"Bad line {_line}")
|
||||||
|
|
||||||
|
# collecting line ids for each conversation
|
||||||
|
conv = []
|
||||||
|
for line in conv_lines[:-1]:
|
||||||
|
_line = line[:-1].split("\t")[-1][1:-1].replace("'", "").replace(" ", ",")
|
||||||
|
conv.append(_line.split(","))
|
||||||
|
|
||||||
|
# conversations = csv.reader(conv_tsv, delimiter="\t")
|
||||||
|
#
|
||||||
|
# reader = csv.reader(lines_tsv, delimiter="\t")
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# lines_dict = {}
|
||||||
|
# for row in reader:
|
||||||
|
# try:
|
||||||
|
# lines_dict[row[0].strip('"')] = row[4]
|
||||||
|
# except:
|
||||||
|
# log.exception(f"Bad line: {row}")
|
||||||
|
# pass
|
||||||
|
# else:
|
||||||
|
# # log.info(f"Good line: {row}")
|
||||||
|
# pass
|
||||||
|
#
|
||||||
|
# # lines_dict = {row[0].strip('"'): row[4] for row in reader_list}
|
||||||
|
|
||||||
|
statements_from_file = []
|
||||||
|
save_every = 300
|
||||||
|
count = 0
|
||||||
|
|
||||||
|
# [characterID of first, characterID of second, movieID, list of utterances]
|
||||||
|
async for lines in AsyncIter(conv):
|
||||||
|
previous_statement_text = None
|
||||||
|
previous_statement_search_text = ""
|
||||||
|
|
||||||
|
for line in lines:
|
||||||
|
text = lines_dict[line]
|
||||||
|
statement = Statement(
|
||||||
|
text=text,
|
||||||
|
in_response_to=previous_statement_text,
|
||||||
|
conversation="training",
|
||||||
|
)
|
||||||
|
|
||||||
|
for preprocessor in self.chatbot.preprocessors:
|
||||||
|
statement = preprocessor(statement)
|
||||||
|
|
||||||
|
statement.search_text = tagger.get_text_index_string(statement.text)
|
||||||
|
statement.search_in_response_to = previous_statement_search_text
|
||||||
|
|
||||||
|
previous_statement_text = statement.text
|
||||||
|
previous_statement_search_text = statement.search_text
|
||||||
|
|
||||||
|
statements_from_file.append(statement)
|
||||||
|
|
||||||
|
count += 1
|
||||||
|
if count >= save_every:
|
||||||
|
if statements_from_file:
|
||||||
|
self.chatbot.storage.create_many(statements_from_file)
|
||||||
|
statements_from_file = []
|
||||||
|
count = 0
|
||||||
|
|
||||||
|
if statements_from_file:
|
||||||
|
self.chatbot.storage.create_many(statements_from_file)
|
||||||
|
|
||||||
|
log.info(f"Training took {time.time() - start_time} seconds.")
|
||||||
|
|
||||||
|
async def asynctrain(self, *args, **kwargs):
|
||||||
|
extracted_lines = self.data_directory / "movie_lines.tsv"
|
||||||
|
extracted_lines: pathlib.Path
|
||||||
|
|
||||||
|
# Download and extract the Ubuntu dialog corpus if needed
|
||||||
|
if not extracted_lines.exists():
|
||||||
|
await self.download(self.kaggle_dataset)
|
||||||
|
else:
|
||||||
|
log.info("Movie dialog already downloaded")
|
||||||
|
if not extracted_lines.exists():
|
||||||
|
raise FileNotFoundError(f"{extracted_lines}")
|
||||||
|
|
||||||
|
await self.run_movie_training()
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
# train_dialogue = kwargs.get("train_dialogue", True)
|
||||||
|
# train_196_dialogue = kwargs.get("train_196", False)
|
||||||
|
# train_301_dialogue = kwargs.get("train_301", False)
|
||||||
|
#
|
||||||
|
# if train_dialogue:
|
||||||
|
# await self.run_dialogue_training(extracted_dir, "dialogueText.csv")
|
||||||
|
#
|
||||||
|
# if train_196_dialogue:
|
||||||
|
# await self.run_dialogue_training(extracted_dir, "dialogueText_196.csv")
|
||||||
|
#
|
||||||
|
# if train_301_dialogue:
|
||||||
|
# await self.run_dialogue_training(extracted_dir, "dialogueText_301.csv")
|
||||||
|
|
||||||
|
|
||||||
|
class UbuntuCorpusTrainer2(KaggleTrainer):
|
||||||
|
def __init__(self, chatbot, datapath: pathlib.Path, **kwargs):
|
||||||
|
super().__init__(
|
||||||
|
chatbot,
|
||||||
|
datapath,
|
||||||
|
downloadpath="kaggle_ubuntu",
|
||||||
|
kaggle_dataset="rtatman/ubuntu-dialogue-corpus",
|
||||||
|
**kwargs,
|
||||||
|
)
|
||||||
|
|
||||||
|
async def asynctrain(self, *args, **kwargs):
|
||||||
|
extracted_dir = self.data_directory / "Ubuntu-dialogue-corpus"
|
||||||
|
|
||||||
|
# Download and extract the Ubuntu dialog corpus if needed
|
||||||
|
if not extracted_dir.exists():
|
||||||
|
await self.download(self.kaggle_dataset)
|
||||||
|
else:
|
||||||
|
log.info("Ubuntu dialogue already downloaded")
|
||||||
|
if not extracted_dir.exists():
|
||||||
|
raise FileNotFoundError("Did not extract in the expected way")
|
||||||
|
|
||||||
|
train_dialogue = kwargs.get("train_dialogue", True)
|
||||||
|
train_196_dialogue = kwargs.get("train_196", False)
|
||||||
|
train_301_dialogue = kwargs.get("train_301", False)
|
||||||
|
|
||||||
|
if train_dialogue:
|
||||||
|
await self.run_dialogue_training(extracted_dir, "dialogueText.csv")
|
||||||
|
|
||||||
|
if train_196_dialogue:
|
||||||
|
await self.run_dialogue_training(extracted_dir, "dialogueText_196.csv")
|
||||||
|
|
||||||
|
if train_301_dialogue:
|
||||||
|
await self.run_dialogue_training(extracted_dir, "dialogueText_301.csv")
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
async def run_dialogue_training(self, extracted_dir, dialogue_file):
|
||||||
|
log.info(f"Beginning dialogue training on {dialogue_file}")
|
||||||
|
start_time = time.time()
|
||||||
|
|
||||||
|
tagger = PosLemmaTagger(language=self.chatbot.storage.tagger.language)
|
||||||
|
|
||||||
|
with open(extracted_dir / dialogue_file, "r", encoding="utf-8") as dg:
|
||||||
|
reader = csv.DictReader(dg)
|
||||||
|
|
||||||
|
next(reader) # Skip the header
|
||||||
|
|
||||||
|
last_dialogue_id = None
|
||||||
|
previous_statement_text = None
|
||||||
|
previous_statement_search_text = ""
|
||||||
|
statements_from_file = []
|
||||||
|
|
||||||
|
save_every = 50
|
||||||
|
count = 0
|
||||||
|
|
||||||
|
async for row in AsyncIter(reader):
|
||||||
|
dialogue_id = row["dialogueID"]
|
||||||
|
if dialogue_id != last_dialogue_id:
|
||||||
|
previous_statement_text = None
|
||||||
|
previous_statement_search_text = ""
|
||||||
|
last_dialogue_id = dialogue_id
|
||||||
|
count += 1
|
||||||
|
if count >= save_every:
|
||||||
|
if statements_from_file:
|
||||||
|
self.chatbot.storage.create_many(statements_from_file)
|
||||||
|
statements_from_file = []
|
||||||
|
count = 0
|
||||||
|
|
||||||
|
if len(row) > 0:
|
||||||
|
statement = Statement(
|
||||||
|
text=row["text"],
|
||||||
|
in_response_to=previous_statement_text,
|
||||||
|
conversation="training",
|
||||||
|
# created_at=date_parser.parse(row["date"]),
|
||||||
|
persona=row["from"],
|
||||||
|
)
|
||||||
|
|
||||||
|
for preprocessor in self.chatbot.preprocessors:
|
||||||
|
statement = preprocessor(statement)
|
||||||
|
|
||||||
|
statement.search_text = tagger.get_text_index_string(statement.text)
|
||||||
|
statement.search_in_response_to = previous_statement_search_text
|
||||||
|
|
||||||
|
previous_statement_text = statement.text
|
||||||
|
previous_statement_search_text = statement.search_text
|
||||||
|
|
||||||
|
statements_from_file.append(statement)
|
||||||
|
|
||||||
|
if statements_from_file:
|
||||||
|
self.chatbot.storage.create_many(statements_from_file)
|
||||||
|
|
||||||
|
log.info(f"Training took {time.time() - start_time} seconds.")
|
||||||
|
|
||||||
|
|
||||||
|
class TwitterCorpusTrainer(Trainer):
|
||||||
|
pass
|
||||||
|
# def train(self, *args, **kwargs):
|
||||||
|
# """
|
||||||
|
# Train the chat bot based on the provided list of
|
||||||
|
# statements that represents a single conversation.
|
||||||
|
# """
|
||||||
|
# import twint
|
||||||
|
#
|
||||||
|
# c = twint.Config()
|
||||||
|
# c.__dict__.update(kwargs)
|
||||||
|
# twint.run.Search(c)
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# previous_statement_text = None
|
||||||
|
# previous_statement_search_text = ''
|
||||||
|
#
|
||||||
|
# statements_to_create = []
|
||||||
|
#
|
||||||
|
# for conversation_count, text in enumerate(conversation):
|
||||||
|
# if self.show_training_progress:
|
||||||
|
# utils.print_progress_bar(
|
||||||
|
# 'List Trainer',
|
||||||
|
# conversation_count + 1, len(conversation)
|
||||||
|
# )
|
||||||
|
#
|
||||||
|
# statement_search_text = self.chatbot.storage.tagger.get_text_index_string(text)
|
||||||
|
#
|
||||||
|
# statement = self.get_preprocessed_statement(
|
||||||
|
# Statement(
|
||||||
|
# text=text,
|
||||||
|
# search_text=statement_search_text,
|
||||||
|
# in_response_to=previous_statement_text,
|
||||||
|
# search_in_response_to=previous_statement_search_text,
|
||||||
|
# conversation='training'
|
||||||
|
# )
|
||||||
|
# )
|
||||||
|
#
|
||||||
|
# previous_statement_text = statement.text
|
||||||
|
# previous_statement_search_text = statement_search_text
|
||||||
|
#
|
||||||
|
# statements_to_create.append(statement)
|
||||||
|
#
|
||||||
|
# self.chatbot.storage.create_many(statements_to_create)
|
@ -58,11 +58,7 @@ class CogLint(Cog):
|
|||||||
|
|
||||||
future = await self.bot.loop.run_in_executor(None, lint.py_run, path, "return_std=True")
|
future = await self.bot.loop.run_in_executor(None, lint.py_run, path, "return_std=True")
|
||||||
|
|
||||||
if future:
|
(pylint_stdout, pylint_stderr) = future or (None, None)
|
||||||
(pylint_stdout, pylint_stderr) = future
|
|
||||||
else:
|
|
||||||
(pylint_stdout, pylint_stderr) = None, None
|
|
||||||
|
|
||||||
# print(pylint_stderr)
|
# print(pylint_stderr)
|
||||||
# print(pylint_stdout)
|
# print(pylint_stdout)
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
from abc import ABC
|
from abc import ABC
|
||||||
@ -13,6 +14,8 @@ from redbot.core import Config, commands
|
|||||||
from redbot.core.bot import Red
|
from redbot.core.bot import Red
|
||||||
from redbot.core.data_manager import bundled_data_path, cog_data_path
|
from redbot.core.data_manager import bundled_data_path, cog_data_path
|
||||||
|
|
||||||
|
log = logging.getLogger("red.fox_v3.conquest")
|
||||||
|
|
||||||
|
|
||||||
class Conquest(commands.Cog):
|
class Conquest(commands.Cog):
|
||||||
"""
|
"""
|
||||||
@ -53,22 +56,27 @@ class Conquest(commands.Cog):
|
|||||||
self.current_map = await self.config.current_map()
|
self.current_map = await self.config.current_map()
|
||||||
|
|
||||||
if self.current_map:
|
if self.current_map:
|
||||||
await self.current_map_load()
|
if not await self.current_map_load():
|
||||||
|
await self.config.current_map.clear()
|
||||||
|
|
||||||
async def current_map_load(self):
|
async def current_map_load(self):
|
||||||
map_data_path = self.asset_path / self.current_map / "data.json"
|
map_data_path = self.asset_path / self.current_map / "data.json"
|
||||||
|
if not map_data_path.exists():
|
||||||
|
log.warning(f"{map_data_path} does not exist. Clearing current map")
|
||||||
|
return False
|
||||||
|
|
||||||
with map_data_path.open() as mapdata:
|
with map_data_path.open() as mapdata:
|
||||||
self.map_data: dict = json.load(mapdata)
|
self.map_data: dict = json.load(mapdata)
|
||||||
self.ext = self.map_data["extension"]
|
self.ext = self.map_data["extension"]
|
||||||
self.ext_format = "JPEG" if self.ext.upper() == "JPG" else self.ext.upper()
|
self.ext_format = "JPEG" if self.ext.upper() == "JPG" else self.ext.upper()
|
||||||
|
return True
|
||||||
|
|
||||||
@commands.group()
|
@commands.group()
|
||||||
async def conquest(self, ctx: commands.Context):
|
async def conquest(self, ctx: commands.Context):
|
||||||
"""
|
"""
|
||||||
Base command for conquest cog. Start with `[p]conquest set map` to select a map.
|
Base command for conquest cog. Start with `[p]conquest set map` to select a map.
|
||||||
"""
|
"""
|
||||||
if ctx.invoked_subcommand is None:
|
if ctx.invoked_subcommand is None and self.current_map is not None:
|
||||||
if self.current_map is not None:
|
|
||||||
await self._conquest_current(ctx)
|
await self._conquest_current(ctx)
|
||||||
|
|
||||||
@conquest.command(name="list")
|
@conquest.command(name="list")
|
||||||
@ -80,13 +88,12 @@ class Conquest(commands.Cog):
|
|||||||
|
|
||||||
with maps_json.open() as maps:
|
with maps_json.open() as maps:
|
||||||
maps_json = json.load(maps)
|
maps_json = json.load(maps)
|
||||||
map_list = "\n".join(map_name for map_name in maps_json["maps"])
|
map_list = "\n".join(maps_json["maps"])
|
||||||
await ctx.maybe_send_embed(f"Current maps:\n{map_list}")
|
await ctx.maybe_send_embed(f"Current maps:\n{map_list}")
|
||||||
|
|
||||||
@conquest.group(name="set")
|
@conquest.group(name="set")
|
||||||
async def conquest_set(self, ctx: commands.Context):
|
async def conquest_set(self, ctx: commands.Context):
|
||||||
"""Base command for admin actions like selecting a map"""
|
"""Base command for admin actions like selecting a map"""
|
||||||
if ctx.invoked_subcommand is None:
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@conquest_set.command(name="resetzoom")
|
@conquest_set.command(name="resetzoom")
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"maps": [
|
"maps": [
|
||||||
"simple_blank_map",
|
"simple",
|
||||||
"test",
|
"ck2",
|
||||||
"test2"
|
"HoI"
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -30,7 +30,6 @@ class MapMaker(commands.Cog):
|
|||||||
"""
|
"""
|
||||||
Base command for managing current maps or creating new ones
|
Base command for managing current maps or creating new ones
|
||||||
"""
|
"""
|
||||||
if ctx.invoked_subcommand is None:
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@mapmaker.command(name="upload")
|
@mapmaker.command(name="upload")
|
||||||
|
@ -65,7 +65,7 @@ def floodfill(image, xy, value, border=None, thresh=0) -> set:
|
|||||||
if border is None:
|
if border is None:
|
||||||
fill = _color_diff(p, background) <= thresh
|
fill = _color_diff(p, background) <= thresh
|
||||||
else:
|
else:
|
||||||
fill = p != value and p != border
|
fill = p not in [value, border]
|
||||||
if fill:
|
if fill:
|
||||||
pixel[s, t] = value
|
pixel[s, t] = value
|
||||||
new_edge.add((s, t))
|
new_edge.add((s, t))
|
||||||
|
@ -27,7 +27,6 @@ class ExclusiveRole(Cog):
|
|||||||
async def exclusive(self, ctx):
|
async def exclusive(self, ctx):
|
||||||
"""Base command for managing exclusive roles"""
|
"""Base command for managing exclusive roles"""
|
||||||
|
|
||||||
if not ctx.invoked_subcommand:
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@exclusive.command(name="add")
|
@exclusive.command(name="add")
|
||||||
@ -85,7 +84,7 @@ class ExclusiveRole(Cog):
|
|||||||
if role_set is None:
|
if role_set is None:
|
||||||
role_set = set(await self.config.guild(member.guild).role_list())
|
role_set = set(await self.config.guild(member.guild).role_list())
|
||||||
|
|
||||||
member_set = set([role.id for role in member.roles])
|
member_set = {role.id for role in member.roles}
|
||||||
to_remove = (member_set - role_set) - {member.guild.default_role.id}
|
to_remove = (member_set - role_set) - {member.guild.default_role.id}
|
||||||
|
|
||||||
if to_remove and member_set & role_set:
|
if to_remove and member_set & role_set:
|
||||||
@ -103,7 +102,7 @@ class ExclusiveRole(Cog):
|
|||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
|
|
||||||
role_set = set(await self.config.guild(after.guild).role_list())
|
role_set = set(await self.config.guild(after.guild).role_list())
|
||||||
member_set = set([role.id for role in after.roles])
|
member_set = {role.id for role in after.roles}
|
||||||
|
|
||||||
if role_set & member_set:
|
if role_set & member_set:
|
||||||
try:
|
try:
|
||||||
|
@ -68,10 +68,7 @@ class CapturePrint:
|
|||||||
self.string = None
|
self.string = None
|
||||||
|
|
||||||
def write(self, string):
|
def write(self, string):
|
||||||
if self.string is None:
|
self.string = string if self.string is None else self.string + "\n" + string
|
||||||
self.string = string
|
|
||||||
else:
|
|
||||||
self.string = self.string + "\n" + string
|
|
||||||
|
|
||||||
|
|
||||||
class FIFO(commands.Cog):
|
class FIFO(commands.Cog):
|
||||||
@ -230,7 +227,6 @@ class FIFO(commands.Cog):
|
|||||||
"""
|
"""
|
||||||
Base command for handling scheduling of tasks
|
Base command for handling scheduling of tasks
|
||||||
"""
|
"""
|
||||||
if ctx.invoked_subcommand is None:
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@fifo.command(name="wakeup")
|
@fifo.command(name="wakeup")
|
||||||
@ -445,6 +441,7 @@ class FIFO(commands.Cog):
|
|||||||
self.scheduler.print_jobs(out=cp)
|
self.scheduler.print_jobs(out=cp)
|
||||||
|
|
||||||
out = cp.string
|
out = cp.string
|
||||||
|
out=out.replace("*","\*")
|
||||||
|
|
||||||
if out:
|
if out:
|
||||||
if len(out) > 2000:
|
if len(out) > 2000:
|
||||||
@ -522,7 +519,6 @@ class FIFO(commands.Cog):
|
|||||||
"""
|
"""
|
||||||
Add a new trigger for a task from the current guild.
|
Add a new trigger for a task from the current guild.
|
||||||
"""
|
"""
|
||||||
if ctx.invoked_subcommand is None:
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@fifo_trigger.command(name="interval")
|
@fifo_trigger.command(name="interval")
|
||||||
|
@ -90,6 +90,7 @@ things_for_fakemessage_to_steal = [
|
|||||||
"content",
|
"content",
|
||||||
"nonce",
|
"nonce",
|
||||||
"reference",
|
"reference",
|
||||||
|
"_edited_timestamp" # New 7/23/21
|
||||||
]
|
]
|
||||||
|
|
||||||
things_fakemessage_sets_by_default = {
|
things_fakemessage_sets_by_default = {
|
||||||
@ -142,7 +143,7 @@ class FakeMessage(discord.Message):
|
|||||||
self._update(
|
self._update(
|
||||||
{
|
{
|
||||||
"mention_roles": self.raw_role_mentions,
|
"mention_roles": self.raw_role_mentions,
|
||||||
"mentions": self.raw_mentions,
|
"mentions": [{"id": _id} for _id in self.raw_mentions],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -55,7 +55,6 @@ class Flag(Cog):
|
|||||||
"""
|
"""
|
||||||
Commands for managing Flag settings
|
Commands for managing Flag settings
|
||||||
"""
|
"""
|
||||||
if ctx.invoked_subcommand is None:
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@flagset.command(name="expire")
|
@flagset.command(name="expire")
|
||||||
|
@ -147,7 +147,6 @@ class Hangman(Cog):
|
|||||||
@checks.mod_or_permissions(administrator=True)
|
@checks.mod_or_permissions(administrator=True)
|
||||||
async def hangset(self, ctx):
|
async def hangset(self, ctx):
|
||||||
"""Adjust hangman settings"""
|
"""Adjust hangman settings"""
|
||||||
if ctx.invoked_subcommand is None:
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@hangset.command()
|
@hangset.command()
|
||||||
@ -250,7 +249,7 @@ class Hangman(Cog):
|
|||||||
|
|
||||||
self.winbool[guild] = True
|
self.winbool[guild] = True
|
||||||
for i in self.the_data[guild]["answer"]:
|
for i in self.the_data[guild]["answer"]:
|
||||||
if i == " " or i == "-":
|
if i in [" ", "-"]:
|
||||||
out_str += i * 2
|
out_str += i * 2
|
||||||
elif i in self.the_data[guild]["guesses"] or i not in "ABCDEFGHIJKLMNOPQRSTUVWXYZ":
|
elif i in self.the_data[guild]["guesses"] or i not in "ABCDEFGHIJKLMNOPQRSTUVWXYZ":
|
||||||
out_str += "__" + i + "__ "
|
out_str += "__" + i + "__ "
|
||||||
@ -262,9 +261,7 @@ class Hangman(Cog):
|
|||||||
|
|
||||||
def _guesslist(self, guild):
|
def _guesslist(self, guild):
|
||||||
"""Returns the current letter list"""
|
"""Returns the current letter list"""
|
||||||
out_str = ""
|
out_str = "".join(str(i) + "," for i in self.the_data[guild]["guesses"])
|
||||||
for i in self.the_data[guild]["guesses"]:
|
|
||||||
out_str += str(i) + ","
|
|
||||||
out_str = out_str[:-1]
|
out_str = out_str[:-1]
|
||||||
|
|
||||||
return out_str
|
return out_str
|
||||||
|
@ -28,9 +28,12 @@ async def get_channel_counts(category, guild):
|
|||||||
online_num = members - offline_num
|
online_num = members - offline_num
|
||||||
# Gets count of actual users
|
# Gets count of actual users
|
||||||
human_num = members - bot_num
|
human_num = members - bot_num
|
||||||
|
# count amount of premium subs/nitro subs.
|
||||||
|
boosters = guild.premium_subscription_count
|
||||||
return {
|
return {
|
||||||
"members": members,
|
"members": members,
|
||||||
"humans": human_num,
|
"humans": human_num,
|
||||||
|
"boosters": boosters,
|
||||||
"bots": bot_num,
|
"bots": bot_num,
|
||||||
"roles": roles_num,
|
"roles": roles_num,
|
||||||
"channels": channels_num,
|
"channels": channels_num,
|
||||||
@ -58,6 +61,7 @@ class InfoChannel(Cog):
|
|||||||
self.default_channel_names = {
|
self.default_channel_names = {
|
||||||
"members": "Members: {count}",
|
"members": "Members: {count}",
|
||||||
"humans": "Humans: {count}",
|
"humans": "Humans: {count}",
|
||||||
|
"boosters": "Boosters: {count}",
|
||||||
"bots": "Bots: {count}",
|
"bots": "Bots: {count}",
|
||||||
"roles": "Roles: {count}",
|
"roles": "Roles: {count}",
|
||||||
"channels": "Channels: {count}",
|
"channels": "Channels: {count}",
|
||||||
@ -65,9 +69,9 @@ class InfoChannel(Cog):
|
|||||||
"offline": "Offline: {count}",
|
"offline": "Offline: {count}",
|
||||||
}
|
}
|
||||||
|
|
||||||
default_channel_ids = {k: None for k in self.default_channel_names.keys()}
|
default_channel_ids = {k: None for k in self.default_channel_names}
|
||||||
# Only members is enabled by default
|
# Only members is enabled by default
|
||||||
default_enabled_counts = {k: k == "members" for k in self.default_channel_names.keys()}
|
default_enabled_counts = {k: k == "members" for k in self.default_channel_names}
|
||||||
|
|
||||||
default_guild = {
|
default_guild = {
|
||||||
"category_id": None,
|
"category_id": None,
|
||||||
@ -159,7 +163,6 @@ class InfoChannel(Cog):
|
|||||||
"""
|
"""
|
||||||
Toggle different types of infochannels
|
Toggle different types of infochannels
|
||||||
"""
|
"""
|
||||||
if not ctx.invoked_subcommand:
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@infochannelset.command(name="togglechannel")
|
@infochannelset.command(name="togglechannel")
|
||||||
@ -171,6 +174,7 @@ class InfoChannel(Cog):
|
|||||||
Valid Types are:
|
Valid Types are:
|
||||||
- `members`: Total members on the server
|
- `members`: Total members on the server
|
||||||
- `humans`: Total members that aren't bots
|
- `humans`: Total members that aren't bots
|
||||||
|
- `boosters`: Total amount of boosters
|
||||||
- `bots`: Total bots
|
- `bots`: Total bots
|
||||||
- `roles`: Total number of roles
|
- `roles`: Total number of roles
|
||||||
- `channels`: Total number of channels excluding infochannels,
|
- `channels`: Total number of channels excluding infochannels,
|
||||||
@ -225,6 +229,7 @@ class InfoChannel(Cog):
|
|||||||
Valid Types are:
|
Valid Types are:
|
||||||
- `members`: Total members on the server
|
- `members`: Total members on the server
|
||||||
- `humans`: Total members that aren't bots
|
- `humans`: Total members that aren't bots
|
||||||
|
- `boosters`: Total amount of boosters
|
||||||
- `bots`: Total bots
|
- `bots`: Total bots
|
||||||
- `roles`: Total number of roles
|
- `roles`: Total number of roles
|
||||||
- `channels`: Total number of channels excluding infochannels
|
- `channels`: Total number of channels excluding infochannels
|
||||||
@ -442,6 +447,7 @@ class InfoChannel(Cog):
|
|||||||
guild,
|
guild,
|
||||||
members=True,
|
members=True,
|
||||||
humans=True,
|
humans=True,
|
||||||
|
boosters=True,
|
||||||
bots=True,
|
bots=True,
|
||||||
roles=True,
|
roles=True,
|
||||||
channels=True,
|
channels=True,
|
||||||
@ -498,14 +504,16 @@ class InfoChannel(Cog):
|
|||||||
guild_data = await self.config.guild(guild).all()
|
guild_data = await self.config.guild(guild).all()
|
||||||
|
|
||||||
to_update = (
|
to_update = (
|
||||||
kwargs.keys() & guild_data["enabled_channels"].keys()
|
kwargs.keys() & [key for key, value in guild_data["enabled_channels"].items() if value]
|
||||||
) # Value in kwargs doesn't matter
|
) # Value in kwargs doesn't matter
|
||||||
|
|
||||||
log.debug(f"{to_update=}")
|
|
||||||
|
|
||||||
if to_update or extra_roles:
|
if to_update or extra_roles:
|
||||||
|
log.debug(f"{to_update=}\n"
|
||||||
|
f"{extra_roles=}")
|
||||||
|
|
||||||
category = guild.get_channel(guild_data["category_id"])
|
category = guild.get_channel(guild_data["category_id"])
|
||||||
if category is None:
|
if category is None:
|
||||||
|
log.debug('Channel category is missing, updating must be off')
|
||||||
return # Nothing to update, must be off
|
return # Nothing to update, must be off
|
||||||
|
|
||||||
channel_data = await get_channel_counts(category, guild)
|
channel_data = await get_channel_counts(category, guild)
|
||||||
|
@ -36,58 +36,6 @@ class LaunchLib(commands.Cog):
|
|||||||
|
|
||||||
async def _embed_launch_data(self, launch: ll.AsyncLaunch):
|
async def _embed_launch_data(self, launch: ll.AsyncLaunch):
|
||||||
|
|
||||||
if False:
|
|
||||||
example_launch = ll.AsyncLaunch(
|
|
||||||
id="9279744e-46b2-4eca-adea-f1379672ec81",
|
|
||||||
name="Atlas LV-3A | Samos 2",
|
|
||||||
tbddate=False,
|
|
||||||
tbdtime=False,
|
|
||||||
status={"id": 3, "name": "Success"},
|
|
||||||
inhold=False,
|
|
||||||
windowstart="1961-01-31 20:21:19+00:00",
|
|
||||||
windowend="1961-01-31 20:21:19+00:00",
|
|
||||||
net="1961-01-31 20:21:19+00:00",
|
|
||||||
info_urls=[],
|
|
||||||
vid_urls=[],
|
|
||||||
holdreason=None,
|
|
||||||
failreason=None,
|
|
||||||
probability=0,
|
|
||||||
hashtag=None,
|
|
||||||
agency=None,
|
|
||||||
changed=None,
|
|
||||||
pad=ll.Pad(
|
|
||||||
id=93,
|
|
||||||
name="Space Launch Complex 3W",
|
|
||||||
latitude=34.644,
|
|
||||||
longitude=-120.593,
|
|
||||||
map_url="http://maps.google.com/maps?q=34.644+N,+120.593+W",
|
|
||||||
retired=None,
|
|
||||||
total_launch_count=3,
|
|
||||||
agency_id=161,
|
|
||||||
wiki_url=None,
|
|
||||||
info_url=None,
|
|
||||||
location=ll.Location(
|
|
||||||
id=11,
|
|
||||||
name="Vandenberg AFB, CA, USA",
|
|
||||||
country_code="USA",
|
|
||||||
total_launch_count=83,
|
|
||||||
total_landing_count=3,
|
|
||||||
pads=None,
|
|
||||||
),
|
|
||||||
map_image="https://spacelaunchnow-prod-east.nyc3.digitaloceanspaces.com/media/launch_images/pad_93_20200803143225.jpg",
|
|
||||||
),
|
|
||||||
rocket=ll.Rocket(
|
|
||||||
id=2362,
|
|
||||||
name=None,
|
|
||||||
default_pads=None,
|
|
||||||
family=None,
|
|
||||||
wiki_url=None,
|
|
||||||
info_url=None,
|
|
||||||
image_url=None,
|
|
||||||
),
|
|
||||||
missions=None,
|
|
||||||
)
|
|
||||||
|
|
||||||
# status: ll.AsyncLaunchStatus = await launch.get_status()
|
# status: ll.AsyncLaunchStatus = await launch.get_status()
|
||||||
status = launch.status
|
status = launch.status
|
||||||
|
|
||||||
@ -102,11 +50,7 @@ class LaunchLib(commands.Cog):
|
|||||||
if launch.pad:
|
if launch.pad:
|
||||||
urls += [launch.pad.info_url, launch.pad.wiki_url]
|
urls += [launch.pad.info_url, launch.pad.wiki_url]
|
||||||
|
|
||||||
if urls:
|
url = next((url for url in urls if urls is not None), None) if urls else None
|
||||||
url = next((url for url in urls if urls is not None), None)
|
|
||||||
else:
|
|
||||||
url = None
|
|
||||||
|
|
||||||
color = discord.Color.green() if status["id"] in [1, 3] else discord.Color.red()
|
color = discord.Color.green() if status["id"] in [1, 3] else discord.Color.red()
|
||||||
|
|
||||||
em = discord.Embed(title=title, description=description, url=url, color=color)
|
em = discord.Embed(title=title, description=description, url=url, color=color)
|
||||||
@ -152,7 +96,9 @@ class LaunchLib(commands.Cog):
|
|||||||
|
|
||||||
if pad_name is not None:
|
if pad_name is not None:
|
||||||
if location_url is not None:
|
if location_url is not None:
|
||||||
location_url = re.sub("[^a-zA-Z0-9/:.'+\"°?=,-]", "", location_url) # Fix bad URLS
|
location_url = re.sub(
|
||||||
|
"[^a-zA-Z0-9/:.'+\"°?=,-]", "", location_url
|
||||||
|
) # Fix bad URLS
|
||||||
em.add_field(name="Launch Pad Name", value=f"[{pad_name}]({location_url})")
|
em.add_field(name="Launch Pad Name", value=f"[{pad_name}]({location_url})")
|
||||||
else:
|
else:
|
||||||
em.add_field(name="Launch Pad Name", value=pad_name)
|
em.add_field(name="Launch Pad Name", value=pad_name)
|
||||||
@ -169,7 +115,6 @@ class LaunchLib(commands.Cog):
|
|||||||
@commands.group()
|
@commands.group()
|
||||||
async def launchlib(self, ctx: commands.Context):
|
async def launchlib(self, ctx: commands.Context):
|
||||||
"""Base command for getting launches"""
|
"""Base command for getting launches"""
|
||||||
if ctx.invoked_subcommand is None:
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@launchlib.command()
|
@launchlib.command()
|
||||||
|
@ -25,7 +25,6 @@ class Leaver(Cog):
|
|||||||
@checks.mod_or_permissions(administrator=True)
|
@checks.mod_or_permissions(administrator=True)
|
||||||
async def leaverset(self, ctx):
|
async def leaverset(self, ctx):
|
||||||
"""Adjust leaver settings"""
|
"""Adjust leaver settings"""
|
||||||
if ctx.invoked_subcommand is None:
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@leaverset.command()
|
@leaverset.command()
|
||||||
@ -57,5 +56,3 @@ class Leaver(Cog):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
await channel.send(out)
|
await channel.send(out)
|
||||||
else:
|
|
||||||
pass
|
|
||||||
|
@ -40,16 +40,20 @@ class LoveCalculator(Cog):
|
|||||||
log.debug(f"{resp=}")
|
log.debug(f"{resp=}")
|
||||||
soup_object = BeautifulSoup(resp, "html.parser")
|
soup_object = BeautifulSoup(resp, "html.parser")
|
||||||
|
|
||||||
description = soup_object.find("div", class_="result__score").get_text()
|
description = soup_object.find("div", class_="result__score")
|
||||||
|
|
||||||
if description is None:
|
if description is None:
|
||||||
description = "Dr. Love is busy right now"
|
description = "Dr. Love is busy right now"
|
||||||
else:
|
else:
|
||||||
description = description.strip()
|
description = description.get_text().strip()
|
||||||
|
|
||||||
result_image = soup_object.find("img", class_="result__image").get("src")
|
result_image = soup_object.find("img", class_="result__image").get("src")
|
||||||
|
|
||||||
result_text = soup_object.find("div", class_="result-text").get_text()
|
result_text = soup_object.find("div", class_="result-text")
|
||||||
|
if result_text is None:
|
||||||
|
result_text = f"{x} and {y} aren't compatible 😔"
|
||||||
|
else:
|
||||||
|
result_text = result_text.get_text()
|
||||||
result_text = " ".join(result_text.split())
|
result_text = " ".join(result_text.split())
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -45,13 +45,11 @@ class LastSeen(Cog):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_date_time(s):
|
def get_date_time(s):
|
||||||
d = dateutil.parser.parse(s)
|
return dateutil.parser.parse(s)
|
||||||
return d
|
|
||||||
|
|
||||||
@commands.group(aliases=["setlseen"], name="lseenset")
|
@commands.group(aliases=["setlseen"], name="lseenset")
|
||||||
async def lset(self, ctx: commands.Context):
|
async def lset(self, ctx: commands.Context):
|
||||||
"""Change settings for lseen"""
|
"""Change settings for lseen"""
|
||||||
if ctx.invoked_subcommand is None:
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@lset.command(name="toggle")
|
@lset.command(name="toggle")
|
||||||
@ -79,11 +77,13 @@ class LastSeen(Cog):
|
|||||||
return
|
return
|
||||||
last_seen = self.get_date_time(last_seen)
|
last_seen = self.get_date_time(last_seen)
|
||||||
|
|
||||||
# embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
# description="{} was last seen at this date and time".format(member.display_name),
|
description="{} was last seen at this date and time".format(member.display_name),
|
||||||
# timestamp=last_seen)
|
timestamp=last_seen,
|
||||||
|
color=await self.bot.get_embed_color(ctx),
|
||||||
|
)
|
||||||
|
|
||||||
embed = discord.Embed(timestamp=last_seen, color=await self.bot.get_embed_color(ctx))
|
# embed = discord.Embed(timestamp=last_seen, color=await self.bot.get_embed_color(ctx))
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
|
|
||||||
@commands.Cog.listener()
|
@commands.Cog.listener()
|
||||||
|
@ -111,7 +111,6 @@ async def _withdraw_points(gardener: Gardener, amount):
|
|||||||
|
|
||||||
if (gardener.points - amount) < 0:
|
if (gardener.points - amount) < 0:
|
||||||
return False
|
return False
|
||||||
else:
|
|
||||||
gardener.points -= amount
|
gardener.points -= amount
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -245,11 +244,9 @@ class PlantTycoon(commands.Cog):
|
|||||||
await self._load_plants_products()
|
await self._load_plants_products()
|
||||||
|
|
||||||
modifiers = sum(
|
modifiers = sum(
|
||||||
[
|
|
||||||
self.products[product]["modifier"]
|
self.products[product]["modifier"]
|
||||||
for product in gardener.products
|
for product in gardener.products
|
||||||
if gardener.products[product] > 0
|
if gardener.products[product] > 0
|
||||||
]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
degradation = (
|
degradation = (
|
||||||
@ -290,17 +287,15 @@ class PlantTycoon(commands.Cog):
|
|||||||
product = product.lower()
|
product = product.lower()
|
||||||
product_category = product_category.lower()
|
product_category = product_category.lower()
|
||||||
if product in self.products and self.products[product]["category"] == product_category:
|
if product in self.products and self.products[product]["category"] == product_category:
|
||||||
if product in gardener.products:
|
if product in gardener.products and gardener.products[product] > 0:
|
||||||
if gardener.products[product] > 0:
|
|
||||||
gardener.current["health"] += self.products[product]["health"]
|
gardener.current["health"] += self.products[product]["health"]
|
||||||
gardener.products[product] -= 1
|
gardener.products[product] -= 1
|
||||||
if gardener.products[product] == 0:
|
if gardener.products[product] == 0:
|
||||||
del gardener.products[product.lower()]
|
del gardener.products[product.lower()]
|
||||||
if product_category == "water":
|
if product_category == "fertilizer":
|
||||||
emoji = ":sweat_drops:"
|
|
||||||
elif product_category == "fertilizer":
|
|
||||||
emoji = ":poop:"
|
emoji = ":poop:"
|
||||||
# elif product_category == "tool":
|
elif product_category == "water":
|
||||||
|
emoji = ":sweat_drops:"
|
||||||
else:
|
else:
|
||||||
emoji = ":scissors:"
|
emoji = ":scissors:"
|
||||||
message = "Your plant got some health back! {}".format(emoji)
|
message = "Your plant got some health back! {}".format(emoji)
|
||||||
@ -310,18 +305,13 @@ class PlantTycoon(commands.Cog):
|
|||||||
damage_msg = "You used {} too many times!".format(product)
|
damage_msg = "You used {} too many times!".format(product)
|
||||||
else:
|
else:
|
||||||
damage_msg = "You gave too much of {}.".format(product)
|
damage_msg = "You gave too much of {}.".format(product)
|
||||||
message = "{} Your plant lost some health. :wilted_rose:".format(
|
message = "{} Your plant lost some health. :wilted_rose:".format(damage_msg)
|
||||||
damage_msg
|
|
||||||
)
|
|
||||||
gardener.points += self.defaults["points"]["add_health"]
|
gardener.points += self.defaults["points"]["add_health"]
|
||||||
await gardener.save_gardener()
|
await gardener.save_gardener()
|
||||||
else:
|
elif product in gardener.products or product_category != "tool":
|
||||||
message = "You have no {}. Go buy some!".format(product)
|
message = "You have no {}. Go buy some!".format(product)
|
||||||
else:
|
else:
|
||||||
if product_category == "tool":
|
|
||||||
message = "You don't have a {}. Go buy one!".format(product)
|
message = "You don't have a {}. Go buy one!".format(product)
|
||||||
else:
|
|
||||||
message = "You have no {}. Go buy some!".format(product)
|
|
||||||
else:
|
else:
|
||||||
message = "Are you sure you are using {}?".format(product_category)
|
message = "Are you sure you are using {}?".format(product_category)
|
||||||
|
|
||||||
@ -412,24 +402,18 @@ class PlantTycoon(commands.Cog):
|
|||||||
gardener.current = plant
|
gardener.current = plant
|
||||||
await gardener.save_gardener()
|
await gardener.save_gardener()
|
||||||
|
|
||||||
em = discord.Embed(description=message, color=discord.Color.green())
|
|
||||||
else:
|
else:
|
||||||
plant = gardener.current
|
plant = gardener.current
|
||||||
message = "You're already growing {} **{}**, silly.".format(
|
message = "You're already growing {} **{}**, silly.".format(
|
||||||
plant["article"], plant["name"]
|
plant["article"], plant["name"]
|
||||||
)
|
)
|
||||||
em = discord.Embed(description=message, color=discord.Color.green())
|
em = discord.Embed(description=message, color=discord.Color.green())
|
||||||
|
|
||||||
await ctx.send(embed=em)
|
await ctx.send(embed=em)
|
||||||
|
|
||||||
@_gardening.command(name="profile")
|
@_gardening.command(name="profile")
|
||||||
async def _profile(self, ctx: commands.Context, *, member: discord.Member = None):
|
async def _profile(self, ctx: commands.Context, *, member: discord.Member = None):
|
||||||
"""Check your gardening profile."""
|
"""Check your gardening profile."""
|
||||||
if member is not None:
|
author = member if member is not None else ctx.author
|
||||||
author = member
|
|
||||||
else:
|
|
||||||
author = ctx.author
|
|
||||||
|
|
||||||
gardener = await self._gardener(author)
|
gardener = await self._gardener(author)
|
||||||
try:
|
try:
|
||||||
await self._apply_degradation(gardener)
|
await self._apply_degradation(gardener)
|
||||||
@ -440,9 +424,7 @@ class PlantTycoon(commands.Cog):
|
|||||||
avatar = author.avatar_url if author.avatar else author.default_avatar_url
|
avatar = author.avatar_url if author.avatar else author.default_avatar_url
|
||||||
em.set_author(name="Gardening profile of {}".format(author.name), icon_url=avatar)
|
em.set_author(name="Gardening profile of {}".format(author.name), icon_url=avatar)
|
||||||
em.add_field(name="**Thneeds**", value=str(gardener.points))
|
em.add_field(name="**Thneeds**", value=str(gardener.points))
|
||||||
if not gardener.current:
|
if gardener.current:
|
||||||
em.add_field(name="**Currently growing**", value="None")
|
|
||||||
else:
|
|
||||||
em.set_thumbnail(url=gardener.current["image"])
|
em.set_thumbnail(url=gardener.current["image"])
|
||||||
em.add_field(
|
em.add_field(
|
||||||
name="**Currently growing**",
|
name="**Currently growing**",
|
||||||
@ -450,16 +432,15 @@ class PlantTycoon(commands.Cog):
|
|||||||
gardener.current["name"], gardener.current["health"]
|
gardener.current["name"], gardener.current["health"]
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
em.add_field(name="**Currently growing**", value="None")
|
||||||
if not gardener.badges:
|
if not gardener.badges:
|
||||||
em.add_field(name="**Badges**", value="None")
|
em.add_field(name="**Badges**", value="None")
|
||||||
else:
|
else:
|
||||||
badges = ""
|
badges = "".join("{}\n".format(badge.capitalize()) for badge in gardener.badges)
|
||||||
for badge in gardener.badges:
|
|
||||||
badges += "{}\n".format(badge.capitalize())
|
|
||||||
em.add_field(name="**Badges**", value=badges)
|
em.add_field(name="**Badges**", value=badges)
|
||||||
if not gardener.products:
|
if gardener.products:
|
||||||
em.add_field(name="**Products**", value="None")
|
|
||||||
else:
|
|
||||||
products = ""
|
products = ""
|
||||||
for product_name, product_data in gardener.products.items():
|
for product_name, product_data in gardener.products.items():
|
||||||
if self.products[product_name] is None:
|
if self.products[product_name] is None:
|
||||||
@ -470,6 +451,8 @@ class PlantTycoon(commands.Cog):
|
|||||||
self.products[product_name]["modifier"],
|
self.products[product_name]["modifier"],
|
||||||
)
|
)
|
||||||
em.add_field(name="**Products**", value=products)
|
em.add_field(name="**Products**", value=products)
|
||||||
|
else:
|
||||||
|
em.add_field(name="**Products**", value="None")
|
||||||
if gardener.current:
|
if gardener.current:
|
||||||
degradation = await self._degradation(gardener)
|
degradation = await self._degradation(gardener)
|
||||||
die_in = await _die_in(gardener, degradation)
|
die_in = await _die_in(gardener, degradation)
|
||||||
@ -600,7 +583,6 @@ class PlantTycoon(commands.Cog):
|
|||||||
self.products[pd]["category"],
|
self.products[pd]["category"],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
await ctx.send(embed=em)
|
|
||||||
else:
|
else:
|
||||||
if amount <= 0:
|
if amount <= 0:
|
||||||
message = "Invalid amount! Must be greater than 1"
|
message = "Invalid amount! Must be greater than 1"
|
||||||
@ -629,6 +611,7 @@ class PlantTycoon(commands.Cog):
|
|||||||
else:
|
else:
|
||||||
message = "I don't have this product."
|
message = "I don't have this product."
|
||||||
em = discord.Embed(description=message, color=discord.Color.green())
|
em = discord.Embed(description=message, color=discord.Color.green())
|
||||||
|
|
||||||
await ctx.send(embed=em)
|
await ctx.send(embed=em)
|
||||||
|
|
||||||
@_gardening.command(name="convert")
|
@_gardening.command(name="convert")
|
||||||
@ -663,8 +646,7 @@ class PlantTycoon(commands.Cog):
|
|||||||
else:
|
else:
|
||||||
gardener.current = {}
|
gardener.current = {}
|
||||||
message = "You successfully shovelled your plant out."
|
message = "You successfully shovelled your plant out."
|
||||||
if gardener.points < 0:
|
gardener.points = max(gardener.points, 0)
|
||||||
gardener.points = 0
|
|
||||||
await gardener.save_gardener()
|
await gardener.save_gardener()
|
||||||
|
|
||||||
em = discord.Embed(description=message, color=discord.Color.dark_grey())
|
em = discord.Embed(description=message, color=discord.Color.dark_grey())
|
||||||
@ -681,12 +663,12 @@ class PlantTycoon(commands.Cog):
|
|||||||
except discord.Forbidden:
|
except discord.Forbidden:
|
||||||
# Couldn't DM the degradation
|
# Couldn't DM the degradation
|
||||||
await ctx.send("ERROR\nYou blocked me, didn't you?")
|
await ctx.send("ERROR\nYou blocked me, didn't you?")
|
||||||
product = "water"
|
|
||||||
product_category = "water"
|
|
||||||
if not gardener.current:
|
if not gardener.current:
|
||||||
message = "You're currently not growing a plant."
|
message = "You're currently not growing a plant."
|
||||||
await _send_message(channel, message)
|
await _send_message(channel, message)
|
||||||
else:
|
else:
|
||||||
|
product = "water"
|
||||||
|
product_category = "water"
|
||||||
await self._add_health(channel, gardener, product, product_category)
|
await self._add_health(channel, gardener, product, product_category)
|
||||||
|
|
||||||
@commands.command(name="fertilize")
|
@commands.command(name="fertilize")
|
||||||
@ -700,11 +682,11 @@ class PlantTycoon(commands.Cog):
|
|||||||
await ctx.send("ERROR\nYou blocked me, didn't you?")
|
await ctx.send("ERROR\nYou blocked me, didn't you?")
|
||||||
channel = ctx.channel
|
channel = ctx.channel
|
||||||
product = fertilizer
|
product = fertilizer
|
||||||
product_category = "fertilizer"
|
|
||||||
if not gardener.current:
|
if not gardener.current:
|
||||||
message = "You're currently not growing a plant."
|
message = "You're currently not growing a plant."
|
||||||
await _send_message(channel, message)
|
await _send_message(channel, message)
|
||||||
else:
|
else:
|
||||||
|
product_category = "fertilizer"
|
||||||
await self._add_health(channel, gardener, product, product_category)
|
await self._add_health(channel, gardener, product, product_category)
|
||||||
|
|
||||||
@commands.command(name="prune")
|
@commands.command(name="prune")
|
||||||
@ -717,12 +699,12 @@ class PlantTycoon(commands.Cog):
|
|||||||
# Couldn't DM the degradation
|
# Couldn't DM the degradation
|
||||||
await ctx.send("ERROR\nYou blocked me, didn't you?")
|
await ctx.send("ERROR\nYou blocked me, didn't you?")
|
||||||
channel = ctx.channel
|
channel = ctx.channel
|
||||||
product = "pruner"
|
|
||||||
product_category = "tool"
|
|
||||||
if not gardener.current:
|
if not gardener.current:
|
||||||
message = "You're currently not growing a plant."
|
message = "You're currently not growing a plant."
|
||||||
await _send_message(channel, message)
|
await _send_message(channel, message)
|
||||||
else:
|
else:
|
||||||
|
product = "pruner"
|
||||||
|
product_category = "tool"
|
||||||
await self._add_health(channel, gardener, product, product_category)
|
await self._add_health(channel, gardener, product, product_category)
|
||||||
|
|
||||||
# async def check_degradation(self):
|
# async def check_degradation(self):
|
||||||
|
@ -67,8 +67,10 @@ class QRInvite(Cog):
|
|||||||
|
|
||||||
extension = pathlib.Path(image_url).parts[-1].replace(".", "?").split("?")[1]
|
extension = pathlib.Path(image_url).parts[-1].replace(".", "?").split("?")[1]
|
||||||
|
|
||||||
|
save_as_name = f"{ctx.guild.id}-{ctx.author.id}"
|
||||||
|
|
||||||
path: pathlib.Path = cog_data_path(self)
|
path: pathlib.Path = cog_data_path(self)
|
||||||
image_path = path / (ctx.guild.icon + "." + extension)
|
image_path = path / f"{save_as_name}.{extension}"
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
async with session.get(image_url) as response:
|
async with session.get(image_url) as response:
|
||||||
image = await response.read()
|
image = await response.read()
|
||||||
@ -77,27 +79,29 @@ class QRInvite(Cog):
|
|||||||
file.write(image)
|
file.write(image)
|
||||||
|
|
||||||
if extension == "webp":
|
if extension == "webp":
|
||||||
new_path = convert_webp_to_png(str(image_path))
|
new_image_path = convert_webp_to_png(str(image_path))
|
||||||
elif extension == "gif":
|
elif extension == "gif":
|
||||||
await ctx.maybe_send_embed("gif is not supported yet, stay tuned")
|
await ctx.maybe_send_embed("gif is not supported yet, stay tuned")
|
||||||
return
|
return
|
||||||
elif extension == "png":
|
elif extension == "png":
|
||||||
new_path = str(image_path)
|
new_image_path = str(image_path)
|
||||||
|
elif extension == "jpg":
|
||||||
|
new_image_path = convert_jpg_to_png(str(image_path))
|
||||||
else:
|
else:
|
||||||
await ctx.maybe_send_embed(f"{extension} is not supported yet, stay tuned")
|
await ctx.maybe_send_embed(f"{extension} is not supported yet, stay tuned")
|
||||||
return
|
return
|
||||||
|
|
||||||
myqr.run(
|
myqr.run(
|
||||||
invite,
|
invite,
|
||||||
picture=new_path,
|
picture=new_image_path,
|
||||||
save_name=ctx.guild.icon + "_qrcode.png",
|
save_name=f"{save_as_name}_qrcode.png",
|
||||||
save_dir=str(cog_data_path(self)),
|
save_dir=str(cog_data_path(self)),
|
||||||
colorized=colorized,
|
colorized=colorized,
|
||||||
)
|
)
|
||||||
|
|
||||||
png_path: pathlib.Path = path / (ctx.guild.icon + "_qrcode.png")
|
png_path: pathlib.Path = path / f"{save_as_name}_qrcode.png"
|
||||||
with png_path.open("rb") as png_fp:
|
# with png_path.open("rb") as png_fp:
|
||||||
await ctx.send(file=discord.File(png_fp.read(), "qrcode.png"))
|
await ctx.send(file=discord.File(png_path, "qrcode.png"))
|
||||||
|
|
||||||
|
|
||||||
def convert_webp_to_png(path):
|
def convert_webp_to_png(path):
|
||||||
@ -110,3 +114,10 @@ def convert_webp_to_png(path):
|
|||||||
new_path = path.replace(".webp", ".png")
|
new_path = path.replace(".webp", ".png")
|
||||||
im.save(new_path, transparency=255)
|
im.save(new_path, transparency=255)
|
||||||
return new_path
|
return new_path
|
||||||
|
|
||||||
|
|
||||||
|
def convert_jpg_to_png(path):
|
||||||
|
im = Image.open(path)
|
||||||
|
new_path = path.replace(".jpg", ".png")
|
||||||
|
im.save(new_path)
|
||||||
|
return new_path
|
||||||
|
@ -97,9 +97,7 @@ class ReactRestrict(Cog):
|
|||||||
"""
|
"""
|
||||||
current_combos = await self.combo_list()
|
current_combos = await self.combo_list()
|
||||||
|
|
||||||
to_keep = [
|
to_keep = [c for c in current_combos if c.message_id != message_id or c.role_id != role.id]
|
||||||
c for c in current_combos if not (c.message_id == message_id and c.role_id == role.id)
|
|
||||||
]
|
|
||||||
|
|
||||||
if to_keep != current_combos:
|
if to_keep != current_combos:
|
||||||
await self.set_combo_list(to_keep)
|
await self.set_combo_list(to_keep)
|
||||||
@ -210,7 +208,6 @@ class ReactRestrict(Cog):
|
|||||||
"""
|
"""
|
||||||
Base command for this cog. Check help for the commands list.
|
Base command for this cog. Check help for the commands list.
|
||||||
"""
|
"""
|
||||||
if ctx.invoked_subcommand is None:
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@reactrestrict.command()
|
@reactrestrict.command()
|
||||||
|
@ -32,6 +32,7 @@ class RecyclingPlant(Cog):
|
|||||||
|
|
||||||
x = 0
|
x = 0
|
||||||
reward = 0
|
reward = 0
|
||||||
|
timeoutcount = 0
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
"{0} has signed up for a shift at the Recycling Plant! Type ``exit`` to terminate it early.".format(
|
"{0} has signed up for a shift at the Recycling Plant! Type ``exit`` to terminate it early.".format(
|
||||||
ctx.author.display_name
|
ctx.author.display_name
|
||||||
@ -53,14 +54,25 @@ class RecyclingPlant(Cog):
|
|||||||
return m.author == ctx.author and m.channel == ctx.channel
|
return m.author == ctx.author and m.channel == ctx.channel
|
||||||
|
|
||||||
try:
|
try:
|
||||||
answer = await self.bot.wait_for("message", timeout=120, check=check)
|
answer = await self.bot.wait_for("message", timeout=20, check=check)
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
answer = None
|
answer = None
|
||||||
|
|
||||||
if answer is None:
|
if answer is None:
|
||||||
|
if timeoutcount == 2:
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
"``{}`` fell down the conveyor belt to be sorted again!".format(used["object"])
|
"{} slacked off at work, so they were sacked with no pay.".format(
|
||||||
|
ctx.author.display_name
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
await ctx.send(
|
||||||
|
"{} is slacking, and if they carry on not working, they'll be fired.".format(
|
||||||
|
ctx.author.display_name
|
||||||
|
)
|
||||||
|
)
|
||||||
|
timeoutcount += 1
|
||||||
elif answer.content.lower().strip() == used["action"]:
|
elif answer.content.lower().strip() == used["action"]:
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
"Congratulations! You put ``{}`` down the correct chute! (**+50**)".format(
|
"Congratulations! You put ``{}`` down the correct chute! (**+50**)".format(
|
||||||
|
@ -69,13 +69,12 @@ class RPSLS(Cog):
|
|||||||
|
|
||||||
def get_emote(self, choice):
|
def get_emote(self, choice):
|
||||||
if choice == "rock":
|
if choice == "rock":
|
||||||
emote = ":moyai:"
|
return ":moyai:"
|
||||||
elif choice == "spock":
|
elif choice == "spock":
|
||||||
emote = ":vulcan:"
|
return ":vulcan:"
|
||||||
elif choice == "paper":
|
elif choice == "paper":
|
||||||
emote = ":page_facing_up:"
|
return ":page_facing_up:"
|
||||||
elif choice in ["scissors", "lizard"]:
|
elif choice in ["scissors", "lizard"]:
|
||||||
emote = ":{}:".format(choice)
|
return ":{}:".format(choice)
|
||||||
else:
|
else:
|
||||||
emote = None
|
return None
|
||||||
return emote
|
|
||||||
|
@ -177,7 +177,3 @@ class SCP(Cog):
|
|||||||
|
|
||||||
msg = "http://www.scp-wiki.net/log-of-unexplained-locations"
|
msg = "http://www.scp-wiki.net/log-of-unexplained-locations"
|
||||||
await ctx.maybe_send_embed(msg)
|
await ctx.maybe_send_embed(msg)
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
|
||||||
bot.add_cog(SCP(bot))
|
|
||||||
|
@ -6,6 +6,7 @@ import discord
|
|||||||
from redbot.core import Config, checks, commands
|
from redbot.core import Config, checks, commands
|
||||||
from redbot.core.bot import Red
|
from redbot.core.bot import Red
|
||||||
from redbot.core.commands import Cog
|
from redbot.core.commands import Cog
|
||||||
|
from redbot.core.utils.chat_formatting import pagify
|
||||||
|
|
||||||
log = logging.getLogger("red.fox_v3.stealemoji")
|
log = logging.getLogger("red.fox_v3.stealemoji")
|
||||||
# Replaced with discord.Asset.read()
|
# Replaced with discord.Asset.read()
|
||||||
@ -69,7 +70,6 @@ class StealEmoji(Cog):
|
|||||||
"""
|
"""
|
||||||
Base command for this cog. Check help for the commands list.
|
Base command for this cog. Check help for the commands list.
|
||||||
"""
|
"""
|
||||||
if ctx.invoked_subcommand is None:
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@checks.is_owner()
|
@checks.is_owner()
|
||||||
@ -100,7 +100,8 @@ class StealEmoji(Cog):
|
|||||||
await ctx.maybe_send_embed("No stolen emojis yet")
|
await ctx.maybe_send_embed("No stolen emojis yet")
|
||||||
return
|
return
|
||||||
|
|
||||||
await ctx.maybe_send_embed(emoj)
|
for page in pagify(emoj, delims=[" "]):
|
||||||
|
await ctx.maybe_send_embed(page)
|
||||||
|
|
||||||
@checks.is_owner()
|
@checks.is_owner()
|
||||||
@stealemoji.command(name="notify")
|
@stealemoji.command(name="notify")
|
||||||
@ -268,7 +269,9 @@ class StealEmoji(Cog):
|
|||||||
break
|
break
|
||||||
|
|
||||||
if guildbank is None:
|
if guildbank is None:
|
||||||
if await self.config.autobank():
|
if not await self.config.autobank():
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
guildbank: discord.Guild = await self.bot.create_guild(
|
guildbank: discord.Guild = await self.bot.create_guild(
|
||||||
"StealEmoji Guildbank", code="S93bqTqKQ9rM"
|
"StealEmoji Guildbank", code="S93bqTqKQ9rM"
|
||||||
@ -296,9 +299,6 @@ class StealEmoji(Cog):
|
|||||||
|
|
||||||
await self.bot.send_to_owners(invite)
|
await self.bot.send_to_owners(invite)
|
||||||
log.info(f"Guild created id {guildbank.id}. Invite: {invite}")
|
log.info(f"Guild created id {guildbank.id}. Invite: {invite}")
|
||||||
else:
|
|
||||||
return
|
|
||||||
|
|
||||||
# Next, have I saved this emoji before (because uploaded emoji != orignal emoji)
|
# Next, have I saved this emoji before (because uploaded emoji != orignal emoji)
|
||||||
|
|
||||||
if str(emoji.id) in await self.config.stolemoji():
|
if str(emoji.id) in await self.config.stolemoji():
|
||||||
|
@ -37,7 +37,7 @@ class Timerole(Cog):
|
|||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.config = Config.get_conf(self, identifier=9811198108111121, force_registration=True)
|
self.config = Config.get_conf(self, identifier=9811198108111121, force_registration=True)
|
||||||
default_global = {}
|
default_global = {}
|
||||||
default_guild = {"announce": None, "reapply": True, "roles": {}}
|
default_guild = {"announce": None, "reapply": True, "roles": {}, "skipbots": True}
|
||||||
default_rolemember = {"had_role": False, "check_again_time": None}
|
default_rolemember = {"had_role": False, "check_again_time": None}
|
||||||
|
|
||||||
self.config.register_global(**default_global)
|
self.config.register_global(**default_global)
|
||||||
@ -77,7 +77,6 @@ class Timerole(Cog):
|
|||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
async def timerole(self, ctx):
|
async def timerole(self, ctx):
|
||||||
"""Adjust timerole settings"""
|
"""Adjust timerole settings"""
|
||||||
if ctx.invoked_subcommand is None:
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@timerole.command()
|
@timerole.command()
|
||||||
@ -93,6 +92,9 @@ class Timerole(Cog):
|
|||||||
await ctx.maybe_send_embed("Error: Invalid time string.")
|
await ctx.maybe_send_embed("Error: Invalid time string.")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if parsed_time is None:
|
||||||
|
return await ctx.maybe_send_embed("Error: Invalid time string.")
|
||||||
|
|
||||||
days = parsed_time.days
|
days = parsed_time.days
|
||||||
hours = parsed_time.seconds // 60 // 60
|
hours = parsed_time.seconds // 60 // 60
|
||||||
|
|
||||||
@ -152,6 +154,14 @@ class Timerole(Cog):
|
|||||||
await self.config.guild(guild).reapply.set(not current_setting)
|
await self.config.guild(guild).reapply.set(not current_setting)
|
||||||
await ctx.maybe_send_embed(f"Reapplying roles is now set to: {not current_setting}")
|
await ctx.maybe_send_embed(f"Reapplying roles is now set to: {not current_setting}")
|
||||||
|
|
||||||
|
@timerole.command()
|
||||||
|
async def skipbots(self, ctx: commands.Context):
|
||||||
|
"""Toggle skipping bots when adding/removing roles. Defaults to True"""
|
||||||
|
guild = ctx.guild
|
||||||
|
current_setting = await self.config.guild(guild).skipbots()
|
||||||
|
await self.config.guild(guild).skipbots.set(not current_setting)
|
||||||
|
await ctx.maybe_send_embed(f"Skipping bots is now set to: {not current_setting}")
|
||||||
|
|
||||||
@timerole.command()
|
@timerole.command()
|
||||||
async def delrole(self, ctx: commands.Context, role: discord.Role):
|
async def delrole(self, ctx: commands.Context, role: discord.Role):
|
||||||
"""Deletes a role from being added/removed after specified time"""
|
"""Deletes a role from being added/removed after specified time"""
|
||||||
@ -200,8 +210,9 @@ class Timerole(Cog):
|
|||||||
remove_results = ""
|
remove_results = ""
|
||||||
reapply = all_guilds[guild_id]["reapply"]
|
reapply = all_guilds[guild_id]["reapply"]
|
||||||
role_dict = all_guilds[guild_id]["roles"]
|
role_dict = all_guilds[guild_id]["roles"]
|
||||||
|
skipbots = all_guilds[guild_id]["skipbots"]
|
||||||
|
|
||||||
if not any(role_data for role_data in role_dict.values()): # No roles
|
if not any(role_dict.values()): # No roles
|
||||||
log.debug(f"No roles are configured for guild: {guild}")
|
log.debug(f"No roles are configured for guild: {guild}")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -209,6 +220,10 @@ class Timerole(Cog):
|
|||||||
# log.debug(f"{all_mr=}")
|
# log.debug(f"{all_mr=}")
|
||||||
|
|
||||||
async for member in AsyncIter(guild.members, steps=10):
|
async for member in AsyncIter(guild.members, steps=10):
|
||||||
|
|
||||||
|
if member.bot and skipbots:
|
||||||
|
continue
|
||||||
|
|
||||||
addlist = []
|
addlist = []
|
||||||
removelist = []
|
removelist = []
|
||||||
|
|
||||||
@ -232,7 +247,7 @@ class Timerole(Cog):
|
|||||||
log.debug(f"{member.display_name} - Not time to check again yet")
|
log.debug(f"{member.display_name} - Not time to check again yet")
|
||||||
continue
|
continue
|
||||||
member: discord.Member
|
member: discord.Member
|
||||||
has_roles = set(r.id for r in member.roles)
|
has_roles = {r.id for r in member.roles}
|
||||||
|
|
||||||
# Stop if they currently have or don't have the role, and mark had_role
|
# Stop if they currently have or don't have the role, and mark had_role
|
||||||
if (int(role_id) in has_roles and not role_data["remove"]) or (
|
if (int(role_id) in has_roles and not role_data["remove"]) or (
|
||||||
@ -296,9 +311,12 @@ class Timerole(Cog):
|
|||||||
log.exception("Failed Adding Roles")
|
log.exception("Failed Adding Roles")
|
||||||
add_results += f"{member.display_name} : **(Failed Adding Roles)**\n"
|
add_results += f"{member.display_name} : **(Failed Adding Roles)**\n"
|
||||||
else:
|
else:
|
||||||
add_results += " \n".join(
|
add_results += (
|
||||||
|
" \n".join(
|
||||||
f"{member.display_name} : {role.name}" for role in add_roles
|
f"{member.display_name} : {role.name}" for role in add_roles
|
||||||
)
|
)
|
||||||
|
+ "\n"
|
||||||
|
)
|
||||||
for role_id in addlist:
|
for role_id in addlist:
|
||||||
await self.config.custom(
|
await self.config.custom(
|
||||||
"RoleMember", role_id, member.id
|
"RoleMember", role_id, member.id
|
||||||
@ -311,9 +329,12 @@ class Timerole(Cog):
|
|||||||
log.exception("Failed Removing Roles")
|
log.exception("Failed Removing Roles")
|
||||||
remove_results += f"{member.display_name} : **(Failed Removing Roles)**\n"
|
remove_results += f"{member.display_name} : **(Failed Removing Roles)**\n"
|
||||||
else:
|
else:
|
||||||
remove_results += " \n".join(
|
remove_results += (
|
||||||
|
" \n".join(
|
||||||
f"{member.display_name} : {role.name}" for role in remove_roles
|
f"{member.display_name} : {role.name}" for role in remove_roles
|
||||||
)
|
)
|
||||||
|
+ "\n"
|
||||||
|
)
|
||||||
for role_id in removelist:
|
for role_id in removelist:
|
||||||
await self.config.custom(
|
await self.config.custom(
|
||||||
"RoleMember", role_id, member.id
|
"RoleMember", role_id, member.id
|
||||||
|
46
tts/tts.py
46
tts/tts.py
@ -1,11 +1,35 @@
|
|||||||
import io
|
import io
|
||||||
|
import logging
|
||||||
|
from typing import Optional, TYPE_CHECKING
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
|
from discord.ext.commands import BadArgument, Converter
|
||||||
from gtts import gTTS
|
from gtts import gTTS
|
||||||
|
from gtts.lang import _fallback_deprecated_lang, tts_langs
|
||||||
from redbot.core import Config, commands
|
from redbot.core import Config, commands
|
||||||
from redbot.core.bot import Red
|
from redbot.core.bot import Red
|
||||||
from redbot.core.commands import Cog
|
from redbot.core.commands import Cog
|
||||||
|
|
||||||
|
log = logging.getLogger("red.fox_v3.tts")
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
ISO639Converter = str
|
||||||
|
else:
|
||||||
|
|
||||||
|
class ISO639Converter(Converter):
|
||||||
|
async def convert(self, ctx, argument) -> str:
|
||||||
|
lang = _fallback_deprecated_lang(argument)
|
||||||
|
|
||||||
|
try:
|
||||||
|
langs = tts_langs()
|
||||||
|
if lang not in langs:
|
||||||
|
raise BadArgument("Language not supported: %s" % lang)
|
||||||
|
except RuntimeError as e:
|
||||||
|
log.debug(str(e), exc_info=True)
|
||||||
|
log.warning(str(e))
|
||||||
|
|
||||||
|
return lang
|
||||||
|
|
||||||
|
|
||||||
class TTS(Cog):
|
class TTS(Cog):
|
||||||
"""
|
"""
|
||||||
@ -18,7 +42,7 @@ class TTS(Cog):
|
|||||||
|
|
||||||
self.config = Config.get_conf(self, identifier=9811198108111121, force_registration=True)
|
self.config = Config.get_conf(self, identifier=9811198108111121, force_registration=True)
|
||||||
default_global = {}
|
default_global = {}
|
||||||
default_guild = {}
|
default_guild = {"language": "en"}
|
||||||
|
|
||||||
self.config.register_global(**default_global)
|
self.config.register_global(**default_global)
|
||||||
self.config.register_guild(**default_guild)
|
self.config.register_guild(**default_guild)
|
||||||
@ -27,13 +51,29 @@ class TTS(Cog):
|
|||||||
"""Nothing to delete"""
|
"""Nothing to delete"""
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@commands.mod()
|
||||||
|
@commands.command()
|
||||||
|
async def ttslang(self, ctx: commands.Context, lang: ISO639Converter):
|
||||||
|
"""
|
||||||
|
Sets the default language for TTS in this guild.
|
||||||
|
|
||||||
|
Default is `en` for English
|
||||||
|
"""
|
||||||
|
await self.config.guild(ctx.guild).language.set(lang)
|
||||||
|
await ctx.send(f"Default tts language set to {lang}")
|
||||||
|
|
||||||
@commands.command(aliases=["t2s", "text2"])
|
@commands.command(aliases=["t2s", "text2"])
|
||||||
async def tts(self, ctx: commands.Context, *, text: str):
|
async def tts(
|
||||||
|
self, ctx: commands.Context, lang: Optional[ISO639Converter] = None, *, text: str
|
||||||
|
):
|
||||||
"""
|
"""
|
||||||
Send Text to speech messages as an mp3
|
Send Text to speech messages as an mp3
|
||||||
"""
|
"""
|
||||||
|
if lang is None:
|
||||||
|
lang = await self.config.guild(ctx.guild).language()
|
||||||
|
|
||||||
mp3_fp = io.BytesIO()
|
mp3_fp = io.BytesIO()
|
||||||
tts = gTTS(text, lang="en")
|
tts = gTTS(text, lang=lang)
|
||||||
tts.write_to_fp(mp3_fp)
|
tts.write_to_fp(mp3_fp)
|
||||||
mp3_fp.seek(0)
|
mp3_fp.seek(0)
|
||||||
await ctx.send(file=discord.File(mp3_fp, "text.mp3"))
|
await ctx.send(file=discord.File(mp3_fp, "text.mp3"))
|
||||||
|
@ -19,7 +19,6 @@ class Unicode(Cog):
|
|||||||
@commands.group(name="unicode", pass_context=True)
|
@commands.group(name="unicode", pass_context=True)
|
||||||
async def unicode(self, ctx):
|
async def unicode(self, ctx):
|
||||||
"""Encode/Decode a Unicode character."""
|
"""Encode/Decode a Unicode character."""
|
||||||
if ctx.invoked_subcommand is None:
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@unicode.command()
|
@unicode.command()
|
||||||
|
@ -90,7 +90,7 @@ async def parse_code(code, game):
|
|||||||
if len(built) < digits:
|
if len(built) < digits:
|
||||||
built += c
|
built += c
|
||||||
|
|
||||||
if built == "T" or built == "W" or built == "N":
|
if built in ["T", "W", "N"]:
|
||||||
# Random Towns
|
# Random Towns
|
||||||
category = built
|
category = built
|
||||||
built = ""
|
built = ""
|
||||||
@ -116,8 +116,6 @@ async def parse_code(code, game):
|
|||||||
options = [role for role in ROLE_LIST if 10 + idx in role.category]
|
options = [role for role in ROLE_LIST if 10 + idx in role.category]
|
||||||
elif category == "N":
|
elif category == "N":
|
||||||
options = [role for role in ROLE_LIST if 20 + idx in role.category]
|
options = [role for role in ROLE_LIST if 20 + idx in role.category]
|
||||||
pass
|
|
||||||
|
|
||||||
if not options:
|
if not options:
|
||||||
raise IndexError("No Match Found")
|
raise IndexError("No Match Found")
|
||||||
|
|
||||||
@ -130,11 +128,8 @@ async def parse_code(code, game):
|
|||||||
|
|
||||||
async def encode(role_list, rand_roles):
|
async def encode(role_list, rand_roles):
|
||||||
"""Convert role list to code"""
|
"""Convert role list to code"""
|
||||||
out_code = ""
|
|
||||||
|
|
||||||
digit_sort = sorted(role for role in role_list if role < 10)
|
digit_sort = sorted(role for role in role_list if role < 10)
|
||||||
for role in digit_sort:
|
out_code = "".join(str(role) for role in digit_sort)
|
||||||
out_code += str(role)
|
|
||||||
|
|
||||||
digit_sort = sorted(role for role in role_list if 10 <= role < 100)
|
digit_sort = sorted(role for role in role_list if 10 <= role < 100)
|
||||||
if digit_sort:
|
if digit_sort:
|
||||||
|
@ -526,9 +526,10 @@ class Game:
|
|||||||
|
|
||||||
async def _notify(self, event_name, **kwargs):
|
async def _notify(self, event_name, **kwargs):
|
||||||
for i in range(1, 7): # action guide 1-6 (0 is no action)
|
for i in range(1, 7): # action guide 1-6 (0 is no action)
|
||||||
tasks = []
|
tasks = [
|
||||||
for event in self.listeners.get(event_name, {}).get(i, []):
|
asyncio.create_task(event(**kwargs))
|
||||||
tasks.append(asyncio.create_task(event(**kwargs)))
|
for event in self.listeners.get(event_name, {}).get(i, [])
|
||||||
|
]
|
||||||
|
|
||||||
# Run same-priority task simultaneously
|
# Run same-priority task simultaneously
|
||||||
await asyncio.gather(*tasks)
|
await asyncio.gather(*tasks)
|
||||||
@ -555,10 +556,7 @@ class Game:
|
|||||||
async def generate_targets(self, channel, with_roles=False):
|
async def generate_targets(self, channel, with_roles=False):
|
||||||
embed = discord.Embed(title="Remaining Players", description="[ID] - [Name]")
|
embed = discord.Embed(title="Remaining Players", description="[ID] - [Name]")
|
||||||
for i, player in enumerate(self.players):
|
for i, player in enumerate(self.players):
|
||||||
if player.alive:
|
status = "" if player.alive else "*[Dead]*-"
|
||||||
status = ""
|
|
||||||
else:
|
|
||||||
status = "*[Dead]*-"
|
|
||||||
if with_roles or not player.alive:
|
if with_roles or not player.alive:
|
||||||
embed.add_field(
|
embed.add_field(
|
||||||
name=f"{i} - {status}{player.member.display_name}",
|
name=f"{i} - {status}{player.member.display_name}",
|
||||||
@ -579,7 +577,7 @@ class Game:
|
|||||||
if channel_id not in self.p_channels:
|
if channel_id not in self.p_channels:
|
||||||
self.p_channels[channel_id] = self.default_secret_channel.copy()
|
self.p_channels[channel_id] = self.default_secret_channel.copy()
|
||||||
|
|
||||||
for x in range(10): # Retry 10 times
|
for _ in range(10): # Retry 10 times
|
||||||
try:
|
try:
|
||||||
await asyncio.sleep(1) # This will have multiple calls
|
await asyncio.sleep(1) # This will have multiple calls
|
||||||
self.p_channels[channel_id]["players"].append(role.player)
|
self.p_channels[channel_id]["players"].append(role.player)
|
||||||
@ -706,9 +704,7 @@ class Game:
|
|||||||
if not self.any_votes_remaining:
|
if not self.any_votes_remaining:
|
||||||
await channel.send("Voting is not allowed right now")
|
await channel.send("Voting is not allowed right now")
|
||||||
return
|
return
|
||||||
elif channel.name in self.p_channels:
|
elif channel.name not in self.p_channels:
|
||||||
pass
|
|
||||||
else:
|
|
||||||
# Not part of the game
|
# Not part of the game
|
||||||
await channel.send("Cannot vote in this channel")
|
await channel.send("Cannot vote in this channel")
|
||||||
return
|
return
|
||||||
@ -757,14 +753,14 @@ class Game:
|
|||||||
await self._at_voted(target)
|
await self._at_voted(target)
|
||||||
|
|
||||||
async def eval_results(self, target, source=None, method=None):
|
async def eval_results(self, target, source=None, method=None):
|
||||||
if method is not None:
|
if method is None:
|
||||||
out = "**{ID}** - " + method
|
|
||||||
return out.format(ID=target.id, target=target.member.display_name)
|
|
||||||
else:
|
|
||||||
return "**{ID}** - {target} the {role} was found dead".format(
|
return "**{ID}** - {target} the {role} was found dead".format(
|
||||||
ID=target.id, target=target.member.display_name, role=await target.role.get_role()
|
ID=target.id, target=target.member.display_name, role=await target.role.get_role()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
out = "**{ID}** - " + method
|
||||||
|
return out.format(ID=target.id, target=target.member.display_name)
|
||||||
|
|
||||||
async def _quit(self, player):
|
async def _quit(self, player):
|
||||||
"""
|
"""
|
||||||
Have player quit the game
|
Have player quit the game
|
||||||
|
@ -75,7 +75,6 @@ class Werewolf(Cog):
|
|||||||
"""
|
"""
|
||||||
Base command to adjust settings. Check help for command list.
|
Base command to adjust settings. Check help for command list.
|
||||||
"""
|
"""
|
||||||
if ctx.invoked_subcommand is None:
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
@ -166,7 +165,6 @@ class Werewolf(Cog):
|
|||||||
"""
|
"""
|
||||||
Base command for this cog. Check help for the commands list.
|
Base command for this cog. Check help for the commands list.
|
||||||
"""
|
"""
|
||||||
if ctx.invoked_subcommand is None:
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
@ -348,7 +346,6 @@ class Werewolf(Cog):
|
|||||||
"""
|
"""
|
||||||
Find custom roles by name, alignment, category, or ID
|
Find custom roles by name, alignment, category, or ID
|
||||||
"""
|
"""
|
||||||
if ctx.invoked_subcommand is None or ctx.invoked_subcommand == self.ww_search:
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ww_search.command(name="name")
|
@ww_search.command(name="name")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user