mirror of
https://gitlab.com/simple-stock-bots/simple-telegram-stock-bot.git
synced 2025-06-16 06:56:46 +00:00
finished donation functinoality.
This commit is contained in:
parent
71db661d72
commit
f02ab0d14b
33
bot.py
33
bot.py
@ -4,14 +4,19 @@ import io
|
||||
import logging
|
||||
import os
|
||||
import random
|
||||
|
||||
import mplfinance as mpf
|
||||
|
||||
import telegram
|
||||
from telegram import InlineQueryResultArticle, InputTextMessageContent, LabeledPrice
|
||||
from telegram import (
|
||||
InlineQueryResultArticle,
|
||||
InputTextMessageContent,
|
||||
LabeledPrice,
|
||||
)
|
||||
from telegram.ext import (
|
||||
CommandHandler,
|
||||
Filters,
|
||||
InlineQueryHandler,
|
||||
PreCheckoutQueryHandler,
|
||||
MessageHandler,
|
||||
Updater,
|
||||
)
|
||||
@ -67,7 +72,7 @@ def donate(update, context):
|
||||
amount = update.message.text.replace("/donate", "").replace("$", "").strip()
|
||||
title = "Simple Stock Bot Donation"
|
||||
description = f"Simple Stock Bot Donation of ${amount}"
|
||||
payload = "Simple Telegram Stock Bot"
|
||||
payload = "simple-stock-bot"
|
||||
provider_token = STRIPE_TOKEN
|
||||
start_parameter = str(chat_id)
|
||||
|
||||
@ -95,6 +100,20 @@ def donate(update, context):
|
||||
)
|
||||
|
||||
|
||||
def precheckout_callback(update, context):
|
||||
query = update.pre_checkout_query
|
||||
|
||||
if query.invoice_payload == "simple-stock-bot":
|
||||
# answer False pre_checkout_query
|
||||
query.answer(ok=True)
|
||||
else:
|
||||
query.answer(ok=False, error_message="Something went wrong...")
|
||||
|
||||
|
||||
def successful_payment_callback(update, context):
|
||||
update.message.reply_text("Thank you for your donation!")
|
||||
|
||||
|
||||
def symbol_detect(update, context):
|
||||
"""
|
||||
Runs on any message that doesn't have a command and searches for symbols, then returns the prices of any symbols found.
|
||||
@ -377,6 +396,14 @@ def main():
|
||||
# Inline Bot commands
|
||||
dp.add_handler(InlineQueryHandler(inline_query))
|
||||
|
||||
# Pre-checkout handler to final check
|
||||
dp.add_handler(PreCheckoutQueryHandler(precheckout_callback))
|
||||
|
||||
# Payment success
|
||||
dp.add_handler(
|
||||
MessageHandler(Filters.successful_payment, successful_payment_callback)
|
||||
)
|
||||
|
||||
# log all errors
|
||||
dp.add_error_handler(error)
|
||||
|
||||
|
8
commands
Normal file
8
commands
Normal file
@ -0,0 +1,8 @@
|
||||
donate - Donate to the bot 🎗️
|
||||
help - Get some help using the bot. 🆘
|
||||
info - $[symbol] General information about the symbol. ℹ️
|
||||
news - $[symbol] News about the symbol. 📰
|
||||
stat - $[symbol] Key statistics about the symbol. 🔢
|
||||
dividend - $[symbol] Dividend info 📅
|
||||
intra - $[symbol] Plot since the last market open. 📈
|
||||
chart - $[chart] Plot of the past month. 📊
|
@ -35,7 +35,7 @@ Keep up with the latest news for the bot in its Telegram Channel: https://t.me/s
|
||||
Full documentation on using and running your own stock bot can be found [here.](https://simple-stock-bots.gitlab.io/site)
|
||||
|
||||
**Commands**
|
||||
- /donate [amount in USD] to donate. 💵
|
||||
- /donate [amount in USD] to donate. 🎗️
|
||||
- /dividend $[symbol] will return dividend information for the symbol. 📅
|
||||
- /intra $[symbol] Plot of the stocks movement since the last market open. 📈
|
||||
- /chart $[symbol] Plot of the stocks movement for the past 1 month. 📊
|
||||
@ -62,6 +62,8 @@ Example: `/donate 2` would donate 2 USD.
|
||||
An alternative way to donate is through https://www.buymeacoffee.com/Anson, which accepts Paypal or Credit card.
|
||||
|
||||
If you have any questions get in touch: @MisterBiggs or [anson@ansonbiggs.com](http://mailto:anson@ansonbiggs.com/)
|
||||
|
||||
*Donations can only be made in a chat directly with @simplestockbot
|
||||
"""
|
||||
|
||||
def __init__(self, IEX_TOKEN: str):
|
||||
|
Loading…
x
Reference in New Issue
Block a user