dcom (discord community bot) is a (python3.6+) bot for communities to trigger upvotes from specified discord channels/servers. - announcement post

dcom has been in use for curation commands in @sndbox discord server in the last two weeks and it's working well.
Registration module
The next step was building a registration module to map discord IDs with STEEM usernames. The expected requirements were:
- Step 1: User can register themselves by sending #registration channel the following command:
$register <steem_username>
.- - Step 2: Bot responds with a unique token and asks for user to send 0.001 STEEM or 0.001 SBD to the designated steem account. (Ex: @sndbox-register.)
- Step 3: Bot starts to listen incoming transaction of the designated STEEM account. When it finds a suitable transfer including the correct memo, bot marks the user as verified.
- Step 4: Bot should return the 0.001 SBD or 0.001 STEEM to the sender.
- Step 5: If the user is verified successfully, bot adds "registered" role to the user in the Discord server.

The challenge
In order to listen STEEM transfers in the background, I need to implement a background task runs forever checking incoming transfers.
I was worried to hack stuff to do that before diving into discord.py library, but it looks like it already support background tasks.
Basically, you can attach a background task to the main asyncio loop just by:
client.loop.create_task(my_background_task())
After that, all you need to do is polling the account history via lightsteem.

There are a couple of optimization touches already implemented. Ex: If there are no waiting veritification codes in the last 60 minutes, bot doesn't poll the account history.
Updating the bot
$ pip install dcom --upgrade
New configuration parameters
A .dcom_env file at your user path should store the below fields:
Key | Value |
---|---|
BOT_ACCOUNT | The account used for the curation |
BOT_POSTING_KEY | Private posting key of the curation account |
STEEM_NODES | A list of STEEM nodes (comma separated) |
DISCORD_BOT_TOKEN | <Token of the discord bot> |
CHANNEL_WHITELIST | Curation channel id list (comma separated) |
LATE_CURATION_WINDOW | Maximum age for a post (in seconds) |
EARLY_CURATION_WINDOW | Minimum age for a post (in seconds) |
CURATOR_GROUPS | Discord roles authorized to use the bot (comma separated) |
REGISTRATION_CHANNEL | Registration channel (ID) |
REGISTRATION_ACCOUNT | Registration account (steem username) |
REGISTRATION_ACCOUNT_ACTIVE_KEY | Registration account's active key |
ROLE_FOR_REGISTERED_USERS | Role name for registered users |
MONGO_URI | Mongodb connection URI |
COMMUNITY_NAME | Community name |
(New parameters with this version is marked as bold.)
Running
$ dcom
To make sure the bot runs all the time, you can use supervisor or other process management software.
For the reference, here is my config for the supervisor:
[program:dcom]
command=/home/user/dcom-env/bin/dcom
autostart=true
autorestart=true
redirect_stderr=true
redirect_stdout=true
Roadmap
- Automatic curation support with donatebot "patrons".