Compare commits
7 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 37a6ba07e8 | |||
| ca2b2c45a4 | |||
| 084502ef08 | |||
| 8fcc250041 | |||
| 424078deff | |||
| 6c01c68429 | |||
| 747d17d8d3 |
8 changed files with 78 additions and 16 deletions
50
README.md
50
README.md
|
|
@ -26,3 +26,53 @@ To run the bot simply execute ``main.py``:
|
||||||
```sh
|
```sh
|
||||||
./main.py
|
./main.py
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Commands
|
||||||
|
### Basic
|
||||||
|
#### `/sayhello`
|
||||||
|
Prints ``Hello world!``
|
||||||
|
|
||||||
|
#### `/ping`
|
||||||
|
Shows the bot's latency.
|
||||||
|
|
||||||
|
### Messages
|
||||||
|
#### `/set_forward_channel <#channel>`
|
||||||
|
Sets channel to forward messages to.
|
||||||
|
|
||||||
|
#### `>forward`
|
||||||
|
Forwards message to set channel
|
||||||
|
|
||||||
|
### Roles
|
||||||
|
#### `/secretroles`
|
||||||
|
Manages roles locked behind a password.
|
||||||
|
|
||||||
|
Lock ``@role`` behind a password ``supersecret``:
|
||||||
|
```
|
||||||
|
/secretroles add @role supersecret
|
||||||
|
```
|
||||||
|
|
||||||
|
Delete password ``supersecret``, so role is no longer obtainable with it:
|
||||||
|
```
|
||||||
|
/secretroles delete supersecret
|
||||||
|
```
|
||||||
|
|
||||||
|
List all current passwords and their roles:
|
||||||
|
```
|
||||||
|
/secretroles list
|
||||||
|
```
|
||||||
|
|
||||||
|
### KSP
|
||||||
|
Ksp related commands
|
||||||
|
|
||||||
|
#### `/task`
|
||||||
|
Generates urls for given task.
|
||||||
|
|
||||||
|
#### `/deadlines`
|
||||||
|
Shows deadlines of currently running series.
|
||||||
|
|
||||||
|
### News
|
||||||
|
#### `/news set_channel <#channel>`
|
||||||
|
Set channel for posting news.
|
||||||
|
|
||||||
|
#### `/news post_news <id>`
|
||||||
|
Post news with given `id` to set channel.
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,7 @@ CONFIG = data.load_json(os.path.join(CONFIG_FOLDER, "config"))
|
||||||
|
|
||||||
bot = commands.Bot()
|
bot = commands.Bot()
|
||||||
|
|
||||||
cogs_list = [
|
cogs_list = CONFIG["enabled_cogs"]
|
||||||
'basic',
|
|
||||||
'roles',
|
|
||||||
'messages',
|
|
||||||
'ksp',
|
|
||||||
'news',
|
|
||||||
]
|
|
||||||
|
|
||||||
for cog in cogs_list:
|
for cog in cogs_list:
|
||||||
bot.load_extension(f'hrochobot.cogs.{cog}')
|
bot.load_extension(f'hrochobot.cogs.{cog}')
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,12 @@
|
||||||
progress "Installing Hrochobot"
|
progress "Installing Hrochobot"
|
||||||
|
|
||||||
|
echo "Creating virtual environment"
|
||||||
|
|
||||||
|
install-pkgs python3-venv
|
||||||
|
|
||||||
|
python3 -m venv /srv/hrochobot
|
||||||
|
. /srv/hrochobot/bin/activate
|
||||||
|
|
||||||
|
echo "Installing package"
|
||||||
cd /build/src
|
cd /build/src
|
||||||
pip install .
|
pip install .
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,12 @@ After=network.target
|
||||||
[Service]
|
[Service]
|
||||||
Type=exec
|
Type=exec
|
||||||
ExecStartPre=mkdir -p /data/hrochobot
|
ExecStartPre=mkdir -p /data/hrochobot
|
||||||
ExecStart=/usr/local/bin/hrochobot
|
ExecStart=/srv/hrochobot/bin/hrochobot
|
||||||
Environment=HROCHOBOT_DATA=/data/hrochobot
|
Environment=HROCHOBOT_DATA=/data/hrochobot
|
||||||
Environment=HROCHOBOT_ETC=/data/hrochobot
|
Environment=HROCHOBOT_ETC=/data/hrochobot
|
||||||
Environment=HROCHOBOT_LOG=/data/log
|
Environment=HROCHOBOT_LOG=/data/log
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=5min
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
FROM docker://registry.ks.matfyz.cz/gimli/base:bullseye
|
FROM docker://registry.ks.matfyz.cz/gimli/base:bookworm
|
||||||
COPY bin /build/src/bin
|
COPY bin /build/src/bin
|
||||||
COPY hrochobot /build/src/hrochobot
|
COPY hrochobot /build/src/hrochobot
|
||||||
COPY setup.py /build/src
|
COPY setup.py /build/src
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,10 @@
|
||||||
{
|
{
|
||||||
"token": "Paste your token here."
|
"token": "Paste your token here.",
|
||||||
}
|
"enabled_cogs": [
|
||||||
|
"basic",
|
||||||
|
"roles",
|
||||||
|
"messages",
|
||||||
|
"ksp",
|
||||||
|
"news"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ class Messages(commands.Cog):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
@discord.message_command()
|
@discord.message_command()
|
||||||
async def forward(self, ctx: discord.Interaction, message: discord.Message):
|
async def forward(self, ctx, message: discord.Message):
|
||||||
messages_json = data.load_guild_data(ctx.guild.id, MESSAGES_JSON)
|
messages_json = data.load_guild_data(ctx.guild.id, MESSAGES_JSON)
|
||||||
if "forward_channel" not in messages_json:
|
if "forward_channel" not in messages_json:
|
||||||
return await ctx.respond(f"Forwarding channel not set.", ephemeral=True)
|
return await ctx.respond(f"Forwarding channel not set.", ephemeral=True)
|
||||||
|
|
@ -26,7 +26,7 @@ class Messages(commands.Cog):
|
||||||
@discord.slash_command(description="Sets channel for forwarding.")
|
@discord.slash_command(description="Sets channel for forwarding.")
|
||||||
@discord.option("channel", discord.TextChannel, description="Channel for forwarding.")
|
@discord.option("channel", discord.TextChannel, description="Channel for forwarding.")
|
||||||
@discord.default_permissions(administrator=True)
|
@discord.default_permissions(administrator=True)
|
||||||
async def set_forward_channel(self, ctx: discord.Interaction, channel: discord.TextChannel):
|
async def set_forward_channel(self, ctx, channel: discord.TextChannel):
|
||||||
messages_json = data.load_guild_data(ctx.guild.id, MESSAGES_JSON)
|
messages_json = data.load_guild_data(ctx.guild.id, MESSAGES_JSON)
|
||||||
messages_json["forward_channel"] = channel.id
|
messages_json["forward_channel"] = channel.id
|
||||||
data.dump_guild_data(ctx.guild.id, MESSAGES_JSON, messages_json)
|
data.dump_guild_data(ctx.guild.id, MESSAGES_JSON, messages_json)
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ class News(commands.Cog):
|
||||||
checks=[commands.has_permissions(manage_guild=True)]
|
checks=[commands.has_permissions(manage_guild=True)]
|
||||||
)
|
)
|
||||||
|
|
||||||
@news.command(description="Adds a new secret role.")
|
@news.command(description="Sets channel for posting news.")
|
||||||
@discord.option("channel_id", str, description="Id of the channel for sending news.")
|
@discord.option("channel_id", str, description="Id of the channel for sending news.")
|
||||||
async def set_channel(self, ctx, channel_id: str):
|
async def set_channel(self, ctx, channel_id: str):
|
||||||
try:
|
try:
|
||||||
|
|
@ -104,13 +104,14 @@ class News(commands.Cog):
|
||||||
data.dump_guild_data(ctx.guild.id, NEWS_JSON, news_json)
|
data.dump_guild_data(ctx.guild.id, NEWS_JSON, news_json)
|
||||||
return await ctx.respond(f"News channel set to {channel.mention}.", ephemeral=True)
|
return await ctx.respond(f"News channel set to {channel.mention}.", ephemeral=True)
|
||||||
|
|
||||||
@news.command(description="Synchronize news feed.")
|
@news.command(description="Posts news of given id to set channel.")
|
||||||
@discord.option("id", str, description="Id of entry to send.", autocomplete=autocomplete_news_ids)
|
@discord.option("id", str, description="Id of entry to send.", autocomplete=autocomplete_news_ids)
|
||||||
async def post_news(self, ctx, id: int):
|
async def post_news(self, ctx, id: int):
|
||||||
|
await ctx.defer(ephemeral=True)
|
||||||
err = await post_news(self.bot, ctx.guild, id)
|
err = await post_news(self.bot, ctx.guild, id)
|
||||||
if err:
|
if err:
|
||||||
return await ctx.respond(err, ephemeral=True)
|
return await ctx.respond(err, ephemeral=True)
|
||||||
return await ctx.respond(f"News posted.", ephemeral=True)
|
return await ctx.respond(f"News posted.")
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue