gfregfregfr
This commit is contained in:
49
text/text.py
49
text/text.py
@@ -57,13 +57,15 @@ async def create_telegram_client(server):
|
||||
|
||||
async def main():
|
||||
server, server_type = TgPhoneDevices().get_or_create(
|
||||
phone="8613661496481",
|
||||
phone="8613641805330",
|
||||
)
|
||||
|
||||
client = await create_telegram_client(server)
|
||||
|
||||
await client.connect()
|
||||
|
||||
# await client.log_out()
|
||||
|
||||
# if await client.is_user_authorized():
|
||||
# me = await client.get_me()
|
||||
# logger.info(f'账号 {8617882004254} -- {me.username} 登录成功!')
|
||||
@@ -170,7 +172,7 @@ async def main():
|
||||
|
||||
# # ---------------------------------------------------------------------------------------------
|
||||
# try:
|
||||
# await client.edit_2fa(current_password="123123", new_password="123")
|
||||
# await client.edit_2fa(current_password="Haxi@123456@", new_password="123456qwe")
|
||||
# except NewSettingsInvalidError:
|
||||
# print(1)
|
||||
# except PasswordHashInvalidError:
|
||||
@@ -264,17 +266,44 @@ async def main():
|
||||
# ]
|
||||
# await client(InviteToChannelRequest(target_group, users_to_add))
|
||||
|
||||
# 2️⃣ 发送消息
|
||||
update = await client(ImportChatInviteRequest("+E6E4i3svka81MGY1"))
|
||||
chat = update.chats[0]
|
||||
try:
|
||||
await client.send_message(chat.id, "你好,这是一条来自 Telethon 的测试消息!")
|
||||
print("消息已发送!")
|
||||
except Exception as e:
|
||||
print(f"发送失败: {e}")
|
||||
# # 2️⃣ 发送消息
|
||||
# update = await client(ImportChatInviteRequest("+E6E4i3svka81MGY1"))
|
||||
# chat = update.chats[0]
|
||||
# try:
|
||||
# await client.send_message(chat.id, "你好,这是一条来自 Telethon 的测试消息!")
|
||||
# print("消息已发送!")
|
||||
# except Exception as e:
|
||||
# print(f"发送失败: {e}")
|
||||
|
||||
|
||||
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
print("正在获取对话列表...")
|
||||
# 获取所有对话
|
||||
dialogs = await client.get_dialogs()
|
||||
|
||||
# 退出所有群聊
|
||||
for dialog in dialogs:
|
||||
if dialog.is_group or dialog.is_channel:
|
||||
try:
|
||||
await client.delete_dialog(dialog.entity)
|
||||
print(f"已退出群聊/频道: {dialog.title}")
|
||||
except Exception as e:
|
||||
print(f"退出群聊/频道 {dialog.title} 时出错: {e}")
|
||||
|
||||
# 取消关注所有机器人
|
||||
for dialog in dialogs:
|
||||
if hasattr(dialog.entity, 'bot') and dialog.entity.bot:
|
||||
try:
|
||||
await client.delete_dialog(dialog.entity)
|
||||
print(f"已取消关注机器人: {dialog.title}")
|
||||
except Exception as e:
|
||||
print(f"取消关注机器人 {dialog.title} 时出错: {e}")
|
||||
|
||||
await client.disconnect()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
asyncio.run(main())
|
||||
|
||||
|
||||
# .\xray.exe -c .\1_3078_client_liu_http_ip_1v1.json
|
||||
Reference in New Issue
Block a user