mirror of
https://github.com/Xtao-Labs/iShotaBot.git
synced 2024-11-21 14:48:23 +00:00
feat: donate
This commit is contained in:
parent
36caca3ead
commit
fcae61039b
55
modules/donate.py
Normal file
55
modules/donate.py
Normal file
@ -0,0 +1,55 @@
|
||||
from pyrogram import filters
|
||||
from pyrogram.types import LabeledPrice, PreCheckoutQuery, Message
|
||||
|
||||
from defs.glover import admin
|
||||
from init import bot
|
||||
|
||||
|
||||
@bot.on_message(
|
||||
filters.incoming & filters.command(["donate", f"donate@{bot.me.username}"])
|
||||
)
|
||||
async def send_donate(_, message: Message):
|
||||
await bot.send_invoice(
|
||||
message.chat.id,
|
||||
title="Donate",
|
||||
description="Support me",
|
||||
currency="XTR",
|
||||
prices=[LabeledPrice(label="Star", amount=10)],
|
||||
payload="stars"
|
||||
)
|
||||
|
||||
|
||||
@bot.on_message(
|
||||
filters.successful_payment,
|
||||
)
|
||||
async def successful_payment(_, message: Message):
|
||||
uuid = message.successful_payment.telegram_payment_charge_id
|
||||
await message.reply_text(
|
||||
f"Thank you for your donation! If you have any questions, please contact @omg_xtao . UUID: `{uuid}`"
|
||||
)
|
||||
|
||||
|
||||
@bot.on_message(
|
||||
filters.incoming
|
||||
& filters.private
|
||||
& filters.user(admin)
|
||||
& filters.command(["donate_refund"])
|
||||
)
|
||||
async def refund_donate(_, message: Message):
|
||||
uid = message.command[1] if len(message.command) > 1 else None
|
||||
uuid = message.command[2] if len(message.command) > 2 else None
|
||||
if not (uuid and uid):
|
||||
return await message.reply_text("Please provide a UID and UUID")
|
||||
try:
|
||||
await bot.refund_star_payment(
|
||||
user_id=int(uid),
|
||||
telegram_payment_charge_id=uuid,
|
||||
)
|
||||
await message.reply_text("Refund successful")
|
||||
except Exception as e:
|
||||
await message.reply_text(f"Refund failed: {e}")
|
||||
|
||||
|
||||
@bot.on_pre_checkout_query()
|
||||
async def pre_checkout_query_handler(_, query: PreCheckoutQuery):
|
||||
await query.answer(ok=True)
|
Loading…
Reference in New Issue
Block a user