Skip to content

Commit

Permalink
Merge branch 'dev/quickconfirm' into matrix/issue1046
Browse files Browse the repository at this point in the history
  • Loading branch information
OasisAkari authored Dec 20, 2023
2 parents 282445a + d8e6733 commit 5842f2a
Show file tree
Hide file tree
Showing 256 changed files with 2,304 additions and 3,553 deletions.
194 changes: 194 additions & 0 deletions LOCALES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
# 目录
- [简介](#简介)
- [文件位置](#文件位置)
- [语言文件格式](#语言文件格式)
- [排版](#排版)
- [空格](#空格)
- [中英文之间需要增加空格](#中英文之间需要增加空格)
- [中文与数字之间需要增加空格](#中文与数字之间需要增加空格)
- [数字与单位之间不加空格](#数字与单位之间不加空格)
- [全角标点与其他字符之间不加空格](#全角标点与其他字符之间不加空格)
- [变量与中文之间需要增加空格](#变量与中文之间需要增加空格)
- [标点符号](#标点符号)
- [不要重复使用标点符号](#不要重复使用标点符号)
- [简体中文不要使用直角引号](#简体中文不要使用直角引号)
- [英文不要使用弯引号](#英文不要使用弯引号)
- [英文省略号使用三个点](#英文省略号使用三个点)
- [全角和半角](#全角和半角)
- [使用全角中文标点](#使用全角中文标点)
- [数字和英文使用半角字符](#数字和英文使用半角字符)
- [遇到完整的英文成句内容中使用半角标点](#遇到完整的英文成句内容中使用半角标点)
- [名词](#名词)
- [专有名词使用正确的大小写](#专有名词使用正确的大小写)
- [不要使用非正式的缩写](#不要使用非正式的缩写)
- [不同地区的中文使用对应的地区词](#不同地区的中文使用对应的地区词)
- [报告问题](#报告问题)

# 简介
本规范文件旨在确保项目中的多语言文本一致性和格式规范。请遵循以下内容以保持代码库中的多语言资源的统一性。

# 文件位置
请将语言文件放置在 `/locales` 目录中,并以语言代码命名为 JSON 文件。

根路径下的目录用于放置全局字符串,模块下的目录用于放置对应专用的模块字符串。

原则上,模块字符串和对应模块须对应,若模块之间存在关联则可以例外,否则请考虑转为全局字符串。

# 语言文件格式
请确保键名与字符串一一对应,不得嵌套。

**全局字符串的命名方式**`字符串类别.用途`

**模块字符串的命名方式**`模块名称.字符串类别.命令名称.用途`

使用 `${变量名}` 表示变量,变量名必须使用英文,不能使用空格和特殊符号,如需分隔则使用下划线代替。

# 排版
> 本文部分参照[中文文案排版指北](https://github.com/sparanoid/chinese-copywriting-guidelines),内容可能有出入。
## 空格
### 中英文之间需要增加空格
正确:
> 在 IBM 的研究中,他们利用 AI 技术开发了一种先进的语音识别系统。
错误:
> 在IBM的研究中,他们利用AI技术开发了一种先进的语音识别系统。
例外:专有名词、商品名等词语,按照约定俗成的格式书写。

### 中文与数字之间需要增加空格
正确:
> 今年的全球汽车销售量达到了 8000 万辆。
错误:
> 今年的全球汽车销售量达到了8000万辆。
### 数字与单位之间不加空格
正确:
> 我家的光纤入户宽带有 10Gbps,SSD 一共有 10TB。
> 这个城市每年平均降雨量为 1200mm。
>
> 角度为 90° 的角,就是直角。
错误:
>我家的光纤入户宽带有 10 Gbps,SSD 一共有 20 TB。
> 这个城市每年平均降雨量为 1200 mm。
>
> 角度为 90 ° 的角,就是直角。
### 全角标点与其他字符之间不加空格
正确:
> 刚刚买了一部 iPhone,好开心!
错误:
> 刚刚买了一部 iPhone ,好开心!
### 变量与中文之间需要增加空格
一般情况下,变量的输入为英文或数字,故变量与中文之间加入空格。

正确:
> 你扔了一块石头,漂了 ${count} 下。
错误:
> 你扔了一块石头,漂了${count}下。
例外:如果变量的输入一定为中文,则不加空格。

## 标点符号
### 不要重复使用标点符号
虽然重复使用标点符号是被允许的行为,但是请别这样做。

正确:
> 德国队竟然战胜了巴西队!
错误:
> 德国队竟然战胜了巴西队!!!
### 简体中文不要使用直角引号
直角引号并不符合简体中文使用者的使用习惯。

正确:
> “老师,‘有条不紊’的‘紊’是什么意思?”
错误:
> 「老师,『有条不紊』的『紊』是什么意思?」
### 英文不要使用弯引号
中文弯引号和英文弯引号属于同一个字符,如果使用弯引号反而会造成阅读问题,请使用直引号 `"`

正确:
> "Success is not final, failure is not fatal: It is the courage to continue that counts."
错误:
> “Success is not final, failure is not fatal: It is the courage to continue that counts.”
### 英文省略号使用三个点
同上,请使用三个点 `...`

正确:
> In the serene moonlit night, whispers of ancient tales lingered, echoing through the stillness of time...
错误:
> In the serene moonlit night, whispers of ancient tales lingered, echoing through the stillness of time…
## 全角和半角
### 使用全角中文标点
正确:
> 嗨!你知道嘛?今天前台的小妹跟我说“喵”了哎!
错误:
> 嗨! 你知道嘛? 今天前台的小妹跟我说 "喵" 了哎!
>
> 嗨!你知道嘛?今天前台的小妹跟我说"喵"了哎!
### 数字和英文使用半角字符
正确:
> 这件蛋糕只卖 200 元。
错误:
> 这件蛋糕只卖 200 元。
### 遇到完整的英文成句内容中使用半角标点
正确:
> 乔布斯那句话是怎么说的?“Stay hungry, stay foolish.”
错误:
> 乔布斯那句话是怎么说的?“Stay hungry, stay foolish。”
## 名词
### 专有名词使用正确的大小写
正确:
> 使用 GitHub 登录
错误:
> 使用 Github 登录
>
> 使用 gitHub 登录
>
> 使用 github 登录
>
> 使用 GITHUB 登录
### 不要使用非正式的缩写
正确:
> 我们需要一位熟悉 JavaScript、HTML5,至少理解一种框架(如 Backbone.js、AngularJS、React 等)的前端开发者。
错误:
> 我们需要一位熟悉 Js、h5,至少理解一种框架(如 backbone、angular、RJS 等)的 FED。

### 不同地区的中文使用对应的地区词
不要在繁体中文中使用“视频”等错误的地区词,认真的。

正确:
> 輸入影片編號取得對應資訊。
错误:
> 輸入視頻編號獲得相應信息。
# 报告问题
与简体中文翻译有关的问题可直接使用 [Issue](https://github.com/Teahouse-Studios/akari-bot/issues/new) 报告。

简体中文以外的所有语言由机器人 @Hldbot 维护,相关问题请移步 [Crowdin](https://crowdin.com/project/akari-bot) 报告。
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

#### QQ

~~目前 QQ 上稳定运行的小可实例为小可三号机。由于腾讯风控问题,请[在此提交](https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=New&template=add_new_group.yaml&title=%5BNEW%5D%3A+)入群申请。~~
~~目前 QQ 上稳定运行的小可实例为小可三号机。由于腾讯风控问题,请[在此提交](https://github.com/Teahouse-Studios/akari-bot/issues/new?assignees=OasisAkari&labels=New&template=add_new_group.yaml&title=%5BNEW%5D%3A+)入群申请。~~

~~QQ 频道的测试版支持也请在上方链接申请。~~ 我们正在进行 QQ 频道官方机器人入驻,未来可能会成为官方认证的机器人。

Expand All @@ -51,7 +51,7 @@

你可以[参考这里](./DEPLOY.md)来进行尝试搭建。

若遇到问题,可以通过 [Issue](https://github.com/Teahouse-Studios/bot/issues/new) 或其他方式咨询开发者。
若遇到问题,可以通过 [Issue](https://github.com/Teahouse-Studios/akari-bot/issues/new) 或其他方式咨询开发者。

### 多语言

Expand Down
Binary file modified assets/maimai/static/mai/default_pic/UI_CMN_DXRating_S_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/maimai/static/mai/default_pic/UI_CMN_DXRating_S_02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/maimai/static/mai/default_pic/UI_CMN_DXRating_S_03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/maimai/static/mai/default_pic/UI_CMN_DXRating_S_04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/maimai/static/mai/default_pic/UI_CMN_DXRating_S_05.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/maimai/static/mai/default_pic/UI_CMN_DXRating_S_06.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/maimai/static/mai/default_pic/UI_CMN_DXRating_S_07.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/maimai/static/mai/default_pic/UI_CMN_DXRating_S_08.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/maimai/static/mai/default_pic/UI_CMN_DXRating_S_09.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/maimai/static/mai/default_pic/UI_CMN_DXRating_S_10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/maimai/static/mai/default_pic/UI_CMN_MiniDialog_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/maimai/static/mai/default_pic/UI_CMN_Name_DX.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/maimai/static/mai/default_pic/UI_CMN_Shougou_Rainbow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/maimai/static/mai/default_pic/UI_GAM_Rank_A.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/maimai/static/mai/default_pic/UI_GAM_Rank_AA.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/maimai/static/mai/default_pic/UI_GAM_Rank_AAA.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/maimai/static/mai/default_pic/UI_GAM_Rank_B.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/maimai/static/mai/default_pic/UI_GAM_Rank_BB.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/maimai/static/mai/default_pic/UI_GAM_Rank_BBB.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/maimai/static/mai/default_pic/UI_GAM_Rank_C.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/maimai/static/mai/default_pic/UI_GAM_Rank_D.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/maimai/static/mai/default_pic/UI_GAM_Rank_S.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/maimai/static/mai/default_pic/UI_GAM_Rank_SS.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/maimai/static/mai/default_pic/UI_GAM_Rank_SSS.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/maimai/static/mai/default_pic/UI_GAM_Rank_SSSp.png
Binary file modified assets/maimai/static/mai/default_pic/UI_GAM_Rank_SSp.png
Binary file modified assets/maimai/static/mai/default_pic/UI_GAM_Rank_Sp.png
Binary file modified assets/maimai/static/mai/default_pic/UI_MSS_MBase_Icon_AP_S.png
Binary file modified assets/maimai/static/mai/default_pic/UI_MSS_MBase_Icon_APp_S.png
Binary file modified assets/maimai/static/mai/default_pic/UI_MSS_MBase_Icon_FC_S.png
Binary file modified assets/maimai/static/mai/default_pic/UI_MSS_MBase_Icon_FCp_S.png
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file modified assets/maimai/static/mai/default_pic/UI_NUM_Drating_0.png
Binary file modified assets/maimai/static/mai/default_pic/UI_NUM_Drating_1.png
Binary file modified assets/maimai/static/mai/default_pic/UI_NUM_Drating_2.png
Binary file modified assets/maimai/static/mai/default_pic/UI_NUM_Drating_3.png
Binary file modified assets/maimai/static/mai/default_pic/UI_NUM_Drating_4.png
6 changes: 3 additions & 3 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def enqueue_output(out, queue):

def init_bot():
base_superuser = Config('base_superuser')
if base_superuser is not None:
if base_superuser:
if isinstance(base_superuser, str):
base_superuser = [base_superuser]
for bu in base_superuser:
Expand Down Expand Up @@ -143,7 +143,7 @@ def run_bot():
raise RestartBot

# break when all processes are done.
if all(p.poll() is not None for p in runlst):
if all(p.poll() for p in runlst):
break

sleep(0.0001)
Expand All @@ -154,7 +154,7 @@ def run_bot():
logger.remove()
logger.add(sys.stderr, format='{message}', level="INFO")
query_dbver = session.query(DBVersion).first()
if query_dbver is None:
if not query_dbver:
session.add_all([DBVersion(value=str(BotDBUtil.database_version))])
session.commit()
query_dbver = session.query(DBVersion).first()
Expand Down
4 changes: 2 additions & 2 deletions bots/aiocqhttp/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class GuildAccountInfo:

@bot.on_message('guild')
async def _(event):
if GuildAccountInfo.tiny_id is None:
if not GuildAccountInfo.tiny_id:
profile = await bot.call_action('get_guild_service_profile')
GuildAccountInfo.tiny_id = profile['tiny_id']
tiny_id = event.user_id
Expand Down Expand Up @@ -144,7 +144,7 @@ async def _(event: Event):
if not Config('allow_bot_auto_approve_group_invite'):
await bot.send_private_msg(user_id=event.user_id,
message='你好!本机器人暂时不主动同意入群请求。\n'
f'请至{Config("qq_join_group_application_link")}申请入群。')
f'请至https://github.com/Teahouse-Studios/bot/issues/new?assignees=OasisAkari&labels=New&template=add_new_group.yaml&title=%5BNEW%5D%3A+申请入群。')
else:
return {'approve': True}

Expand Down
41 changes: 25 additions & 16 deletions bots/aiocqhttp/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from bots.aiocqhttp.client import bot
from bots.aiocqhttp.info import client_name
from config import Config
from core.builtins import Bot, base_superuser_list, command_prefix, ErrorMessage, Image, Plain, Temp, Voice
from core.builtins import Bot, base_superuser_list, command_prefix, ErrorMessage, Image, Plain, Temp, Voice, MessageTaskManager
from core.builtins.message import MessageSession as MessageSessionT
from core.builtins.message.chain import MessageChain
from core.exceptions import SendMessageFailed
Expand Down Expand Up @@ -88,26 +88,30 @@ class Feature:
quote = True

async def send_message(self, message_chain, quote=True, disable_secret_check=False,
allow_split_image=True) -> FinishedSession:
allow_split_image=True,
callback=None) -> FinishedSession:

message_chain = MessageChain(message_chain)
message_chain_assendable = message_chain.as_sendable(self, embed=False)

if (self.target.target_from == 'QQ|Group' and Temp.data.get('lagrange_status', False) and not
self.tmp.get('enforce_send_by_master_client', False)):
self.tmp.get('enforce_send_by_master_client', False) and not callback):
lagrange_available_groups = Temp.data.get('lagrange_available_groups', [])
if int(self.session.target) in lagrange_available_groups:
choose = random.randint(0, 1)
Logger.debug(f'choose: {choose}')
if choose:
can_sends = []
cant_sends = []
for x in message_chain_assendable:
if isinstance(x, (Plain, Image)):
can_sends.append(x)
if isinstance(x, Voice):
cant_sends.append(x)
message_chain_assendable.remove(x)
if can_sends:
if message_chain_assendable:
await JobQueue.send_message('Lagrange', self.target.target_id,
MessageChain(can_sends).to_list())
if not message_chain_assendable:
MessageChain(message_chain_assendable).to_list())
if cant_sends:
self.tmp['enforce_send_by_master_client'] = True
await self.send_message(MessageChain(cant_sends))
return FinishedSession(self, 0, [{}])
else:
Logger.debug(f'Do not use lagrange since some conditions are not met.\n{self.target.target_from} '
Expand All @@ -124,12 +128,12 @@ async def send_message(self, message_chain, quote=True, disable_secret_check=Fal
if isinstance(x, Plain):
msg = msg + MessageSegment.text(('\n' if count != 0 else '') + x.text)
elif isinstance(x, Image):
msg = msg + MessageSegment.image(Path(await x.get()).as_uri())
msg = msg + MessageSegment.image('base64://' + await x.get_base64())
elif isinstance(x, Voice):
if self.target.target_from != 'QQ|Guild':
msg = msg + MessageSegment.record(file=Path(x.path).as_uri())
count += 1
Logger.info(f'[Bot] -> [{self.target.target_id}]: {msg}')
Logger.info(f'[Bot] -> [{self.target.target_id}]: {message_chain_assendable}')
if self.target.target_from == 'QQ|Group':
try:
send = await bot.send_group_msg(group_id=self.session.target, message=msg)
Expand Down Expand Up @@ -170,6 +174,8 @@ async def send_message(self, message_chain, quote=True, disable_secret_check=Fal
return FinishedSession(self, 0, [{}])
else:
raise e
if callback:
MessageTaskManager.add_callback(send['message_id'], callback)
return FinishedSession(self, send['message_id'], [send])

async def check_native_permission(self):
Expand Down Expand Up @@ -343,11 +349,14 @@ async def post_(fetch_: Bot.FetchedSession):
Temp.data['waiting_for_send_group_message'].append({'fetch': fetch_, 'message': message,
'i18n': i18n, 'kwargs': kwargs})
else:
if i18n:
await fetch_.send_direct_message(fetch_.parent.locale.t(message, **kwargs))
msgchain = message
if isinstance(message, str):
if i18n:
msgchain = MessageChain([Plain(fetch_.parent.locale.t(message, **kwargs))])
else:
msgchain = MessageChain([Plain(message)])

else:
await fetch_.send_direct_message(message)
await fetch_.send_direct_message(msgchain)
if _tsk:
_tsk = []
if enable_analytics:
Expand Down Expand Up @@ -376,7 +385,7 @@ async def post_(fetch_: Bot.FetchedSession):
except Exception:
Logger.error(traceback.format_exc())

if user_list is not None:
if user_list:
for x in user_list:
await post_(x)
else:
Expand Down
2 changes: 1 addition & 1 deletion bots/aiogram/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
async def msg_handler(message: types.Message):
target_id = f'Telegram|{message.chat.type}|{message.chat.id}'
reply_id = None
if message.reply_to_message is not None:
if message.reply_to_message:
reply_id = message.reply_to_message.message_id
msg = MessageSession(MsgInfo(target_id=target_id,
sender_id=f'Telegram|User|{message.from_user.id}',
Expand Down
Loading

0 comments on commit 5842f2a

Please sign in to comment.