Skip to content

Instantly share code, notes, and snippets.

@wolfsyntax
Last active November 13, 2018 17:30
Show Gist options
  • Save wolfsyntax/6ba63965d10f607f4904a24070f39310 to your computer and use it in GitHub Desktop.
Save wolfsyntax/6ba63965d10f607f4904a24070f39310 to your computer and use it in GitHub Desktop.
Exploring Languages
#Default: Python-Telegram-Bot
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
from telegram import ReplyKeyboardMarkup
import telegram
#Tables
import pandas as pd
#Database
import pymysql.cursors
#
import sys, os, requests
#==================================================
reply_keyboard = [
[' BTC', ' BCH'],
[' XRP',' ETH']
]
markup = ReplyKeyboardMarkup(reply_keyboard, one_time_keyboard=True, resize_keyboard=True)
bot.send_message(chat_id=update.message.chat_id, text = msg,reply_markup=markup,parse_mode=telegram.ParseMode.MARKDOWN)
#==================================================
bot.send_message(chat_id=update.message.chat_id, text = " ",parse_mode=telegram.ParseMode.MARKDOWN)
#==================================================
#==================================================
bot.sendPhoto(chat_id=update.message.chat_id, photo="https://blockchain.info/qr?data=bitcoin:3FW3ghHDMWSbhCMG1vQV1SqvXNTeQQWfPK?size=80", caption="3FW3ghHDMWSbhCMG1vQV1SqvXNTeQQWfPK")
#==================================================
#==================================================
def unknown(bot, update):
rmsg = update.message.text
id = update.message.chat_id
currency = None
bot.send_chat_action(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
if(rmsg == "💲 BTC"):
currency = "BTC"
elif(rmsg == "💲 ETH"):
currency = "ETH"
elif(rmsg == "💲 BCH"):
currency = "BCH"
elif(rmsg == "💲 XRP"):
currency = "XRP"
if(currency is not None):
response = requests.get('https://quote.coins.ph/v1/markets/{}-PHP'.format(currency)).json()
bot.send_chat_action(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
msg = "Buy:\t₱ `%s` / 1 *%s*\nSell:\t₱ `%s` / 1 *%s*\n`Will update after %s seconds`\n"%("{0:,.2f}".format(float(response['market']['ask'])),currency,"{0:,.2f}".format(float(response['market']['bid'])),currency,response['market']['expires_in_seconds'])
else:
msg = "Sorry, I didn't understand you!"
bot.send_chat_action(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
bot.send_message(chat_id=update.message.chat_id, text=msg, parse_mode=telegram.ParseMode.MARKDOWN)
#==================================================
def main():
updater = Updater(token='YOUR TOKEN',workers=10)
dispatcher = updater.dispatcher
print("The System is up..")
dispatcher.add_handler(CommandHandler('start', start,pass_args=True))
dispatcher.add_handler(MessageHandler(Filters.text, unknown))
updater.start_polling()
updater.idle()
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment