dcom (discord community bot) updates: Registration module
dcom (discord community bot) is a (python3.6+) bot for communities to trigger upvotes from specified discord channels/servers. - announcement post
![](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmYT3svFg4mQczC83uTQ7QMvLVLZMT63kfRBV3utZnGgLJ/Screen%20Shot%202018-12-17%20at%209.50.29%20AM.png)
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.
![](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmYWA423UJMA3N6htVTidcjMdJsMy2xBYmcyezXUuu4ZZM/Screen%20Shot%202018-12-17%20at%209.40.43%20AM.png)
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.
![](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmSMS2QiM2964xpWEjC9He8UjvR8YykWiNx4NrRtfvGoLW/Screen%20Shot%202018-12-17%20at%209.55.37%20AM.png)
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".
Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.
To view those questions and the relevant answers related to your post, click here.
Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]
Thank you for your review, @helo! Keep up the good work!
Okay Cool job <3
Posted using Partiko Android
Wow, great job. Really cool project
Posted using Partiko Android
Thank you so much for participating the Partiko Delegation Plan Round 1! We really appreciate your support! As part of the delegation benefits, we just gave you a 3.00% upvote! Together, let’s change the world!
Hi @emrebeyler!
Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server
Hey, @emrebeyler!
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!
Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).
Want to chat? Join us on Discord https://discord.gg/h52nFrV.
Vote for Utopian Witness!
Birthdaypost !BEER
_
View or trade
BEER
.Hey @emrebeyler, here is a little bit of
BEER
from @isnochys for you. Enjoy it!