- C 85.2%
- Makefile 11.3%
- Dockerfile 3.5%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .forgejo | ||
| src | ||
| .gitignore | ||
| Dockerfile | ||
| makefile | ||
| README.md | ||
discord-announcements-publisher
Discord announcements publisher is a small discord bot that automatically crosspost messages from announcements channels in Discord. It is written in C and can be used with a container
Limitations
Since discord forces a limitation of 10 crossposts per hour per channel, the bot will not check for errors and will not try to crosspost them if there are problems
If you enable reactions at compile time (which are enabled by default), reaching the limitation might trigger an assertion error from concord itself To disable the reactions, you can compile it with a flag set to 0 :
make cleanbuild SKIP_REACTIONS=1. The container is compiled with this flag set to0, resulting in the activation of reactions You can tweak the container yourself to disable this flag. If you are interested in a more automatic way to disable this in the container, contact me
Installation
From source
Get the code : git clone https://git.greensky.tf/Greensky/discord-announcements-publisher.git && cd discord-announcements-publisher
Prerequisiteries
You need to have the Concord library, since it is written in C and is required
Here are the steps to install it :
git clone https://git.greensky.tf/Miroir/concord.git && cd concord(or from the original source (mine is a mirror, it is the same ) :git clone https://github.com/cogmasters/concord && cd concord)makesudo make install
If you need to remove concord, run :
sudo rm -rf /usr/local/include/concord /usr/local/lib/libdiscord.a
Setup
Then you need to setup a config.json file. Here is an example :
{
"logging": {
"level": "trace",
"filename": "bot.log",
"quiet": false,
"overwrite": true,
"use_color": true,
"http": {
"enable": true,
"filename": "http.log"
},
"disable_modules": ["WEBSOCKETS", "USER_AGENT"]
},
"discord": {
"token": "YOUR-BOT-TOKEN",
"default_prefix": {
"enable": false,
"prefix": "YOUR-COMMANDS-PREFIX"
}
}
}
Example from https://git.greensky.tf/Miroir/concord/src/commit/fb0f834d07d65048a6afde177e318fe9659a9494/config.json (I took it from my mirror because forgejo exposes a "Permalink" button to get a permanent url to the said file)
Put it in the same folder as the repository
Environment
The bot relies on a GUILD_ID env variable to target the correct server. Find the one you need, then set it up in your environment :
GUILD_ID="GUILD ID"
Or you can just give it for the launch command : GUILD_ID="..." the..rest..of..the..command..explained..below
Compiling
You can compile the code by running : make cleanbuild
Here is a table of compile flags of the makefile
| Name | Type | Usage | Default |
|---|---|---|---|
SKIP_REACTIONS |
integer | When set to 1, the section about reacting to crossposted message will be removed | 0 |
IFDEBUG |
integer | When defined (set in arguments list), the random debug messages I left will be enabled. Disabled, less CPU time is used to compute current time and display it to stdout | N/A |
Launching
Launch it by running ./bin/main.uwu (the default file).
Container
You still need a
config.jsonfile
You can make the use of a docker-compose.yaml file, such as :
services:
watchbot:
image: git.greensky.tf/greensky/discord-announcements-publisher:latest
container_name: Watchbot
environment:
- GUILD_ID=GUILD_ID_HERE
restart: always
volumes:
- /absolute/path/to/config.json-file:/var/discord
Then start it up : docker compose up -d and you're set
Contact
You can join the discord server, or send me an email
Credits
If you are wondering, the profile picture of the bot has been found here https://pixabay.com/illustrations/chinese-painting-ink-wash-painting-10006608/