-
Notifications
You must be signed in to change notification settings - Fork 1
/
bot.py
36 lines (31 loc) · 1.12 KB
/
bot.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
from flask import Flask, request
from telegram import Bot, InlineKeyboardMarkup, InlineKeyboardButton
from decouple import config
import json
app = Flask(__name__)
bot = Bot(config("BOT_TOKEN", default=None))
chat = config('UPDATE', default=None, cast=int)
@app.route('/', methods=["POST"])
def main():
data = json.loads(request.form.to_dict()['data'])
message=f'''
A *{data['type']}* received from *{data["from_name"]}* of *{data['amount']}* _{data['currency']}_ 🥳.
`Transaction Id` : *{data['kofi_transaction_id']}*
`Subscription payment` : *{data['is_subscription_payment']}*
`From` : *{data['from_name']}*
`Sender e-Mail` : *{data['email']}*
`Currency` : *{data['currency']}*
`Amount` : *{data['amount']}*
'''
bot.send_message(
chat_id=chat,
text=message,
parse_mode='MarkDown',
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup([
[InlineKeyboardButton(text="👀 View transaction 👀", url=data['url'])]
])
)
return {}, 200
if __name__ == '__main__':
app.run(host='0.0.0.0', port=config('PORT', default=6969))