A cli bot to send simple messages to a Discord channel.
Project description
A simple python Discord bot to send messages to Discord channel via command line.
It allows markdown formatted messages and attaching files.
It registers the following commands:
dbot-run - main CLI entry-point
dbot-message - (short-hand) to send a message, or even pipe - message contents
dbot-file - (short-hand) to send a file with an message
dbot-info - (short-hand) to send a message with system information (extra dependencies have to be installed!)
Requirements
Python >= 3.6 (see badges above)
Extra:
Installation
python3 -m pip install discord-notifier-bot
Optionally, install it locally with --user.
For system info messages using dbot-info or dbot-run info [...], you have to install extra dependencies. You can choose between cpu (cpu + disk information) and gpu (nvidia-smi information):
python3 -m pip install discord-notifier-bot[cpu,gpu]
Configuration
Configuration is done by placing a .dbot.conf file in one of the following directories:
$HOME/.dbot.conf
$HOME/dbot.conf
./.dbot.conf
./dbot.conf
/etc/dbot.conf
Alternatively a configuration file can be provided via -c/--config CLI options.
The configuration file should be a standard INI file. A template can be found in the templates folder. All configurations are placed under the discord-bot section.
Example:
[discord-bot]
# the bot token (used for login)
token = abc
# the numeric id of a channel, can be found when activating the developer options in appearances
channel = 123
Usage
dbot-message and dbot-file are simpler versions of dbot-run.
Print help and available options:
dbot-run -h
Sending messages:
# send a simple message
dbot-run message "Test message"
# or shorter:
dbot-message "Test **message**"
# pipe output
echo "Test" | dbot-emessage -
# wrap it inside a code-block ```
# optionally with a type
cat `which dbot-message` | dbot-message - --type
cat `which dbot-message` | dbot-message - --type python
Sending a file:
dbot-file README.rst "Your message to desribe the attached file"
# or with no visible message:
dbot-file README.rst ""
# optionally also like this:
dbot-run file -f README.rst "Message ..."
You are always able to specify the configuration file like this:
dbot-run -c /path/to/dbot.conf [...]
dbot-{message,file} -c /path/to/dbot.conf [...]
Only with dbot-run: To display debugging information (api calls, log messages etc.):
dbot-run -v [...]
You may also run the bot with the python module notation. But it will only run the same entry-point like dbot-run.
python -m discord_notifier_bot [...]
Bot Creation etc.
See information provided by:
Short description
You have to own a Discord server! Or know someone with administrator/moderation(?) privileges.
Visit and login to the Discord developer page.
Create a new application. The given name is also the visible name of the bot. (default, can be changed later?)
Create a bot (on the Bot page). You should disable the Public Bot option.
The bot login token (credentials) can be found on the Bot page.
Change to the OAuth2 page and check
Scopes: Bot
Bot Permissions: Send Messages, Attach Files (in the Text Permissions column)
Copy the URL in the Scopes section and paste it in a new browser tab.
Now you can choose one (?) of your own Discord servers to add the bot to. (For this you need server administration permissions, or be the owner..?)
To get the channel id, send the following message on your server \#channelname, or enable developer options. You may want to visit the following pages for more information:
Credits
Copyright and License Information
Copyright (c) 2020 Erik Körner. All rights reserved.
See the file “LICENSE” for information on the history of this software, terms & conditions for usage, and a DISCLAIMER OF ALL WARRANTIES.
All trademarks referenced herein are property of their respective holders.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for discord-notifier-bot-0.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | bde533d366c5d5713e6b1bf5ed7727097d40391b1b4623cd8b12c746c5c8df37 |
|
MD5 | 15b3f24166c11d41da3f69119af1a02a |
|
BLAKE2b-256 | 9b589c9d0acbe94aa8a28a1f7e43e6c3a9f28f2bf8d6b23e3a5b20baabc6c2c9 |
Hashes for discord_notifier_bot-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6d24dba8a2473e62493493d86bd836eeb25c0ee3f8da594ac906c0d4541e4d8 |
|
MD5 | 2c2343fa002882f71d51b663e13aff2e |
|
BLAKE2b-256 | 6443805e7ced42a64f4b7bf6b9a740d372dbfed819c88bca4fa2de725c1a3e2c |