🐛📝 Fix speedtest error and add new translations (#67)

* 🐛 修复 speedtest 报错

* 🐛 取消多开和被删消息的上报

* 📝 i18n
This commit is contained in:
Xtao_dada 2021-04-25 13:58:21 +08:00 committed by GitHub
parent e13b024b68
commit 00a5842faf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 101 additions and 104 deletions

View File

@ -1,5 +1,4 @@
# English
# main
web_TypeError: Oops ~ Web interface is configured to bind to an invalid address.
web_KeyError: Oops ~ Web interface configuration is missing in the config file.
@ -7,32 +6,29 @@ PhoneNumberInvalidError: Oops ~ The phone number entered is invalid. Please make
module: module
error: loading error
start: PagerMaid-Modify have started, type -help in any chat for help message.
# utils
msg_ValueError: Oops ~ No messages were successfully obtained!
isinstance: Oops ~ Length must be an integer!
# init
platform: Detected platform as
platform: Detected platform as
platform_load: proceeding to early load process of PagerMaid.
platform_unsupported: is not supported, please start PagerMaid on Linux or *BSD.
error_prefix: Oops ~
error_prefix: Oops ~
python: Please upgrade your python interpreter to at least version 3.6.
config_error: Oops ~ Please place a valid configuration file in the working directory.
save_id: The user ID is get successfully.
# modules_init
modules_init_loading_modules: Load built-in modules
modules_init_loading_plugins: Load plugin
# listener
command: command
has_reg: is already registered.
too_long: Oops ~ The output generated was too long and could not be presented.
run_error: Oops ~ An error occurred while executing this command.
report_error: Oops ~ report error.
use_method: Usage
# account
## username
# username
username_des: sets the username.
arg_error: Invalid argument.
username_exist: Username is taken.
@ -40,42 +36,40 @@ username_vaild: Invalid username.
username_set: Username have been updated.
username_cancel: Username has been unset.
username_whatset: Username has been set to
## name
# name
name_des: Alters the display name.
name_vaild: Invalid first name.
name_set: Display name is successfully altered.
name_whatset: Changed display name to
## pfp
# pfp
pfp_des: Set attachment of message replied to as profile picture.
pfp_process: Setting profile picture . . .
pfp_e_notp: Unable to parse attachment as image.
pfp_e_size: The image dimensions are smaller than minimum requirement.
pfp_e_img: An error occurred while the server is interpreting the command.
## bio
# bio
bio_des: Sets the biography to the string in the parameter.
bio_too_lang: Provided string is too long.
bio_set: Bio has been altered successfully.
bio_cancel: Bio has been unset.
bio_whatset: Bio has been set to
## rmpfp
# rmpfp
rmpfp_des: Deletes defined amount of profile pictures.
int: integer
rmpfp_p: Removed
rmpfp_l: profile picture(s).
## profile
# profile
profile_des: Shows user profile in a large message.
profile_process: Generating user profile summary . . .
profile_e_no: The specified user does not exist.
profile_e_nou: The username specified does not exist.
profile_e_nof: The UserID specified does not correspond to a user.
profile_e_nof: The UserID specified does not correspond to a user.
profile_e_long: The UserID specified have exceeded the integer limit.
profile_user: User
profile_noset: Not set.
profile_nobio: Not set.
profile_yes: True
profile_no: False
profile_yes: true
profile_no: false
profile_name: Profile
profile_username: Username
profile_fname: First name
@ -85,9 +79,8 @@ profile_gic: Group in common
profile_verified: Verified
profile_restricted: Restricted
profile_type: Type
# avoid
## ghost
# ghost
ghost_des: Toggles ghosting of chat, requires redis.
redis_dis: Redis is offline, cannot operate.
ghost_e_mark: Unable to set flag on self.
@ -96,41 +89,37 @@ ghost_set_l: added to ghosted chats.
ghost_cancel: removed from ghosted chats.
ghost_e_noexist: Current chat is not ghosted.
ghost_e_exist: Current chat is ghosted.
## deny
# deny
deny_des: Toggles denying of chat, requires redis.
deny_set: added to denied chats.
deny_cancel: removed from denied chats.
deny_e_noexist: Current chat is not denied.
deny_e_exist: Current chat is denied.
# help
help_des: Shows a list of commands or help string of a single command.
help_list: Commands
help_send: Issue
help_see: to view help for a specific command.*
help_source: Source
#qr
## genqr
# qr
# genqr
genqr_des: Generates a QR Code sticker from a specific string.
genqr_process: Generating QR code...
genqr_e_encode: Invalid characters in target string.
genqr_ok: Generated QR Code for
## parseqr
# parseqr
parseqr_des: Parse attachment of replied message as a QR Code and output results.
parseqr_nofile: There are no attachments in the message.
parseqr_content: Content
parseqr_e_noqr: Target is not a QR Code.
parseqr_log: Parsed QR Code with content
parseqr_log: Parsed QR Code with content
# captions
## convert
# convert
convert_des: Reply to an attachment message and convert it to image output
convert_process: Converting...
convert_no_file: Something went wrong. There seems to be no attachment in the reply message.
convert_error: Something went wrong, woooo~ An error occurred during the conversion.
## caption
# caption
caption_des: Add two lines of captions to the reply picture. The captions will be added to the top and bottom respectively. The captions need to be separated by commas.
caption_process: The image is being rendered...
caption_error_grammer: Something went wrong ~ Wrong grammar.
@ -138,29 +127,27 @@ caption_no_file: Something went wrong, woooo~ There is no attachment in the targ
caption_error: Something went wrong, woohoo~ An error occurred during the conversion.
caption_success1: caption successfully
caption_success2: Added to a picture.
## ocr
# ocr
ocr_des: Extract text from the reply image
ocr_psm_len_error: Oh, something went wrong...psm value is 0-13
ocr_processing: The picture is being processed, please wait...
ocr_no_file: Something went wrong. There is no attachment in the reply message.
ocr_no_result: Something went wrong ~ Please report this problem to the original author.
ocr_result_hint: The following is the extracted text
## highlight
# highlight
highlight_des: Generate a picture with syntax highlighting.
highlight_processing: The image is being rendered, please wait...
highlight_no_file: Something went wrong, woooo~ The target message could not be retrieved.
highlight_uploading: Uploading pictures...
## handle_failure
# handle_failure
handle_failure_error: Something went wrong oh woo woo ~ Please report this problem.
# clock
## time
# time
time_des: Display the time in a specific area. If the parameter is empty, the configuration value will be displayed by default.
time_parameters: <area>
time_time: time
# external
## translate
# translate
translate_des: Translate the target message into the specified language through Google Translate. (Support reply)
translate_parameters: <text>
translate_processing: The translation is being generated...
@ -190,80 +177,77 @@ fetchaudio_processing: Fetching audio...
fetchaudio_error_downloading: Something went wrong, woooo~ The original soundtrack failed to download.
fetchaudio_success: fetched an audio from the link
fetchaudio_link: link
# fun
## animate
# animate
animate_des: Use messages to animate text.
## teletype
# teletype
teletype_des: Make typing animation by editing the message. Will generate a lot of operation records!
## mock
# mock
mock_des: mock people through weird capital letters.
## widen
# widen
widen_des: widen each character in the string.
widen_already: This message has been widened.
## fox
# fox
fox_des: Use fox to make your message look less complete
## owo
# owo
owo_des: Convert the message to OwO.
## flip
# flip
flip_des: Flip the message.
## ship
# ship
ship_des: Generate random friends, and also support designated targets.
ship_processing: Generate base friends...
ship_BaseException: Something went wrong, woooo~ An error occurred while acquiring users.
ship_hint: Congratulations to both
## rng
# rng
rng_des: Generate a random string with a specific length.
## aaa
# aaa
aaa_des: send a message containing a and A
## asciiart
# asciiart
asciiart_des: Generate ASCII text for the specified string.
## tuxsay
# tuxsay
tuxsay_des: Generate an ASCII art message that looks like a penguin talking
## coin
# coin
coin_des: Throw a coin.
coin_processing: Throwing a coin...
coin_lost: I lost my coin
# help
## lang
# lang
lang_des: Switch language.
lang_change_to: The language has been switched to
lang_change_to: The language has been switched to
lang_reboot: Restarting.
lang_current_lang: The current language is
lang_all_lang: All available languages are
lang_current_lang: The current language is
lang_all_lang: "All available languages are "
# message
## id
# id
id_des: Get various information about a message.
id_hint: The following is the information of the reply message
id_is_bot_yes: yes
id_is_bot_yes: true
id_da: dead number
## uslog
# uslog
uslog_des: forward a message to the log.
uslog_success: Logged.
uslog_log_disable: Something went wrong, woooo~ Logging has been disabled.
## log
# log
log_des: silently forward a message to the log.
## re
# re
re_des: Reread the reply message in the current conversation. (Need to reply to a message)
re_parameters: <number of times>
re_too_big: oh oh something went wrong... this number is too big to provoke
re_arg_error: Oh, something went wrong...maybe the parameter contains symbols other than numbers
not_reply: Something went wrong ~ You don't seem to reply to a message.
## leave
# leave
leave_res: Say "goodbye" and leave the session.
leave_bye: You are a waste of my time, goodbye.
leave_not_group: Something went wrong ohh~ The current chat does not seem to be a group chat.
## meter2feet
# meter2feet
m2f_des: Convert meters to feet.
m2f_get: will
m2f_meter: meter
m2f_convert_to: convert to
m2f_feet: feet
## feet2meter
# feet2meter
f2m_des: Convert feet to meters.
## hitokoto
# hitokoto
hitokoto_des: A word of the day
hitokoto_type_anime: animation
hitokoto_type_manga: manga
@ -277,9 +261,8 @@ hitokoto_type_poem: poem
hitokoto_type_netease_music: Netease Cloud
hitokoto_type_philosophy: philosophy
hitokoto_type_meme: trembling
# plugin
## apt
# apt
apt_des: Used to manage plugins installed to PagerMaid-Modify.
apt_parameters: "{update|search|show|status|install|remove|enable|disable|upload} <plugin name/file>"
apt_processing: Installing plugins...
@ -322,34 +305,32 @@ apt_plugin_maintainer: Author
apt_plugin_size: size
apt_plugin_support: support period
apt_plugin_des_short: description
# prune
## prune
# prune
prune_des: Replying to a message with this command will delete all messages between the latest message and the message. Limit, 1000 messages based on message ID, more than 1000 messages may trigger the limit of deleting messages too quickly. (Non-group administrators only delete their own messages)
prune_hint1: Deleted in bulk
prune_hint2: messages.
## selfprune
# selfprune
sp_des: delete a specific number of messages sent by you in the current conversation. Limit, 1000 messages based on message ID, more than 1000 may trigger the limit of deleting messages too quickly. Non-administrators cannot delete the group message. (Reverse order) When the number is large enough, all messages can be deleted.
sp_parameters: <quantity>
sp_hint: self-sent
## yourprune
# yourprune
yp_des: delete the current conversation you reply to a specific number of messages sent by the user. Limit, 1000 messages based on message ID, more than 1000 may trigger the limit of deleting messages too quickly. (Reverse order, need to delete message permission) When the number is large enough, all messages can be deleted.
yp_hint: Reply to what the user sent
## del
# del
del_des: Delete the message you replied to in the current conversation. (Need to reply to a message)
del_notification: A message was deleted.
del_BadRequestError: Something went wrong, woooo~ I dont have permission to delete this message.
## send_prune_notify
del_BadRequestError: Something went wrong, woooo~ I don
# send_prune_notify
spn_deleted: deleted
# status
## sysinfo
# sysinfo
sysinfo_des: Retrieve system information through neofetch.
sysinfo_loading: Loading system information...
## fortune
# fortune
fortune_des: read fortune cookies information.
fortune_not_exist: Something went wrong, woooo~ There are no fortune cookies on this system
## fbcon
# fbcon
fbcon_des: Take a screenshot of the currently bound frame buffer console.
fbcon_processing: Taking a screenshot of the frame buffer console...
fbcon_no_fbdump: Something went wrong ~ woof ~ fbdump is not installed on this system
@ -357,7 +338,7 @@ fbcon_no_ImageMagick: Something went wrong, woooo ~ ImageMagick is not installed
fbcon_no_permission: Something went wrong. The user running PagerMaid-Modify is not in the video group.
fbcon_caption: A screenshot of the bound frame buffer.
fbcon_error: Something went wrong ~ The file generation failed due to an unexpected error. Please make sure that the apt packages fbcat and imagemagick have been installed, and your machine has a graphics card.
## status
# status
status_des: Output the running status of PagerMaid-Modify.
status_online: online
status_offline: offline
@ -369,25 +350,26 @@ status_python: Python version
status_telethon: Telethon version
status_db: database status
status_dialogs: total number of conversations
## speedtest
# speedtest
speedtest_des: Execute the speedtest script and send the result.
speedtest_processing: Execute test scripts...
## connection
speedtest_ServerFailure: Unable to determine the best server.
speedtest_ConnectFailure: Connection failure.
# connection
connection_des: Display the connection information between the server running PagerMaid-Modify and the Telegram server.
connection_hint: connection information
connection_country: country
connection_dc: Data center connected to
connection_nearest_dc: nearest data center
## ping
# ping
ping_des: Calculate the delay between the server running PagerMaid-Modify and the Telegram server.
## topcloud
# topcloud
topcloud_des: Generate a word cloud picture of resource usage.
topcloud_processing: generating pictures...
topcloud_caption: The running process.
topcloud_success: A word cloud picture of resource usage is generated.
# sticker
## sticker
# sticker
sticker_des: Collect the replied images/stickers as stickers, and specify emoji through parameters to set a non-default emoji.
sticker_processing: Collecting images/stickers...
sticker_downloading: Downloading the picture...
@ -403,36 +385,34 @@ sticker_this: this
sticker_pack: sticker pack
sticker_another_running: Another command is adding a sticker, trying again
sticker_no_pack_exist_creating: The sticker pack does not exist, it is being created...
## upload_sticker
# upload_sticker
us_animated_uploading: Upload animations...
us_static_uploading: Uploading pictures...
# system
## sh
# sh
sh_des: remotely execute Shell commands on Telegram.
sh_parameters: <command>
sh_channel: Something went wrong ~ The current PagerMaid-Modify configuration prohibits the execution of Shell commands in the channel.
sh_success: execute Shell commands remotely
## restart
# restart
restart_des: Restart PagerMaid-Modify
restart_processing: Try to restart PagerMaid-Modify.
restart_log: PagerMaid-Modify restarts.
## trace
# trace
trace_des: Trace the redirection of the URL.
trace_processing: Tracking redirection...
trace_over128: Something went wrong, woooo~ More than 128 redirects, aborting!
trace_re: redirect
trace_http_error: Something went wrong ~ There was a problem when sending the HTTP request.
## chat
# chat
chat_des: Join the Pagermaid-Modify user group.
chat_message: Hello everyone, I am a newcomer.
chat_already_join1: You have already successfully joined
chat_already_join2: User group.
chat_error: Something went wrong ~ Please try to manually add @PagerMaid_Modify
chat_join_success: You have successfully joined
#update
## update
# update
# update
update_des: Check for updates from remote sources and install them to PagerMaid-Modify.
update_processing: Checking the remote source for update...
update_platform_version: system version number
@ -455,4 +435,4 @@ update_success: Update successfully
update_failed: update failed
update_auto_upgrade_git_failed_ubuntu: It is detected that your system is Ubuntu or Debain. Try to upgrade git automatically but failed. Please upgrade manually.
update_auto_upgrade_git_failed_cent: It is detected that your system is CentOS, try to upgrade git automatically but failed, please upgrade manually.
update_auto_upgrade_git_hint: Your git version is too low and has tried to automatically upgrade for you. If you are reminded of this error again, please upgrade manually.
update_auto_upgrade_git_hint: Your git version is too low and has tried to automatically upgrade for you. If you are reminded of this error again, please upgrade manually.

View File

@ -370,6 +370,8 @@ status_dialogs: 对话总数
## speedtest
speedtest_des: 执行 speedtest 脚本并发送结果。
speedtest_processing: 执行测试脚本 . . .
speedtest_ServerFailure: 无法确定最佳服务器。。。
speedtest_ConnectFailure: speedtest API 服务器连接失败。。。
## connection
connection_des: 显示运行 PagerMaid-Modify 的服务器和 Telegram 服务器之间的连接信息。
connection_hint: 连接信息
@ -453,4 +455,4 @@ update_success: 更新成功
update_failed: 更新失败
update_auto_upgrade_git_failed_ubuntu: 检测到您的系统是Ubuntu或Debain尝试自动升级git但失败,请手动升级.
update_auto_upgrade_git_failed_cent: 检测到您的系统是CentOS尝试自动升级git但失败,请手动升级.
update_auto_upgrade_git_hint: 您的git版本过低,已尝试为您自动升级. 如再次提醒此错误,请手动升级.
update_auto_upgrade_git_hint: 您的git版本过低,已尝试为您自动升级. 如再次提醒此错误,请手动升级.

View File

@ -1,4 +1,4 @@
# Chinese (Simplified)
# Chinese (TW)
# main
web_TypeError: ErrorWeb 介面綁定了一個無效網址。
web_KeyError: Error設定檔缺少Web介面配置。
@ -353,6 +353,8 @@ status_dialogs: 聊天總數
# speedtest
speedtest_des: 執行Speedtest腳本然後發送結果
speedtest_processing: 執行腳本
speedtest_ServerFailure: Unable to determine the best server.
speedtest_ConnectFailure: Connection failure.
# connection
connection_des: 顯示伺服器和Telegram之間的資訊。
connection_hint: 連接資訊

View File

@ -16,6 +16,7 @@ from logging import getLogger, INFO, DEBUG, ERROR, StreamHandler, basicConfig
from distutils2.util import strtobool
from coloredlogs import ColoredFormatter
from telethon import TelegramClient
from telethon.errors.rpcerrorlist import MessageNotModifiedError, MessageIdInvalidError
persistent_vars = {}
module_dir = __path__[0]
@ -149,6 +150,10 @@ def before_send(event, hint):
return None
elif exc_info and isinstance(exc_info[0], CancelledError):
return None
elif exc_info and isinstance(exc_info[0], MessageNotModifiedError):
return None
elif exc_info and isinstance(exc_info[0], MessageIdInvalidError):
return None
if time() <= report_time + 30:
report_time = time()
return None

View File

@ -2,7 +2,7 @@
from os import remove, popen
from datetime import datetime
from speedtest import Speedtest
from speedtest import Speedtest, ShareResultsConnectFailure, ShareResultsSubmitFailure, SpeedtestBestServerFailure
from telethon import functions
from platform import python_version, uname
from wordcloud import WordCloud
@ -92,10 +92,18 @@ async def speedtest(context):
""" Tests internet speed using speedtest. """
await context.edit(lang('speedtest_processing'))
test = Speedtest()
test.get_best_server()
try:
test.get_best_server()
except SpeedtestBestServerFailure:
await context.edit(lang('speedtest_ServerFailure'))
return
test.download()
test.upload()
test.results.share()
try:
test.results.share()
except ShareResultsConnectFailure or ShareResultsSubmitFailure:
await context.edit(lang('speedtest_ConnectFailure'))
return
result = test.results.dict()
des = (
f"**Speedtest** \n"