Skip to content

Instantly share code, notes, and snippets.

@makzan
Created December 30, 2021 08:21
Telegram Like Pirce Bot
from telegram.ext import Updater
from telegram import Update
from telegram.ext import CallbackContext
from telegram.ext import CommandHandler
TOKEN = "YOUR_BOT_API_TOKEN_HERE"
updater = Updater(token=TOKEN)
def start(update: Update, context: CallbackContext):
context.bot.send_message(chat_id=update.effective_chat.id, text="I'm a bot. You may check LIKE price with me: /LIKE")
def like(update: Update, context: CallbackContext):
import requests
url = "https://api.coingecko.com/api/v3/simple/price?ids=likecoin&vs_currencies=usd"
res = requests.get(url)
data = res.json()
price = data["likecoin"]["usd"]
context.bot.send_message(chat_id=update.effective_chat.id, text=f"LIKE: {price}")
def price(update: Update, context: CallbackContext):
import requests
url = "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin,ethereum,terra-luna,osmosis,likecoin,crypto-com-chain&vs_currencies=usd"
res = requests.get(url)
data = res.json()
btc,eth,like,osmo,cro,luna = (
data["bitcoin"]["usd"],
data["ethereum"]["usd"],
data["likecoin"]["usd"],
data["osmosis"]["usd"],
data["crypto-com-chain"]["usd"],
data["terra-luna"]["usd"],
)
context.bot.send_message(chat_id=update.effective_chat.id, text=f"BTC: {btc}\nETH: {eth}\nLIKE: {like}\nOSMO: {osmo}\nCRO: {cro}\nLUNA: {luna}")
updater.dispatcher.add_handler(CommandHandler('start', start))
updater.dispatcher.add_handler(CommandHandler('like', like))
updater.dispatcher.add_handler(CommandHandler('price', price))
updater.start_polling()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment