Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

文档中contentToString()的注释似乎有错误 #2373

Closed
MrY-Cat opened this issue Dec 3, 2022 · 4 comments · Fixed by #2374
Closed

文档中contentToString()的注释似乎有错误 #2373

MrY-Cat opened this issue Dec 3, 2022 · 4 comments · Fixed by #2374
Labels
N 优先级: 一般 s:core 子系统: mirai-core t:problem 类型: 不容易归类为特性或 bug 的综合问题
Milestone

Comments

@MrY-Cat
Copy link
Contributor

MrY-Cat commented Dec 3, 2022

问题描述

image

如图,根据描述,At()调用contentToString()将被转化为"@群名片",但经过test发现实际转化的是"@qq",测试结果如下(测试代码贴在系统日志了):
image

可见无论是At.contentToString()或者At.content,返回字符串均为"@qq",要伪造假艾特字符串还是只能用"@"+group.getMember(MasterID)?.nameCardOrNick

复现

test一下就好

mirai-core 版本

2.13.0-M1

bot-protocol

ANDROID_PAD

其他组件版本

No response

系统日志

suspend fun test5(group:Group,name:String="At(ID).content")
{
    group.sendMessage("测试${name}开始")
    group.sendMessage(At(MasterID))
    group.sendMessage(At(MasterID).content)
    group.sendMessage(At(MasterID).contentToString())
    group.sendMessage("@"+group.getMember(MasterID)?.nameCardOrNick)
    group.sendMessage("测试${name}完毕")
}

网络日志

No response

补充信息

No response

@MrXiaoM
Copy link
Contributor

MrXiaoM commented Dec 3, 2022

At本身就只存了被at的人的qq号,你还想 contentToString 能取到群名片就是奢望。

要获取与QQ客户端类似的格式应当用At.getDisplay(Group)

@MrY-Cat
Copy link
Contributor Author

MrY-Cat commented Dec 3, 2022

我也觉得这不可能,所以才说这个注释有误

@cssxsh
Copy link
Contributor

cssxsh commented Dec 3, 2022

At本身就只存了被at的人的qq号,你还想 contentToString 能取到群名片就是奢望。

要获取与QQ客户端类似的格式应当用At.getDisplay(Group)

一定条件下是可以的
例如 MessageChain 里的 At 可以根据 MessageSource 获取上下文(群) 然后 转成群名片

单个 At 当然不行

@LaoLittle
Copy link
Contributor

At本身就只存了被at的人的qq号,你还想 contentToString 能取到群名片就是奢望。

要获取与QQ客户端类似的格式应当用At.getDisplay(Group)

文档确实有问题

@Him188 Him188 added this to the 2.14.0-RC milestone Dec 3, 2022
@Him188 Him188 added N 优先级: 一般 t:problem 类型: 不容易归类为特性或 bug 的综合问题 s:core 子系统: mirai-core labels Dec 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
N 优先级: 一般 s:core 子系统: mirai-core t:problem 类型: 不容易归类为特性或 bug 的综合问题
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants