Add name for Face (#345)

* add faceName

* fix incorrect merge

* fix misspelling

* fix incorrect access control

* fix test

* fix typo
This commit is contained in:
Niltok 2020-06-14 20:03:37 +08:00 committed by GitHub
parent c7ab173a5d
commit 169942237f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 213 additions and 2 deletions

View File

@ -28,7 +28,10 @@ data class Face(val id: Int) : // used in delegation
MessageContent, CodableMessage {
override fun toString(): String = "[mirai:face:$id]"
override fun contentToString(): String = "[表情]"
override fun contentToString(): String =
if (id >= 0 && id <= 255)
FaceName.names[id]
else "[表情]"
override fun equals(other: Any?): Boolean = other is Face && other.id == this.id
override fun hashCode(): Int = id
@ -253,4 +256,212 @@ data class Face(val id: Int) : // used in delegation
@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN)
@Suppress("unused", "UNUSED_PARAMETER")
operator fun component2(): String = toString()
}
/**
* @author Niltok
*/
@Suppress("SpellCheckingInspection")
private object FaceName {
val names = Array<String>(256, { "[表情]" })
init {
names[Face.jingya] = "[惊讶]"
names[Face.piezui] = "[撇嘴]"
names[Face.se] = "[色]"
names[Face.fadai] = "[发呆]"
names[Face.deyi] = "[得意]"
names[Face.liulei] = "[流泪]"
names[Face.haixiu] = "[害羞]"
names[Face.bizui] = "[闭嘴]"
names[Face.shui] = "[睡]"
names[Face.daku] = "[大哭]"
names[Face.ganga] = "[尴尬]"
names[Face.fanu] = "[发怒]"
names[Face.tiaopi] = "[调皮]"
names[Face.ciya] = "[呲牙]"
names[Face.weixiao] = "[微笑]"
names[Face.nanguo] = "[难过]"
names[Face.ku] = "[酷]"
names[Face.zhuakuang] = "[抓狂]"
names[Face.tu] = "[吐]"
names[Face.touxiao] = "[偷笑]"
names[Face.keai] = "[可爱]"
names[Face.baiyan] = "[白眼]"
names[Face.aoman] = "[傲慢]"
names[Face.ji_e] = "[饥饿]"
names[Face.kun] = "[困]"
names[Face.jingkong] = "[惊恐]"
names[Face.liuhan] = "[流汗]"
names[Face.hanxiao] = "[憨笑]"
names[Face.dabing] = "[大病]"
names[Face.fendou] = "[奋斗]"
names[Face.zhouma] = "[咒骂]"
names[Face.yiwen] = "[疑问]"
names[Face.yun] = "[晕]"
names[Face.zhemo] = "[折磨]"
names[Face.shuai] = "[衰]"
names[Face.kulou] = "[骷髅]"
names[Face.qiaoda] = "[敲打]"
names[Face.zaijian] = "[再见]"
names[Face.fadou] = "[发抖]"
names[Face.aiqing] = "[爱情]"
names[Face.tiaotiao] = "[跳跳]"
names[Face.zhutou] = "[猪头]"
names[Face.yongbao] = "[拥抱]"
names[Face.dan_gao] = "[蛋糕]"
names[Face.shandian] = "[闪电]"
names[Face.zhadan] = "[炸弹]"
names[Face.dao] = "[刀]"
names[Face.zuqiu] = "[足球]"
names[Face.bianbian] = "[便便]"
names[Face.kafei] = "[咖啡]"
names[Face.fan] = "[饭]"
names[Face.meigui] = "[玫瑰]"
names[Face.diaoxie] = "[凋谢]"
names[Face.aixin] = "[爱心]"
names[Face.xinsui] = "[心碎]"
names[Face.liwu] = "[礼物]"
names[Face.taiyang] = "[太阳]"
names[Face.yueliang] = "[月亮]"
names[Face.qiang] = "[强]"
names[Face.ruo] = "[弱]"
names[Face.woshou] = "[握手]"
names[Face.shengli] = "[胜利]"
names[Face.feiwen] = "[飞吻]"
names[Face.naohuo] = "[恼火]"
names[Face.xigua] = "[西瓜]"
names[Face.lenghan] = "[冷汗]"
names[Face.cahan] = "[擦汗]"
names[Face.koubi] = "[抠鼻]"
names[Face.guzhang] = "[鼓掌]"
names[Face.qiudale] = "[糗大了]"
names[Face.huaixiao] = "[坏笑]"
names[Face.zuohengheng] = "[左哼哼]"
names[Face.youhengheng] = "[右哼哼]"
names[Face.haqian] = "[哈欠]"
names[Face.bishi] = "[鄙视]"
names[Face.weiqu] = "[委屈]"
names[Face.kuaikule] = "[快哭了]"
names[Face.yinxian] = "[阴险]"
names[Face.qinqin] = "[亲亲]"
names[Face.xia] = "[吓]"
names[Face.kelian] = "[可怜]"
names[Face.caidao] = "[菜刀]"
names[Face.pijiu] = "[啤酒]"
names[Face.lanqiu] = "[篮球]"
names[Face.pingpang] = "[乒乓]"
names[Face.shiai] = "[示爱]"
names[Face.piaochong] = "[瓢虫]"
names[Face.baoquan] = "[抱拳]"
names[Face.gouyin] = "[勾引]"
names[Face.quantou] = "[拳头]"
names[Face.chajin] = "[差劲]"
names[Face.aini] = "[爱你]"
names[Face.bu] = "[NO]"
names[Face.hao] = "[OK]"
names[Face.zhuanquan] = "[转圈]"
names[Face.ketou] = "[磕头]"
names[Face.huitou] = "[回头]"
names[Face.tiaosheng] = "[跳绳]"
names[Face.huishou] = "[挥手]"
names[Face.jidong] = "[激动]"
names[Face.jiewu] = "[街舞]"
names[Face.xianwen] = "[献吻]"
names[Face.zuotaiji] = "[左太极]"
names[Face.youtaiji] = "[右太极]"
names[Face.shuangxi] = "[双喜]"
names[Face.bianpao] = "[鞭炮]"
names[Face.denglong] = "[灯笼]"
names[Face.facai] = "[发财]"
names[Face.K_ge] = "[K歌]"
names[Face.gouwu] = "[购物]"
names[Face.youjian] = "[邮件]"
names[Face.shuai_qi] = "[帅气]"
names[Face.hecai] = "[喝彩]"
names[Face.qidao] = "[祈祷]"
names[Face.baojin] = "[爆筋]"
names[Face.bangbangtang] = "[棒棒糖]"
names[Face.he_nai] = "[喝奶]"
names[Face.xiamian] = "[下面]"
names[Face.xiangjiao] = "[香蕉]"
names[Face.feiji] = "[飞机]"
names[Face.kaiche] = "[开车]"
names[Face.gaotiezuochetou] = "[高铁左车头]"
names[Face.chexiang] = "[车厢]"
names[Face.gaotieyouchetou] = "[高铁右车头]"
names[Face.duoyun] = "[多云]"
names[Face.xiayu] = "[下雨]"
names[Face.chaopiao] = "[钞票]"
names[Face.xiongmao] = "[熊猫]"
names[Face.dengpao] = "[灯泡]"
names[Face.fengche] = "[风车]"
names[Face.naozhong] = "[闹钟]"
names[Face.dasan] = "[打伞]"
names[Face.caiqiu] = "[彩球]"
names[Face.zuanjie] = "[钻戒]"
names[Face.shafa] = "[沙发]"
names[Face.zhijin] = "[纸巾]"
names[Face.yao] = "[药]"
names[Face.shouqiang] = "[手枪]"
names[Face.qingwa] = "[青蛙]"
names[Face.hexie] = "[河蟹]"
names[Face.yangtuo] = "[羊驼]"
names[Face.youling] = "[幽灵]"
names[Face.dan] = "[蛋]"
names[Face.juhua] = "[菊花]"
names[Face.hongbao] = "[红包]"
names[Face.daxiao] = "[大笑]"
names[Face.bukaixin] = "[不开心]"
names[Face.lengmo] = "[冷漠]"
names[Face.e] = "[呃]"
names[Face.haobang] = "[好棒]"
names[Face.baituo] = "[拜托]"
names[Face.dianzan] = "[点赞]"
names[Face.wuliao] = "[无聊]"
names[Face.tuolian] = "[托脸]"
names[Face.chi] = "[吃]"
names[Face.songhua] = "[送花]"
names[Face.haipa] = "[害怕]"
names[Face.huachi] = "[花痴]"
names[Face.xiaoyanger] = "[小样儿]"
names[Face.biaolei] = "[飙泪]"
names[Face.wobukan] = "[我不看]"
names[212] = "[托腮]"
names[Face.bobo] = "[啵啵]"
names[Face.hulian] = "[糊脸]"
names[Face.paitou] = "[拍头]"
names[Face.cheyiche] = "[扯一扯]"
names[Face.tianyitian] = "[舔一舔]"
names[Face.cengyiceng] = "[蹭一蹭]"
names[Face.zhuaizhatian] = "[拽炸天]"
names[Face.dingguagua] = "[顶呱呱]"
names[Face.baobao] = "[抱抱]"
names[Face.baoji] = "[暴击]"
names[Face.kaiqiang] = "[开枪]"
names[Face.liaoyiliao] = "[撩一撩]"
names[Face.paizhuo] = "[拍桌]"
names[Face.paishou] = "[拍手]"
names[Face.gongxi] = "[恭喜]"
names[Face.ganbei] = "[干杯]"
names[Face.chaofeng] = "[嘲讽]"
names[Face.heng] = "[哼]"
names[Face.foxi] = "[佛系]"
names[Face.qiaoyiqioa] = "[敲一敲]"
names[Face.jingdai] = "[惊呆]"
names[Face.chandou] = "[颤抖]"
names[Face.kentou] = "[啃头]"
names[Face.toukan] = "[偷看]"
names[Face.shanlian] = "[扇脸]"
names[Face.yuanliang] = "[原谅]"
names[Face.penlian] = "[喷脸]"
names[Face.shengrikuaile] = "[生日快乐]"
names[Face.touzhuangji] = "[头撞击]"
names[Face.shuaitou] = "[甩头]"
names[Face.rengou] = "[扔狗]"
names[245] = "[必胜加油]"
names[246] = "[加油抱抱]"
names[247] = "[口罩护体]"
}
}

View File

@ -92,7 +92,7 @@ internal class ConstrainSingleTest {
}
assertEquals(7, result.size)
assertEquals(" [表情]ss p test", result.contentToString())
assertEquals(" [OK]ss p test", result.contentToString())
result as MessageChainImplByCollection
assertSame(new, result.delegate.toTypedArray()[2])
}