Skip to content
Open
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
15 changes: 4 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,16 @@ Share opinions, laugh together, and level up your server with a bot that can tal
- `#!search` - Searches for stuff on the web using DuckDuckGo and provides a Rob-certified™ summary.

# Development setup
1. Install Obun
```bash
git clone https://github.com/Dogo6647/obun.git
cd obun
./install.sh
```

2. Clone this repo and install requirements
1. Clone this repo and install requirements
```bash
git clone https://github.com/Dogo6647/rob.git
cd rob
pip install -r requirements.txt
```

3. Edit .env.example with your preferred text editor and rename it to .env
2. Edit .env.example with your preferred text editor and rename it to .env

4. Run the bot
3. Run the bot
```
obun -w
python3 src/main.py
```
123 changes: 0 additions & 123 deletions index.obun

This file was deleted.

38 changes: 0 additions & 38 deletions src/broadcast.obun.py

This file was deleted.

27 changes: 0 additions & 27 deletions src/channeldetect.obun.py

This file was deleted.

94 changes: 94 additions & 0 deletions src/cogs/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import re
from discord import app_commands
from discord.ext import commands
from core.client import Rob
from util.config import has_rob_admin, save_config
from typing import Optional

@commands.check(has_rob_admin)
@commands.guild_only()
class ConfigCog(commands.Cog):
def __init__(self, bot: Rob):
super().__init__()
self.bot = bot

@commands.hybrid_command(
name="option",
description="Change Rob's settings to your liking."
)
@app_commands.describe(
option="ID of the option to change.",
value="Value to assign, leave empty to view the current value."
)
async def option(self, ctx: commands.Context, option: str, value: Optional[str]):
assert ctx.guild
if not value:
return await ctx.send(f"its `{self.bot.config[option]}`")
elif not option:
return await ctx.send("#!option <optionId> <value>\nthats how you do it btw ;3", ephemeral=True)

if option in self.bot.config:
if not option == "model" and not option == "mailChannel" and not option == "mailTrusted":
if value.lower() in ["enable", "disable"]:
self.bot.config[option] = value.lower() == "enable"
else:
try:
self.bot.config[option] = int(value)
except ValueError:
await ctx.send("no not like that :X\nuse `enable`, `disable`, or a number", ephemeral=True)
return
elif option == "mailChannel":
match = re.match(r"<#(\d+)>", value)

if match:
self.bot.config[option] = int(match.group(1))
elif value.isdigit():
self.bot.config[option] = int(value)
else:
await ctx.send("give me a channel mention or channel id", ephemeral=True)
return
elif option == "mailTrusted" or option == "model":
await ctx.send("you cannot change that part of my config with #!option :X", ephemeral=True)
return
else:
config[option] = value
save_config(ctx.guild.id, self.bot.config)
await ctx.send(f"alr, `{option}` is now `{value}` :)")
else:
await ctx.send(f"umm idk what a `{option}` is :/", ephemeral=True)
return

@commands.hybrid_command(
name="trust",
description="Trusts another server's address, allowing them to send you letters."
)
@app_commands.describe(address="Mail address of the server to trust.")
async def trust(self, ctx: commands.Context, address: str):
if not address:
await ctx.send("its like #!trust <address>", ephemeral=True)
return

if address not in self.bot.config["mailTrusted"]:
self.bot.config["mailTrusted"].append(address)
save_config(ctx.guild.id, self.bot.config)

return await ctx.send(f"trusted `{address}` :)")

@commands.hybrid_command(
name="untrust",
description="Stops trusting another server's address, blocking them from sending you letters."
)
@app_commands.describe(address="Mail address of the server to untrust.")
async def untrust(self, ctx: commands.Context, address: str):
if not address:
await ctx.send("its like #!untrust <address>", ephemeral=True)
return

if address in self.bot.config["mailTrusted"]:
self.bot.config["mailTrusted"].remove(address)
save_config(ctx.guild.id, self.bot.config)

return await ctx.send(f"bleh, untrusted `{address}` -_-")

async def setup(bot: Rob):
return await bot.add_cog(ConfigCog(bot))
36 changes: 36 additions & 0 deletions src/cogs/dev.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import io
from discord.ext import commands
from core.client import Rob
from contextlib import redirect_stdout

@commands.is_owner()
class DevCog(commands.Cog):
def __init__(self, bot: Rob):
super().__init__()
self.bot = bot

@commands.command(name="eval", description="Evaluates Python code.")
async def eval(self, ctx: commands.Context, *, code: str):
print(f":: [SECURITY WARNING] - executing eval '{code}'.")
buffer = io.StringIO()

try:
with redirect_stdout(buffer):
exec(code)

output = buffer.getvalue() or "(no output)"
await ctx.channel.send(f"```\n{output}\n```")
except Exception as e:
await ctx.channel.send(f"```\n{type(e).__name__}: {e}\n```")
return

@commands.command(name="reload", description="Reloads a loaded cog.")
async def reload(self, ctx: commands.Context, cog: str):
try:
await self.bot.reload_extension(f"cogs.{cog}")
return await ctx.reply(f":: Cog {cog} loaded successfully")
except Exception as e:
return await ctx.reply(f":: Cog {cog} failed to load: {e}")

async def setup(bot: Rob):
return await bot.add_cog(DevCog(bot))
Loading