Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
DoroWolf committed Feb 5, 2025
1 parent 99aca1e commit fba70b6
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 52 deletions.
2 changes: 1 addition & 1 deletion bots/aiocqhttp/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from core.builtins import PrivateAssets
from core.builtins.utils import command_prefix
from core.builtins.temp import Temp
from core.config import Config, CFGManager
from core.config import Config
from core.constants.default import issue_url_default, ignored_sender_default, qq_host_default
from core.constants.info import Info
from core.constants.path import assets_path
Expand Down
31 changes: 11 additions & 20 deletions bots/aiocqhttp/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,33 +362,24 @@ async def fake_forward_msg(self, nodelist):
async def msgchain2nodelist(
self,
msg_chain_list: List[MessageChain],
name: Optional[str] = None,
) -> list[Dict]:
"""将消息链列表转换为节点列表。"""
sender_name: Optional[str] = None,
) -> List[dict]:
node_list = []
for message in msg_chain_list:
content = ''
for element in message.as_sendable():
if all(
(
isinstance(element, PlainElement),
message.as_sendable().index(element) == len(message.as_sendable()) - 1
or len(message.as_sendable()) == 0,
)
):
content += element.text
elif isinstance(element, ImageElement):
content += f"[CQ:image,file=base64://{element.get_base64()}]\n"
elif isinstance(element, VoiceElement):
content += '[Voice]'
else:
content += element.text + '\n'
msgchain = message.as_sendable()
for x in msgchain:
if isinstance(x, PlainElement):
content += x.text + '\n'
elif isinstance(x, ImageElement):
content += f"[CQ:image,file=base64://{x.get_base64()}]\n"

template = {
"type": "node",
"data": {
"nickname": name if name else Temp().data.get("qq_nickname"),
"nickname": sender_name if sender_name else Temp().data.get("qq_nickname"),
"user_id": str(Temp().data.get("qq_account")),
"content": content
"content": content.strip()
}
}
node_list.append(template)
Expand Down
11 changes: 4 additions & 7 deletions core/builtins/message/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,12 +333,12 @@ async def fake_forward_msg(self, nodelist: List[Dict[str, Union[str, Any]]]):
"""
raise NotImplementedError

async def msgchain2nodelist(self, msg_chain_list: List[MessageChain], name: Optional[str] = None,
async def msgchain2nodelist(self, msg_chain_list: List[MessageChain], sender_name: Optional[str] = None,
) -> list[Dict]:
"""
用于将消息链列表转换为节点列表。(QQ)
:param msg_chain_list: 消息链列表,详情参考小可文档
:param name: 用于指定发送者名称。
用于将消息链列表转换为节点列表(QQ)。
:param msg_chain_list: 消息链列表。
:param sender_name: 用于指定发送者名称。
"""
raise NotImplementedError

Expand Down Expand Up @@ -616,9 +616,6 @@ class Feature:
typing = False
wait = False

async def msgchain2nodelist(self, msgchain_lst):
pass


class FetchedSession:
"""
Expand Down
2 changes: 0 additions & 2 deletions modules/wiki/locales/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"wiki.help.wiki_inline.page": "Enter a title within [[ ]] to automatically query the page.",
"wiki.help.wiki_inline.template": "Enter a title within {{ }} to automatically query the template.",
"wiki.help.wiki_inline.url": "Send the URL of the wiki page to generate the Infobox image.",
"wiki.message.ab.qq.link.title": "Abuse Log URL",
"wiki.message.ab.qq.slice": "${user} trigerred an abuse filter, performing the action \"${action}\" on ${title}.\nActions Taken: ${result}\nFilter Description: ${filter_name}",
"wiki.message.ab.qq.title": "Abuse Log",
"wiki.message.ab.slice": "${time} - ${user} trigerred an abuse filter, performing the action \"${action}\" on ${title}.\nActions Taken: ${result}\nFilter Description: ${filter_name}",
Expand Down Expand Up @@ -108,7 +107,6 @@
"wiki.message.rc.params.tag": "Tag: ",
"wiki.message.rc.params.target_title": "Target Title: ",
"wiki.message.rc.qq.link.prompt": "Tip: Copy and paste any of the messages below into the chat window to get a screenshot of the details of this change.",
"wiki.message.rc.qq.link.title": "Recent Changes URL",
"wiki.message.rc.qq.title": "Recent Changes",
"wiki.message.redirect": "(Redirect [${title}] -> [${redirected_title}])",
"wiki.message.redirect.autofix": "(Specified [${title}] redirected to [${redirected_title}].)",
Expand Down
2 changes: 0 additions & 2 deletions modules/wiki/locales/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"wiki.help.wiki_inline.page": "在 [[ ]] 内输入标题以自动查询页面。",
"wiki.help.wiki_inline.template": "在 {{ }} 内输入标题以自动查询模板。",
"wiki.help.wiki_inline.url": "发送 Wiki 页面的 URL 以生成 Infobox 图片。",
"wiki.message.ab.qq.link.title": "滥用过滤器日志地址",
"wiki.message.ab.qq.slice": "${user} 在 ${title} 执行操作“${action}”时触发了过滤器。\n过滤器描述:${filter_name}\n采取的行动:${result}",
"wiki.message.ab.qq.title": "滥用过滤器日志",
"wiki.message.ab.slice": "${time} - ${user} 在 ${title} 执行操作“${action}”时触发了过滤器。\n过滤器描述:${filter_name}\n采取的行动:${result}",
Expand Down Expand Up @@ -107,7 +106,6 @@
"wiki.message.rc.params.tag": "标签:",
"wiki.message.rc.params.target_title": "目标标题:",
"wiki.message.rc.qq.link.prompt": "提示:复制粘贴下面的任一消息到聊天窗口发送可获取此次更改详细信息的截图。",
"wiki.message.rc.qq.link.title": "最近更改地址",
"wiki.message.rc.qq.title": "最近更改日志",
"wiki.message.redirect": "(重定向 [${title}] -> [${redirected_title}])",
"wiki.message.redirect.autofix": "(已指定 [${title}] 更正为 [${redirected_title}]。)",
Expand Down
2 changes: 0 additions & 2 deletions modules/wiki/locales/zh_tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"wiki.help.wiki_inline.page": "在 [[ ]] 內輸入標題以自動查詢頁面。",
"wiki.help.wiki_inline.template": "在 {{ }} 內輸入標題以自動查詢模板。",
"wiki.help.wiki_inline.url": "傳送 Wiki 頁面的 URL 以生成 Infobox 圖片。",
"wiki.message.ab.qq.link.title": "防濫用過濾器日誌網址",
"wiki.message.ab.qq.slice": "${user} 在 ${title} 執行操作「${action}」時觸發防濫用過濾器。\n过滤器描述:${filter_name}\n采取的行动:${result}",
"wiki.message.ab.qq.title": "防濫用過濾器日誌",
"wiki.message.ab.slice": "${time} - ${user} 在 ${title} 執行操作「${action}」時觸發防濫用過濾器。\n过滤器描述:${filter_name}\n采取的行动:${result}",
Expand Down Expand Up @@ -108,7 +107,6 @@
"wiki.message.rc.params.tag": "標籤:",
"wiki.message.rc.params.target_title": "目標標題:",
"wiki.message.rc.qq.link.prompt": "提示:複製並貼上下方的任意訊息到聊天視窗並傳送可取得此次改動詳細訊息的截圖。",
"wiki.message.rc.qq.link.title": "近期變更網址",
"wiki.message.rc.qq.title": "近期變更日誌",
"wiki.message.redirect": "(重新導向 [${title}] -> [${redirected_title}])",
"wiki.message.redirect.autofix": "(已指定 [${title}] 更正為 [${redirected_title}]。)",
Expand Down
7 changes: 2 additions & 5 deletions modules/wiki/utils/ab_qq.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from core.builtins import MessageSession, MessageChain, Plain
from core.config import Config
from core.builtins import MessageSession, MessageChain, Plain, Url
from core.logger import Logger
from modules.wiki.utils.ab import convert_ab_to_detailed_format
from modules.wiki.utils.wikilib import WikiLib
Expand All @@ -15,9 +14,7 @@ async def ab_qq(msg: MessageSession, wiki_url):
_no_login=not msg.options.get("use_bot_account", False),
)
pageurl = wiki.wiki_info.articlepath.replace("$1", "Special:AbuseLog")
msgchain_lst = [MessageChain([Plain(msg.locale.t("wiki.message.ab.qq.link.title"))]),
MessageChain([Plain(pageurl)]),
MessageChain([Plain(msg.locale.t("wiki.message.ab.qq.title"))])]
msgchain_lst = [MessageChain([Plain(msg.locale.t("wiki.message.ab.qq.title")), Url(pageurl)])]
ablist = await convert_ab_to_detailed_format(query["query"]["abuselog"], msg)
for x in ablist:
msgchain_lst.append(MessageChain([Plain(x)]))
Expand Down
22 changes: 9 additions & 13 deletions modules/wiki/utils/rc_qq.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from core.builtins import MessageSession, MessageChain, Plain, Image
from core.builtins import MessageSession, MessageChain, Plain
from core.logger import Logger
from modules.wiki.utils.rc import convert_rc_to_detailed_format
from modules.wiki.utils.wikilib import WikiLib
Expand All @@ -15,20 +15,16 @@ async def rc_qq(msg: MessageSession, wiki_url):
_no_login=not msg.options.get("use_bot_account", False),
)
wiki_info = wiki.wiki_info

pageurl = wiki.wiki_info.articlepath.replace("$1", "Special:RecentChanges")
msgchain_lst = [
MessageChain([Plain(msg.locale.t("wiki.message.rc.qq.link.title"))]),
MessageChain([Plain(wiki_info.articlepath.replace(
"$1", "Special:RecentChanges"
)
+ (
"\n" + msg.locale.t("wiki.message.rc.qq.link.prompt")
if wiki.wiki_info.in_allowlist
else ""
)
MessageChain([Plain(msg.locale.t("wiki.message.rc.qq.title")),
Plain(pageurl + (
"\n" + msg.locale.t("wiki.message.rc.qq.link.prompt")
if wiki.wiki_info.in_allowlist
else ""
)
)
]),
MessageChain([Plain(msg.locale.t("wiki.message.rc.qq.title"))])
])
]

rclist = await convert_rc_to_detailed_format(
Expand Down

0 comments on commit fba70b6

Please sign in to comment.