forked from cyber-urvesh/crypto-wp-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
100 lines (82 loc) · 4.09 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
from flask import Flask, request
import requests
import pandas as pd
from bs4 import BeautifulSoup as BS
from twilio.twiml.messaging_response import MessagingResponse
app = Flask(__name__)
@app.route('/')
def hello():
return "Hello World!"
@app.route('/bot', methods=['POST'])
def bot():
incoming_msg = request.values.get('Body', '').lower()
resp = MessagingResponse()
msg = resp.message()
responded = False
if '1' in incoming_msg or 'btc' in incoming_msg:
response = requests.get('https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=inr')
data = response.json()
rate = f'*Current Bitcoin(BTC) Rate in INR*: Rs.{data["bitcoin"]["inr"]}'
msg.body(rate)
responded = True
if '2' in incoming_msg or 'ltc' in incoming_msg:
response = requests.get('https://api.coingecko.com/api/v3/simple/price?ids=litecoin&vs_currencies=inr')
data = response.json()
rate = f'*Current Litecoin(LTC) Rate in INR*: Rs.{data["litecoin"]["inr"]}'
msg.body(rate)
responded = True
if '3' in incoming_msg or 'eth' in incoming_msg:
response = requests.get('https://api.coingecko.com/api/v3/simple/price?ids=ethereum&vs_currencies=inr')
data = response.json()
rate = f'*Current Ethereum(ETH) Rate in INR*: Rs.{data["ethereum"]["inr"]}'
msg.body(rate)
responded = True
if '4' in incoming_msg or 'usdt' in incoming_msg:
response = requests.get('https://api.coingecko.com/api/v3/simple/price?ids=Tether&vs_currencies=inr')
data = response.json()
rate = f'*Current Theter(USDT) Rate in INR*: Rs.{data["tether"]["inr"]}'
msg.body(rate)
responded = True
if '5' in incoming_msg or 'ada' in incoming_msg:
response = requests.get('https://api.coingecko.com/api/v3/simple/price?ids=Cardano&vs_currencies=inr')
data = response.json()
rate = f'*Current Cardano(ADA) Rate in INR*: Rs.{data["cardano"]["inr"]}'
msg.body(rate)
responded = True
if '6' in incoming_msg or 'xlm' in incoming_msg:
response = requests.get('https://api.coingecko.com/api/v3/simple/price?ids=Stellar&vs_currencies=inr')
data = response.json()
rate = f'*Current Stellar(XLM) Rate in INR*: Rs.{data["stellar"]["inr"]}'
msg.body(rate)
responded = True
if '7' in incoming_msg or 'doge' in incoming_msg:
response = requests.get('https://api.coingecko.com/api/v3/simple/price?ids=Dogecoin&vs_currencies=inr')
data = response.json()
rate = f'*Current Dogecoin(DOGE) Rate in INR*: Rs.{data["dogecoin"]["inr"]}'
msg.body(rate)
responded = True
if '8' in incoming_msg or 'dot' in incoming_msg:
response = requests.get('https://api.coingecko.com/api/v3/simple/price?ids=Polkadot&vs_currencies=inr')
data = response.json()
rate = f'*Current Polkadot(DOT) Rate in INR*: Rs.{data["polkadot"]["inr"]}'
msg.body(rate)
responded = True
if '9' in incoming_msg or 'xmr' in incoming_msg:
response = requests.get('https://api.coingecko.com/api/v3/simple/price?ids=Monero&vs_currencies=inr')
data = response.json()
rate = f'*Current Monero(XMR) Rate in INR*: Rs.{data["monero"]["inr"]}'
msg.body(rate)
responded = True
if '10' in incoming_msg or 'sol' in incoming_msg:
response = requests.get('https://api.coingecko.com/api/v3/simple/price?ids=Solana&vs_currencies=inr')
data = response.json()
rate = f'*Current Solana(SOL) Rate in INR*: Rs.{data["solana"]["inr"]}'
msg.body(rate)
responded = True
if not responded:
text = f'*Please enter one of the following option to get current rates in INR👇* \n *1*. Bitcoin *(BTC)* \n *2*. Litecoin *(LTC)* \n *3*. Ethereum *(ETH)* \n *4*. Tether *(USDT)* \n *5*. Cardiano *(ADA)* \n *6*. Steller *(XLM)* \n *7*. Dogecoin *(DOGE)* \n *8*. Polkadot *(DOT)* \n *9*. Monero *(XMR)* \n *10*. Solana *(SOL)* '
msg.body(text)
responded = True
return str(resp)
if __name__ == '__main__':
app.run()