- Configure
.env
file with Redmine and Discord settings- Generate the Discord token
- Generate the Redmine token
- Deploy
netbot
container withdocker compose
- Confirm operation with
docker logs
To start, you will need the URL of the Redmine server you're integrating with, and admin access to that redmine instance.
- To deploy the latest:
git pull; docker compose up --build -d
- To shudown netbot:
docker cmopose down
- To check for errors in the logs:
docker logs netbot | grep ERROR
To mangage authorization, security tokens and other credentials are stored in a local .env
file and read by the code. The following credentials are needed for netbot.sh
:
REDMINE_TOKEN
: Secure Redmine API tokenREDMINE_URL
: URL of Redmine serviceDISCORD_TOKEN
: Secure Discord API token, see Discord Token below
These values will be loaded from a .env
file in the same directory as netbot.py
and compose.yaml
.
To set the values, create (or append to) a .env
file with valid entries for the IMAP configuration:
REDMINE_TOKEN=123-TOKEN-456
REDMINE_URL=http://localhost
DISCORD_TOKEN=ABC-ANOTHER-TOKEN-DEF
Once the .env
file has been created, the container can be started
netbot
uses standard Docker compose:
To run netbot
using a standard container system:
cd netbox
git pull
sudo docker compose up --build -d
to stop:
sudo docker compose down
The SCN email threader collects new IMAP email messages to publish to Redmine as tickets. The functionality is implemented in threader.py
, is designed to run periodically as a cron job.
To enable netbot on your Discord server, you need to generate a valid DISCORD_TOKEN
and then invite the bot to your Discord instance.
- Go to https://discord.com/developers/applications and login.
- Create a New Application (top-right button).
- Fill in the Name and click the Terms of Service.
- Add a Description on the General Information page and save changes.
- In the OAuth2/URL Generator section, generate a URL for a bot with Administrator permissions.
- That URL will look something like: https://discord.com/api/oauth2/authorize?client_id=[client-id]&permissions=8&scope=bot
- Open a browser with that URL and login.
- You'll be presented with a window to add your bot to any server you have admin permissions for.
- Select your server and click OK.
- Back in the bot setup, in the "Bot" section, under "Build-A-Bot", Copy the Token. This is the DISCORD_TOKEN
- On the same page, a little lower, unset the Public Bot switch.
- Under "Privlidged Gateway Intents", enable "Message Content Intent".
- Create an
.env
file in thenetbot
directory containing:DISCORD_TOKEN=your-token-contents
Note: Not all admin permissions are needed. If you want a very targeted bot, select:
- Manage Server
- Manage Roles
- Manage Channels
- Manage Expressions
- Read Messages/View Channels
- Send Messages
- Create Pubilc Threads
- Create Private Threads
- Send Messages in Threads
- Manage Messages
- Manage Threads
- Embed Links
- Attach Files
- Read Message History
- Use Slash Commands
TODO: create admin user as part of Redmine deployment. Not yet implemented.
Each Redmine API token is associated with a specific user, so an specific "admin" user is created for bot API access.
If the admin
user already exists and Administrator privlidges, skip this step.
An existing Redmine administrator must log into the Redmine instance to access REDMINE_URL/user to create a new user:
- Login to Redmine via REDMINE_URL
- Click + New User (top right)
- Enter the follow values. Everything else can be left as is.
- Login:
admin
- First name:
Admin
- Last name:
-
- Email:
[email protected]
- Administrator: (check the box)
- Authentication mode: Internal
- Password: (generate a new secure password)
- Confirmation: (same new password)
- Login:
- Click Create
Once the admin
user has been created:
- Login as the admin user with the new password
- Click on "My Account" (top right, REDMINE_URL/my/account)
- In the right-hand column, look for API access key
- Click the related Show button
- Copy the revealed token to the
.env
file asREDMINE_TOKEN
As a container, the logs from netbot
are avilabel using the stantard Docker logging facilities. To view netbot logs, use:
docker logs netbot
To search for specific keyword 'xyz', combine that with grep
:
docker logs netbot | grep xyz
To display the netbot logs to the console as they occur, the Unix tail
command is handy:
docker logs netbot | tail -f