Mike
mike5-20 minutes of reaction times based on the army of the attacker. is a Discord bot sends notifications to your discord handle if you get attacked in the @drugwars game. Currently, when somebody attacks you, you have
Imagine you're at the office and focusing into your work, and suddenly @ngc attacks you to wipe out your army. The first thing to do is spending in-game resources so they're not exposed for stealing. However, you have still units and you have two options:
- Fight and die
- Send your troops to another easy opponent so they don't die.
In order to react fast to that kind of situations, Mike sends notifications (delay time: 5-10 seconds) to your Discord handle. An instance of the bot is currently live at a new Discord Server free to use for any player.
Usage
After joining the discord server send this command in the #bot-commands
channel:
$subscribe <player_name>
And you're all set. You can subscribe up to 10 different players. If you want to unsubscribe from a player, you can use $unsubscribe <player_name>
and you can see all your subscriptions with $subscriptions
.
Tech talk: Discord bots, Steem and Non blocking I/O
All the data is streamed from the blockchain, almost real-time.
Since discord.py
uses an asyncio eventloop, all functionality of the bot should work with async libraries to avoid blocking calls. The current state of the python libraries for steem is not well in the non-blocking world so using steem-python
, beem
, or lightsteem
was not feasible.
meeseeker comes into the play to solve that problem. Since it's possible to subscribe custom jsons with meeseeker, utilizing it helped me remove lots of boilerplate code, and staying in the asyncio loop
without any blocking code. (aioredis
)@inertia's amazing
If you want to have a private mike for your own joy in your discord server, you can install the bot on your own.
Installation
$ (sudo) pip install drugwars_mike
Configuration and Running
mike
uses meeseeker
to stream custom json operations. If you don't have a meeseker
yet, you need to install it.
An Example command to run meeseker
to have custom json channels:
MEESEEKER_PUBLISH_OP_CUSTOM_ID=true MEESEEKER_EXPIRE_KEYS=300 meeseeker sync
Environment parameters:
Variable | Description | Required |
---|---|---|
MIKE_BOT_TOKEN | Discord bot token | True |
MIKE_BATTLE_LOG_CHANNEL_ID | Channel ID for battle logs | False |
MIKE_DB | Connection URI for DB | True |
MIKE_REDIS_HOST | Redis host | True |
MIKE_REDIS_PORT | Redis port | True |
You can run mike by typing:
$ MIKE_BOT_TOKEN=<token> MIKE_DB=sqlite:///mydatabase.db MIKE_REDIS_HOST=localhost MIKE_REDIS_PORT=6379 mike
Repository and License
Repository is located at github/emre/mike and it's licensed under MIT.
Disclaimer
Even though mike works perfectly at the moment, there is no guarantee that it will notify you every time. Due to potential bugs or lags in the backend blockchain streaming, you may miss some notifications. However, I will be doing my best to keep it always working.
Vote for my witness
This is yet another free of charge tool I have developed for the Steem community. If you like what I do, consider casting a vote on via Steemconnect or on steemit.com
Thank you for your contribution. I have to admit that I spent quite some time learning how to play this game, and it is fun!
I have some concerns about the performance. If there are quite a number of subscribers, does this Python library have impact on the server or does it have delays on sending notifications? You might want to have a separate queue for sending notification. The
await
still blocks the function execution.Great to see you have tests! You could add some unit tests for historic data, as they are immutable on the steem blockchain which is great to test the
TxListener.handle_operation()
which I think it is important.Your code looks great and it is a text-book example for learning Python, Steem Blockchain and how to create a discord bot. Thanks for that.
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? Chat with us on Discord.
[utopian-moderator]
Thank you for your review, @justyy! Keep up the good work!
Also, special thanks to @crokkon, @bitcoinjake09, @louis88 for the initial testing on the bot. :-)
Magic Dice has rewarded your post with a 79% upvote. Thanks for playing Magic Dice.
You can always call upon @fenrir78 for some support 😂
Dude that rocks!
🤘
Excellent!
I don't think the discord link works?
Fixed.
That discord link might be expired.
Should be fixed, now.
Awesome work, could have come really handy abt an hr ago
Well, you had one battle. There will be more :-)
Agreed, I was thinking about how to build one right after that battle. Atleast a script to just buy units if thr is an attack. Glad you build one on discord. Are you scanning the blockchain to check for attacks?
That's great. Really spices up battles - and very annoying for attackers :D
Posted using Partiko Android
Hi @emrebeyler!
Feel free to join our @steem-ua Discord serverYour 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!
BRILLIANT!
This is awesome, thank you! :)
@tipU voting service always profitable, instant upvotes | For investors.This post is supported by $2.05 @tipU upvote funded by @cardboard :)
Hey, @emrebeyler!
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!
Get higher incentives and support Utopian.io!
SteemPlus or Steeditor). Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via
Want to chat? Join us on Discord https://discord.gg/h52nFrV.
Vote for Utopian Witness!
good stuff, i'll take look, still learning...already got steempy installed and importaccount command with success, now i look forward learning how to put info from the blockchain in a table (just like i do with steemsql query's), i need more coffee :)
This post has been included in the latest edition of SoS Daily News - a digest of all the latest news on the Steem blockchain.
This is great! Thanks for this, I'll try it now.
Good work, how do you get all this time :D :D
Magic Dice has rewarded your post with a 6% upvote. Thanks for playing Magic Dice.