🐛✨ Support ping dcs,block、unblock user,fix profile unable to mention user without username. (#85)
* ✨ 支持测试客户端到五个DC的延迟, * ✨ 支持拉黑、取消拉黑用户, * 🐛 修复用户简介无法提及无用户名用户。
This commit is contained in:
parent
0698293d50
commit
6be2f090bc
@ -73,12 +73,23 @@ profile_no: false
|
||||
profile_name: Profile
|
||||
profile_username: Username
|
||||
profile_fname: First name
|
||||
pfofile_lname: Last name
|
||||
profile_lname: Last name
|
||||
profile_bio: Bio
|
||||
profile_gic: Group in common
|
||||
profile_verified: Verified
|
||||
profile_restricted: Restricted
|
||||
profile_type: Type
|
||||
# block
|
||||
block_des: Block an user.
|
||||
block_process: Processing . . .
|
||||
block_success: Success block
|
||||
block_exist: is already a blacklist.
|
||||
## unblock
|
||||
unblock_des: Unblock an user.
|
||||
unblock_process: Processing . . .
|
||||
unblock_success: Success unblock
|
||||
unblock_exist: isn't in a blacklist.
|
||||
|
||||
# avoid
|
||||
# ghost
|
||||
ghost_des: Toggles ghosting of chat, requires redis.
|
||||
@ -361,6 +372,13 @@ connection_hint: Connection information
|
||||
connection_country: Area
|
||||
connection_dc: Data center connected to
|
||||
connection_nearest_dc: nearest data center
|
||||
# pingdc
|
||||
pingdc_des: Test your server to the delay of the telegram data servers.
|
||||
pingdc_1: DC1(Miami FL,USA)
|
||||
pingdc_2: DC2(Amsterdam,NL)
|
||||
pingdc_3: DC3(Miami FL,USA)
|
||||
pingdc_4: DC4(Amsterdam,NL)
|
||||
pingdc_5: DC5(Singapore)
|
||||
# ping
|
||||
ping_des: Calculate the delay between the server running PagerMaid-Modify and the Telegram server.
|
||||
# topcloud
|
||||
|
@ -79,12 +79,22 @@ profile_no: 否
|
||||
profile_name: 用户简介
|
||||
profile_username: 道纹
|
||||
profile_fname: 名字
|
||||
pfofile_lname: 姓氏
|
||||
profile_lname: 姓氏
|
||||
profile_bio: 目前已知的情报
|
||||
profile_gic: 共同裙
|
||||
profile_verified: 官方认证
|
||||
profile_restricted: 受限制
|
||||
profile_type: 类型
|
||||
## block
|
||||
block_des: 拉黑一个用户
|
||||
block_process: 正在拉黑中 . . .
|
||||
block_success: 成功拉黑
|
||||
block_exist: 已存在黑名单中。
|
||||
## unblock
|
||||
unblock_des: 取消拉黑一个用户
|
||||
unblock_process: 正在取消拉黑中 . . .
|
||||
unblock_success: 成功取消拉黑
|
||||
unblock_exist: 不存在黑名单中。
|
||||
|
||||
# avoid
|
||||
## ghost
|
||||
@ -378,6 +388,13 @@ connection_hint: 连接信息
|
||||
connection_country: 地区
|
||||
connection_dc: 连接到的数据中心
|
||||
connection_nearest_dc: 最近的数据中心
|
||||
## pingdc
|
||||
pingdc_des: 测试您的服务器到 Telegram 数据服务器的延迟之间的延迟。
|
||||
pingdc_1: DC1(美国-迈阿密)
|
||||
pingdc_2: DC2(荷兰-阿姆斯特丹)
|
||||
pingdc_3: DC3(美国-迈阿密)
|
||||
pingdc_4: DC4(荷兰-阿姆斯特丹)
|
||||
pingdc_5: DC5(新加坡)
|
||||
## ping
|
||||
ping_des: 计算运行 PagerMaid-Modify 的服务器和 Telegram 服务器之间的延迟。
|
||||
## topcloud
|
||||
|
@ -73,12 +73,18 @@ profile_no: 否
|
||||
profile_name: 用戶介紹
|
||||
profile_username: 用戶名
|
||||
profile_fname: 名字
|
||||
pfofile_lname: 姓氏
|
||||
profile_lname: 姓氏
|
||||
profile_bio: 用戶介紹
|
||||
profile_gic: 共同的群組
|
||||
profile_verified: 官方認證
|
||||
profile_restricted: 受到限制
|
||||
profile_type: 類型
|
||||
# block
|
||||
block_des: 拉黑一個用戶
|
||||
block_process: 正在拉黑中 . . .
|
||||
block_success: 成功拉黑
|
||||
block_exist: 已存在黑名單中。
|
||||
|
||||
# avoid
|
||||
# ghost
|
||||
ghost_des: 開啟對話的自動已讀,需要Redis
|
||||
@ -361,6 +367,13 @@ connection_hint: 連接資訊
|
||||
connection_country: 地區
|
||||
connection_dc: 連到的DC
|
||||
connection_nearest_dc: 最近的DC
|
||||
# pingdc
|
||||
pingdc_des: 計算伺服器Delays
|
||||
pingdc_1: DC1(美國-邁阿密)
|
||||
pingdc_2: DC2(荷蘭-阿姆斯特丹)
|
||||
pingdc_3: DC3(美國-邁阿密)
|
||||
pingdc_4: DC4(荷蘭-阿姆斯特丹)
|
||||
pingdc_5: DC5(新加坡)
|
||||
# ping
|
||||
ping_des: 計算伺服器Delay
|
||||
# topcloud
|
||||
|
@ -7,6 +7,7 @@ from telethon.errors.rpcerrorlist import PhotoExtInvalidError, UsernameOccupiedE
|
||||
from telethon.tl.functions.account import UpdateProfileRequest, UpdateUsernameRequest
|
||||
from telethon.tl.functions.photos import DeletePhotosRequest, GetUserPhotosRequest, UploadProfilePhotoRequest
|
||||
from telethon.tl.functions.users import GetFullUserRequest
|
||||
from telethon.tl.functions.contacts import BlockRequest, UnblockRequest
|
||||
from telethon.tl.types import InputPhoto, MessageMediaPhoto, MessageEntityMentionName
|
||||
from struct import error as StructError
|
||||
from pagermaid import bot, log
|
||||
@ -158,8 +159,8 @@ async def profile(context):
|
||||
await context.edit(lang('profile_process'))
|
||||
if context.reply_to_msg_id:
|
||||
reply_message = await context.get_reply_message()
|
||||
user_id = reply_message.from_id
|
||||
target_user = await context.client(GetFullUserRequest(user_id))
|
||||
user = reply_message.from_id
|
||||
target_user = await context.client(GetFullUserRequest(user))
|
||||
else:
|
||||
if len(context.parameter) == 1:
|
||||
user = context.parameter[0]
|
||||
@ -170,7 +171,10 @@ async def profile(context):
|
||||
user = user_object.id
|
||||
if context.message.entities is not None:
|
||||
if isinstance(context.message.entities[0], MessageEntityMentionName):
|
||||
return await context.client(GetFullUserRequest(context.message.entities[0].user_id))
|
||||
user = context.message.entities[0].user_id
|
||||
else:
|
||||
await context.edit(f"{lang('error_prefix')}{lang('arg_error')}")
|
||||
return
|
||||
try:
|
||||
user_object = await context.client.get_entity(user)
|
||||
target_user = await context.client(GetFullUserRequest(user_object.id))
|
||||
@ -202,7 +206,7 @@ async def profile(context):
|
||||
f"{lang('profile_username')}: {username_system} \n" \
|
||||
f"ID: {target_user.user.id} \n" \
|
||||
f"{lang('profile_fname')}: {first_name} \n" \
|
||||
f"{lang('pfofile_lname')}: {last_name} \n" \
|
||||
f"{lang('profile_lname')}: {last_name} \n" \
|
||||
f"{lang('profile_bio')}: {biography} \n" \
|
||||
f"{lang('profile_gic')}: {target_user.common_chats_count} \n" \
|
||||
f"{lang('profile_verified')}: {verified} \n" \
|
||||
@ -254,3 +258,87 @@ async def profile(context):
|
||||
return
|
||||
except TypeError:
|
||||
await context.edit(caption)
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="block",
|
||||
description=lang('block_des'),
|
||||
parameters="<username/uid/reply>")
|
||||
async def block_user(context):
|
||||
""" Block an user. """
|
||||
user = None
|
||||
if len(context.parameter) > 1:
|
||||
await context.edit(f"{lang('error_prefix')}{lang('arg_error')}")
|
||||
return
|
||||
|
||||
await context.edit(lang('block_process'))
|
||||
if context.reply_to_msg_id:
|
||||
reply_message = await context.get_reply_message()
|
||||
user = reply_message.from_id.user_id
|
||||
else:
|
||||
if len(context.parameter) == 1:
|
||||
user = context.parameter[0]
|
||||
if user.isnumeric():
|
||||
user = int(user)
|
||||
else:
|
||||
user_object = await context.client.get_me()
|
||||
user = user_object.id
|
||||
if context.message.entities is not None:
|
||||
if isinstance(context.message.entities[0], MessageEntityMentionName):
|
||||
user = context.message.entities[0].user_id
|
||||
else:
|
||||
await context.edit(f"{lang('error_prefix')}{lang('arg_error')}")
|
||||
return
|
||||
result = None
|
||||
if not user:
|
||||
await context.edit(f"{lang('error_prefix')}{lang('arg_error')}")
|
||||
return
|
||||
try:
|
||||
result = await context.client(BlockRequest(id=user))
|
||||
except Exception:
|
||||
pass
|
||||
if result:
|
||||
await context.edit(f"{lang('block_success')} `{user}`")
|
||||
else:
|
||||
await context.edit(f"`{user}` {lang('block_exist')}")
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="unblock",
|
||||
description=lang('unblock_des'),
|
||||
parameters="<username/uid/reply>")
|
||||
async def unblock_user(context):
|
||||
""" Unblock an user. """
|
||||
user = None
|
||||
if len(context.parameter) > 1:
|
||||
await context.edit(f"{lang('error_prefix')}{lang('arg_error')}")
|
||||
return
|
||||
|
||||
await context.edit(lang('unblock_process'))
|
||||
if context.reply_to_msg_id:
|
||||
reply_message = await context.get_reply_message()
|
||||
user = reply_message.from_id.user_id
|
||||
else:
|
||||
if len(context.parameter) == 1:
|
||||
user = context.parameter[0]
|
||||
if user.isnumeric():
|
||||
user = int(user)
|
||||
else:
|
||||
user_object = await context.client.get_me()
|
||||
user = user_object.id
|
||||
if context.message.entities is not None:
|
||||
if isinstance(context.message.entities[0], MessageEntityMentionName):
|
||||
user = context.message.entities[0].user_id
|
||||
else:
|
||||
await context.edit(f"{lang('error_prefix')}{lang('arg_error')}")
|
||||
return
|
||||
result = None
|
||||
if not user:
|
||||
await context.edit(f"{lang('error_prefix')}{lang('arg_error')}")
|
||||
return
|
||||
try:
|
||||
result = await context.client(UnblockRequest(id=user))
|
||||
except Exception:
|
||||
pass
|
||||
if result:
|
||||
await context.edit(f"{lang('unblock_success')} `{user}`")
|
||||
else:
|
||||
await context.edit(f"`{user}` {lang('unblock_exist')}")
|
||||
|
@ -3,7 +3,8 @@
|
||||
from json import loads
|
||||
from os import remove, popen
|
||||
from datetime import datetime
|
||||
from speedtest import distance, Speedtest, ShareResultsConnectFailure, ShareResultsSubmitFailure, NoMatchedServers, SpeedtestBestServerFailure
|
||||
from speedtest import distance, Speedtest, ShareResultsConnectFailure, ShareResultsSubmitFailure, NoMatchedServers, \
|
||||
SpeedtestBestServerFailure
|
||||
from telethon import functions
|
||||
from platform import python_version, uname
|
||||
from wordcloud import WordCloud
|
||||
@ -16,6 +17,14 @@ from pagermaid.utils import execute, upload_attachment
|
||||
from pagermaid.listener import listener
|
||||
from pagermaid.utils import lang
|
||||
|
||||
DCs = {
|
||||
1: "149.154.175.50",
|
||||
2: "149.154.167.51",
|
||||
3: "149.154.175.100",
|
||||
4: "149.154.167.91",
|
||||
5: "91.108.56.130"
|
||||
}
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="sysinfo",
|
||||
description=lang('sysinfo_des'))
|
||||
@ -73,13 +82,13 @@ async def tty(context):
|
||||
async def status(context):
|
||||
database = lang('status_online') if redis_status() else lang('status_offline')
|
||||
text = (f"**{lang('status_hint')}** \n"
|
||||
f"{lang('status_name')}: `{uname().node}` \n"
|
||||
f"{lang('status_platform')}: `{platform}` \n"
|
||||
f"{lang('status_release')}: `{uname().release}` \n"
|
||||
f"{lang('status_python')}: `{python_version()}` \n"
|
||||
f"{lang('status_telethon')}: `{telethon_version.__version__}` \n"
|
||||
f"{lang('status_db')}: `{database}`"
|
||||
)
|
||||
f"{lang('status_name')}: `{uname().node}` \n"
|
||||
f"{lang('status_platform')}: `{platform}` \n"
|
||||
f"{lang('status_release')}: `{uname().release}` \n"
|
||||
f"{lang('status_python')}: `{python_version()}` \n"
|
||||
f"{lang('status_telethon')}: `{telethon_version.__version__}` \n"
|
||||
f"{lang('status_db')}: `{database}`"
|
||||
)
|
||||
await context.edit(text)
|
||||
dialogs = await context.client.get_dialogs()
|
||||
dialogs = len(dialogs)
|
||||
@ -158,6 +167,23 @@ async def connection(context):
|
||||
)
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="pingdc",
|
||||
description=lang('pingdc_des'))
|
||||
async def pingdc(context):
|
||||
""" Ping your or other data center's IP addresses. """
|
||||
data = []
|
||||
for dc in range(1, 6):
|
||||
result = await execute(f"ping -c 1 {DCs[dc]} | awk -F '/' " + "'END {print $5}'")
|
||||
data.append(result)
|
||||
await context.edit(
|
||||
f"{lang('pingdc_1')}: `{data[0]}ms`\n"
|
||||
f"{lang('pingdc_2')}: `{data[1]}ms`\n"
|
||||
f"{lang('pingdc_3')}: `{data[2]}ms`\n"
|
||||
f"{lang('pingdc_4')}: `{data[3]}ms`\n"
|
||||
f"{lang('pingdc_5')}: `{data[4]}ms`"
|
||||
)
|
||||
|
||||
|
||||
@listener(is_plugin=False, outgoing=True, command="ping",
|
||||
description=lang('ping_des'))
|
||||
async def ping(context):
|
||||
|
Loading…
Reference in New Issue
Block a user