3
0
Telegram_PaimonBot/defs/log.py
Xtao_dada 5eeea30fdc
v0.1.0beta (#1)
*  支持生成原神黄历
*  支持每日副本查询
*  支持角色资料、命座查询
*  支持武器查询
2021-07-09 23:31:30 +08:00

35 lines
1.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from configparser import RawConfigParser
from os import getcwd, sep
from pyrogram import Client
from pyrogram.types import Message
config = RawConfigParser()
config.read(f"{getcwd()}{sep}config.ini")
channel_id: int = 0
channel_id = config.get("basic", "channel_id", fallback=channel_id)
async def log(client: Client, message: Message, mode):
if not channel_id == 0:
chat = message.chat
cid = chat.id
uid = message.from_user.id
if chat.type == 'private':
cname = chat.first_name
else:
cname = chat.title
if chat.username:
cname = f'<a href="https://t.me/{chat.username}">{cname}</a>'
else:
cname = f'<code>{cname}</code>'
if mode == '邀请入群':
text = '#Paimon #join \n'
else:
text = '#Paimon #message \n'
text += f'群组 ID<code>{cid}</code>\n' \
f'群组名称:{cname}\n' \
f'用户 ID<code>{uid}</code>\n' \
f'执行操作:<code>{mode}</code>'
await client.send_message(channel_id, text, disable_notification=True, disable_web_page_preview=True)