Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #7

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"python.pythonPath": "venv/bin/python",
"python.formatting.provider": "black"
}
2 changes: 1 addition & 1 deletion doomer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
A friendly discord bot for chatting.
"""

__version__ = "0.1.0"
__version__ = "0.1.0"
27 changes: 15 additions & 12 deletions doomer/cogs/doomercog.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class DoomerCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.settings = {
"auto_reply_rate": 100,
"auto_reply_rate": 1,
"auto_react_rate": 0,
"auto_reply_messages": 10,
"channel_settings": {
Expand All @@ -52,24 +52,23 @@ def __init__(self, bot):

def build_display_settings(self, ctx):
display_settings = self.settings.copy()
new_channel_settings = {}
for setting, values in display_settings["channel_settings"].items():
new_channel_settings[setting] = {}
for channel_id, value in values.items():
channel = utils.get(ctx.guild.text_channels, id=channel_id)
if channel:
new_channel_settings[setting][channel.name] = value
display_settings["channel_settings"] = new_channel_settings

# Looks up channel names from ids
display_settings["channel_settings"] = {
setting: {
utils.get(ctx.guild.text_channels, id=channel).name: value
if utils.get(ctx.guild.text_channels, id=channel) is not None
else "Unknown channel"
for channel, value in values.items()
}
for setting, values in display_settings["channel_settings"].items()
}
return display_settings

def sanitize_output(self, text):
return re.sub(r"[\s^]>", "\n>", fix_emoji(text))

async def complete_text(self, prompt, max_tokens, stop=None):
loop = asyncio.get_running_loop()
print(prompt)
completion = await loop.run_in_executor(
None,
partial(
Expand Down Expand Up @@ -193,7 +192,7 @@ async def reply(self, message, force=False):
)
)
banter = await self.complete_text(
messages + "\n**[" + self.bot.user.name + "]**:", 300, stop=["**["]
messages + "\n**[" + self.bot.user.name + "]**: ", 300, stop=["**["]
)
await message.channel.send(banter)

Expand Down Expand Up @@ -234,6 +233,7 @@ async def update_settings(self, ctx, setting, value):
valid_settings = self.settings.keys()
if setting in valid_settings:
self.settings[setting] = int(value)
self.save_settings()
await ctx.send(f"Setting {setting} set to value {value}")
else:
await ctx.send(f"Setting {setting} is not valid.")
Expand All @@ -252,6 +252,7 @@ async def update_channel_settings(self, ctx, setting, channel_name, value):
filter(lambda x: x.name == channel_name, ctx.guild.text_channels)
)
channel_settings[setting][int(channel.id)] = int(value)
self.save_settings()
await ctx.send(
f"Setting {setting} set to value {value} for channel {channel_name}"
)
Expand All @@ -274,6 +275,7 @@ async def update_model_settings(self, ctx, setting, value, model_name=None):
if value.isnumeric():
value = int(value)
model.settings[setting] = value
self.save_settings()
await ctx.send(f"Setting model {model_name} setting {setting} to {value}")
else:
await ctx.send(f"Model {model_name} does not have setting {setting}")
Expand All @@ -285,6 +287,7 @@ async def set_default_model(self, ctx, model_name):
if model_name in available_models:
self.default_model = self.bot.models[model_name]
self.settings["default_model_name"] = model_name
self.save_settings()
await ctx.send(f"Default model changed to {model_name}")
else:
await ctx.send(
Expand Down
43 changes: 0 additions & 43 deletions doomer/cogs/utilitycog.py

This file was deleted.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ requires = [
"requests",
"cogwatch",
"transformers[torch]",
"pandas",
"discord.py",
"python-dotenv"
]
Expand Down