|
|
|
|
|
|
|
|
|
|
|
import random |
|
import re |
|
|
|
from telegram import Update |
|
from telegram.constants import ParseMode |
|
from telegram.ext import CommandHandler, ContextTypes |
|
|
|
from Mikobot import function |
|
|
|
|
|
|
|
|
|
|
|
|
|
async def pick_winner(update: Update, context: ContextTypes.DEFAULT_TYPE): |
|
|
|
participants = context.args |
|
|
|
if participants: |
|
|
|
winner = random.choice(participants) |
|
|
|
|
|
await update.message.reply_text(f"π The winner is: {winner}") |
|
else: |
|
|
|
await update.message.reply_text("Please provide a list of participants.") |
|
|
|
|
|
|
|
async def hyperlink_command(update: Update, context: ContextTypes.DEFAULT_TYPE): |
|
args = context.args |
|
if len(args) >= 2: |
|
text = " ".join(args[:-1]) |
|
link = args[-1] |
|
hyperlink = f"[{text}]({link})" |
|
await update.message.reply_text( |
|
text=hyperlink, parse_mode="Markdown", disable_web_page_preview=True |
|
) |
|
else: |
|
match = re.search(r"/hyperlink ([^\s]+) (.+)", update.message.text) |
|
if match: |
|
text = match.group(1) |
|
link = match.group(2) |
|
hyperlink = f"[{text}]({link})" |
|
await update.message.reply_text( |
|
text=hyperlink, parse_mode=ParseMode.HTML, disable_web_page_preview=True |
|
) |
|
else: |
|
await update.message.reply_text( |
|
"β Invalid format! Please use the format: /hyperlink <text> <link>." |
|
) |
|
|
|
|
|
|
|
function(CommandHandler("pickwinner", pick_winner, block=False)) |
|
function(CommandHandler("hyperlink", hyperlink_command, block=False)) |
|
|
|
|