main
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3import asyncio
4import re
5
6from glom import glom
7from pyrogram.client import Client
8from pyrogram.types import Message
9
10# ruff: noqa: SIM102, RUF001
11
12SLEEP_TIME = 600
13
14
15async def lottery(client: Client, message: Message) -> None:
16 return
17 # 仅限于群聊
18 if glom(message, "chat.type.name", default="") != "SUPERGROUP":
19 return
20
21 # 抽奖机器人 @XiaoCaiLotteryBot
22 if glom(message, "from_user.id", default=0) == 6461022460:
23 if str(message.text).startswith("新的抽奖已经创建\n"):
24 if matched := re.search(r"参与关键词:「(.*?)」", str(message.text)):
25 keyword = matched.group(1)
26 await asyncio.sleep(SLEEP_TIME)
27 await client.send_message(message.chat.id, keyword)
28
29 # 抽奖机器人 @Lottery8Bot
30 for url in glom(message, "reply_markup.inline_keyboard.**.url", default=[]):
31 if str(url).startswith("https://t.me/Lottery8Bot?start="):
32 await asyncio.sleep(SLEEP_TIME)
33 await client.send_message("@Lottery8Bot", "/start " + url.removeprefix("https://t.me/Lottery8Bot?start="))