NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

import telepot
import requests
import json
import config

def handle_message(msg):
content_type, chat_type, chat_id = telepot.glance(msg)
if content_type == 'text':
command = msg['text'].split()
if len(command) == 2 and command[0].lower() == '/d':
symbol = command[1].upper() + 'USDT'
url = f'https://api.bybit.com/v5/market/tickers?category=linear&symbol={symbol}'
response = requests.get(url)
if response.status_code == 200:
data = json.loads(response.text)
if data['retCode'] == 0 and len(data['result']['list']) == 1:
result = data['result']['list'][0]
lastPrice = result['lastPrice']
highPrice24h = result['highPrice24h']
lowPrice24h = result['lowPrice24h']
price_24h_pcnt = float(result['price24hPcnt'])
price_24h_emoji = '🔺' if price_24h_pcnt >= 0 else '🔻'
price_24h_pcnt_formatted = "{0}{1:.2f}".format("+%" if price_24h_pcnt > 0 else "-%", abs(price_24h_pcnt) * 100)
turnover24h = "{:.3f}".format(float(result['turnover24h']))
volume24h = "{:.2f}".format(float(result['volume24h']))
openInterest = result['openInterest']
fundingRate = float(result['fundingRate']) * 100
fundingRate_formatted = "{0}{1:.4f}%".format("+" if fundingRate > 0 else "", fundingRate)
nextFundingTime = result['nextFundingTime']
time_to_funding = int((int(nextFundingTime) - int(result['time_now'])) / 60)


# Başlık oluşturma
title_emoji = price_24h_emoji
title_symbol = symbol.replace("USDT", "")
message_title = f"<b>⚡️ Güncel {symbol} Fiyat Verisi ({price_24h_pcnt_formatted}{title_emoji})</b>nn"

# istatistiksel bilgilerin toplanması
statistics = {
'🟠 Son Fiyat': f"<b>{lastPrice}$</b>",
'🔄 24S Değişim': f"<b>{price_24h_pcnt_formatted}</b>",
'⬆️ 24S En Yüksek': f"<b>{highPrice24h}$</b>",
'⬇️ 24S En Düşük': f"<b>{lowPrice24h}$</b>",
'📊 24S Hacim': f"<b>{volume24h} {title_symbol}</b>",
'📊 24S Ciro (USDT)': f"<b>{turnover24h}$</b>",
'🔍 Açık Pozisyon Sayısı': f"<b>{openInterest}</b>",
'💰 Fonlama Oranı': f"<b>{fundingRate_formatted}</b>",
'⏳ Fonlama Zamanı(Kalan)': f"<b>{time_to_funding}</b>"
}


# İstatistiksel bilgilerin formatlanması
message_statistics = ""
for title, value in statistics.items():
message_statistics += f"{title}: {value}n"

# Mesaj oluşturma ve gönderme
message_link = f"https://www.bybit.com/trade/usdt/{symbol}"
message = f"{message_title}{message_statistics}n👉 <b><a href='{message_link}'>{symbol} (VADELİ) sözleşmesinde işlem yapın!</a></b>"
bot.sendMessage(chat_id, message, parse_mode='HTML', disable_web_page_preview=True)
else:
bot.sendMessage(chat_id, 'Geçersiz bir vadeli sözleşme arattınız, lütfen tekrar deneyin.')
else:
bot.sendMessage(chat_id, 'APIde sorun var, daha sonra tekrar deneyin!')


TOKEN = config.API_KEY
bot = telepot.Bot(TOKEN)
bot.message_loop(handle_message)

while True:
pass
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.