main
 1#!/usr/bin/env python
 2# -*- coding: utf-8 -*-
 3from pyrogram.client import Client
 4from pyrogram.types import Message, User
 5from pyrogram.types.messages_and_media.message import Str
 6
 7from config import DEVICE_NAME
 8from custom.config import ACCOUNT_NAME, CHANNEL_FAVORITE, GROUP_67373, GROUP_DEV, GROUP_JSQ, USER_BENNY, USER_XIAOHAO
 9from history.query import query_chat_history
10from messages.utils import startswith_prefix
11
12
13async def tg_history_alias(client: Client, message: Message, **kwargs):
14    """TG发言快捷查询.
15
16    `/wild`: 发姐
17    `/dbb`: 电报部
18    `/jsq`: 下班不关电脑群
19    """
20    cid = message.chat.id
21    if cid not in [GROUP_DEV, CHANNEL_FAVORITE, USER_BENNY, USER_XIAOHAO, GROUP_67373, GROUP_JSQ] or not startswith_prefix(
22        message.content, prefix=["/alias", "/wild", "/li", "/67373", "/jsq", "/pods", "/bili", "/weibo", "/fxq", "/zaihua", "/solidot", "/heike", "/hkdg"]
23    ):
24        return
25    if cid == GROUP_DEV and DEVICE_NAME in ["BennyBot-JP", "BennyBot-US", "BennyBot-CN"]:
26        return
27    if cid in [GROUP_67373, GROUP_JSQ, USER_XIAOHAO] and ACCOUNT_NAME != "xiaohao":  # 只使用小号响应67373相关群
28        return
29    if message.content == "/alias":
30        docs = "`/wild`: 发姐\n`/li`: 李老师\n`/67373`: 电报部\n`/jsq`: 技术群\n`/pods`: 播客\n`/bili`: B站\n`/weibo`: 微博\n`/fxq`: 风向旗\n`/zaihua`: 在花\n`/solidot`: Solidot\n`/heike`: 黑客帝国\n"
31        await message.reply(text=docs.strip(), quote=True)
32        return
33    text = ""
34    if startswith_prefix(message.content, prefix="/wild"):
35        text = message.content.removeprefix("/wild").strip()
36        text = f"/history #1744444199 @1639998668 {text}"
37    elif startswith_prefix(message.content, prefix="/dbb,/67373"):
38        text = message.content.removeprefix("/dbb").removeprefix("/67373").strip()
39        text = f"/history #1744444199 {text}"
40    elif startswith_prefix(message.content, prefix="/jsq,/jsb"):
41        text = message.content.removeprefix("/jsq").removeprefix("/jsb").strip()
42        text = f"/history #1852924912 {text}"
43    elif startswith_prefix(message.content, prefix="/pods"):
44        text = message.content.removeprefix("/pods").strip()
45        text = f"/history #2436072788 {text}"
46    elif startswith_prefix(message.content, prefix="/bili"):
47        text = message.content.removeprefix("/bili").strip()
48        text = f"/history #2178783945 {text}"
49    elif startswith_prefix(message.content, prefix="/weibo"):
50        text = message.content.removeprefix("/weibo").strip()
51        text = f"/history #2328010080 {text}"
52    elif startswith_prefix(message.content, prefix="/li"):
53        text = message.content.removeprefix("/li").strip()
54        text = f"/history #2416354272 {text}"
55    elif startswith_prefix(message.content, prefix="/zaihua"):
56        text = message.content.removeprefix("/zaihua").strip()
57        text = f"/history #1125107539 {text}"
58    elif startswith_prefix(message.content, prefix="/fxq"):
59        text = message.content.removeprefix("/fxq").strip()
60        text = f"/history #1472283197 {text}"
61    elif startswith_prefix(message.content, prefix="/solidot"):
62        text = message.content.removeprefix("/solidot").strip()
63        text = f"/history #1104204833 {text}"
64    elif startswith_prefix(message.content, prefix="/heike,/hkdg"):
65        text = message.content.removeprefix("/heike").removeprefix("/hkdg").strip()
66        text = f"/history #1812023706 {text}"
67    if not text:
68        return
69    message.text = Str(text)
70    message.from_user = User(id=USER_BENNY)  # Use `benny` to bypass permission check
71    await query_chat_history(client, message, **kwargs)