Introducing: A Discord Crypto Ticker Bot based on CryptoBridge API

in #utopian-io6 years ago

Repository

https://github.com/gluneau/discord-crypto-bot

New Project

After being on the discord server of CryptoBridge, I noticed the Price Bots they had, I was inspired. A neet idea and a cool service for a coin. I contacted the team and was able to obtain the source code of the original bot used thanks to stepollo from crypto-bridge.org.

I then refactored the code, coalesced all prices into one bot and made it generic so that anyone who wants to add this bot to their discord server can with minimal configuration of the environment variables in .env file.

From here I was able to find the right match in the array of exchange pairs and get our token values.

And then we get the fiat values from here, all in BTC

We need to do some calculation around volume, then format all the strings we want the bot to report.

Finally we loop around and display each statistic after another with the sleep time requested.

Once this is done, it starts again, fetches the API one more time and does its thing, displays the newly acquired data.

Here is the results in an animated gif with 15 seconds interval:

Install instructions from the README.md

Installing the prerequisites

sudo apt install python-pip
pip install pipenv

Installing the bot:

git clone https://github.com/gluneau/discord-crypto-bot.git
cd discord-crypto-bot
pipenv install

Here is a proposed sample for your .env file:

YOURDISCORDTOKEN=Nxxxxxxxxxxxxxxxxxxxxxx4.Dxxxxw.mxxxxxxxxxxxxxxxxxxxxxxxxxk
BOTSLEEP=15
BOTPAIR=STONE_BTC
BOTFIAT=USD

Running the bot

pipenv run python3 bot.py

Technology Stack

  • Python3
  • Pipenv

Roadmap

It depends of the community requests, I will implement new features as they come up.

How to contribute

Simple! 1. fork, 2. modify, 3. submit a pull request to the official repository.

Proof of work

About Discord

Discord is an all-in-one voice and text chat for gamers (and crypto enthusiasts obviously!) that's free, secure, and works on both your desktop and phone.

Create your app and bot right here:

To add your new bot to a server you administer, replace the place holder with your client id and go:

About CryptoBridge

CryptoBridge is a decentralized exchange (DEX) that supports trading of most popular tokens & altcoins. In the hands of BridgeCoin Holders. Built on the Bitshares(BTS) CryptoBrigde’s order book, trades and accounts are completely decentralized. CryptoBridge can be access by anyone with internet access 24/7. Trading never stops.

About StoneCoin

STONE is a rock solid, feature rich cryptocurrency ecosystem. A group of ambitious community members banded together and began implementing their skills to revive the coin after being abandoned by the original developer. The choice to rebuild the infrastructure was easy due to the coin having been listed on two exchanges and the core built on an older Dash core that was widely known and easy to understand.

Thanks to @jedigeiss and @venalbe for their fantastic interview about StoneCoin and introduction to the project.

The bot is running on their Discord Server.

GitHub Account

Sort:  

Looks neat. It's a great idea to show prices like that.

One a side note, using requests library inside an asyncio loop is not considered a good practice since requests blocks entire loop until they finish. Using aiohttp or a similar non-blocking requests library would fix that since it will not block to the loop.

I know, this may not make any huge difference in a small scale like that but I would still stay away from blocking libraries in a non-blocking environment. :)


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]

Great feedback, I love it when I learn something new. I guess it's in the same line as asyncio.sleep().

I'll be putting this in for my next update. You never know who's going to use it next and develop on it. Better fix these now that the project is small.

I guess it's in the same line as asyncio.sleep().

Exactly. Same difference on asyncio.sleep and time.sleep. :)

Thank you for your review, @emrebeyler!

So far this week you've reviewed 2 contributions. Keep up the good work!

Thank you very much for your contribution to our STONE Discord, @helo!
The bot looks ace :)

Thanks, I like the team over there, very supportive. You have many Steemian fans as well, count me in with them.

Hi @helo! We are @steem-ua, a new Steem dApp, using UserAuthority for algorithmic post curation! Your post is eligible for our upvote, thanks to our collaboration with @utopian-io! Thanks for your contribution, keep up the good work, and feel free to join our @steem-ua Discord server

You make me smile every time I see you. I can't thank @scipio enough. Great things are coming.

Hey, @helo!

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!

Coin Marketplace

STEEM 0.17
TRX 0.16
JST 0.029
BTC 76095.48
ETH 2918.89
USDT 1.00
SBD 2.65