Python Forum
Creating a TG crypto Bot_ problem when trying to with bot.polling
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating a TG crypto Bot_ problem when trying to with bot.polling
#1
Hi there, I have a problem, I have made a telegram bot, which gets input from telgegram(namely the crypto coin name) and then using the CoinGecko API, it sends the price of that coin on telegram, here is my code:

import environs from pycoingecko import CoinGeckoAPI from telebot import TeleBot env = environs.Env() env.read_env('.env') BOT_TOKEN = env('API_KEY') bot = TeleBot(token=BOT_TOKEN) coin_client = CoinGeckoAPI() ### print(coin_client.get_price(ids="bone-shibaswap", vs_currencies='usd')['bone-shibaswap']['usd']) @bot.message_handler(content_types=['text']) def crypto_price_message_handler(message): crypto_id = message.text price = coin_client.get_price(ids=crypto_id, vs_currencies='usd')[crypto_id]['usd'] bot.send_message(chat_id=message.chat.id, text=f"Price of {crypto_id}: {price}$") bot.polling(none_stop=True, )
I tried bot.infinity_polling() :(

What I want to achieve is that, for ex. if in the TG bot, I enter bitcoin, it replies me with price, but I want the price to autopost constanstly as the price changes.
Again the data of the prices is from Coingecko API.

So far so good, If anyone could help me with the issue I would really apreaciate it.

Best regards.
Reply
#2
Anyone ?!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  how to manage crypto trading flooding data from exchange servers Mikeardy 2 4,296 Sep-11-2025, 06:01 AM
Last Post: Mercyto
  SHA256 ImportError when using Crypto.Hash in crypto.py andrewk 1 1,216 Feb-17-2025, 02:06 PM
Last Post: DeaD_EyE
  How to listen to clipboard content change without polling the clipboard continuously? edgelord 0 4,088 Nov-27-2020, 06:07 AM
Last Post: edgelord
  Problem creating an archive trojantrojan 3 3,502 May-10-2020, 01:32 AM
Last Post: trojantrojan
  Problem with using Crypto library reks2004 2 3,945 Mar-27-2020, 05:38 AM
Last Post: buran
  Python crypto byte plaintext to hexint Mangaz90 2 4,233 Feb-21-2020, 07:42 PM
Last Post: Mangaz90
  mouse 0.7.0 - mouse polling hate 125-1000hz penahuse 1 3,812 Dec-06-2019, 09:51 PM
Last Post: Larz60+
  Problem in creating a vector termo 11 6,905 Oct-10-2019, 03:09 PM
Last Post: stullis
  Create file archive that contains crypto hash ED209 1 3,188 May-29-2019, 03:05 AM
Last Post: heiner55
  crypto import issue saisankalpj 2 10,934 Dec-20-2018, 06:08 AM
Last Post: saisankalpj

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020
This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.