Skip to content

hiropuko/python-mini-telegram-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Python mini Telegram-bot

Мини Telegram-бот на Python

# library import / импорт библиотеки

import ccxt # pip install ccxt
import telegram # pip install python-telegram-bot
import asyncio
# object instance of the ccxt.binance() class for interacting with the Binance API
# объект экземпляр класса ccxt.binance() для взаимодействия с Binance API

exchange = ccxt.binance()
# an instance of the telegram.Bot class for messages in Telegram
# экземпляр класса telegram.Bot для сообщений в Telegram

bot = telegram.Bot(token='YOUR_TELEGRAM_TOKEN')
chat_id = 'YOUR_TELEGRAM_CHAT_ID'
# function / функция

async def send_btc_price():
    while True:
    # loop / цикл
        ticker = exchange.fetch_ticker('BTC/USDT')
        btc_price = ticker['last']
        await bot.send_message(chat_id=chat_id, text=f'BTC/USDT: {btc_price}')
        await asyncio.sleep(5) # pause in seconds /  в секундах пауза
asyncio.run(send_btc_price()) # start function / запуск функции

About

Python mini Telegram Bot

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages