Skip to content

Commit f320d9e

Browse files
kanrichanfumiama
andauthored
✨ 增加插件 emojimix (#121)
* ✨ 增加插件 emojimix * 🎨✏️ 优化代码格式 * ✨ 增加 qqface 支持 * Update main.go Co-authored-by: 源文雨 <[email protected]>
1 parent 18bd34f commit f320d9e

File tree

4 files changed

+344
-0
lines changed

4 files changed

+344
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ zerobot [-h] [-t token] [-u url] [-n nickname] [-p prefix] [-d|w] [-g 监听地
247247
- [x] 讲个笑话[@xxx] | 讲个笑话[qq号]
248248
- **抽象话** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_chouxianghua"`
249249
- [x] 抽象翻译[xxx]
250+
- **抽象话** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_emojimix"`
251+
- [x] [emoji][emoji]
250252
- **绝绝子** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_juejuezi"`
251253
- [x] 喝奶茶绝绝子 | 绝绝子吃饭
252254
- **藏头诗** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_cangtoushi"`

main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ import (
6262
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_cpstory" // cp短打
6363
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_danbooru" // DeepDanbooru二次元图标签识别
6464
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_diana" // 嘉心糖发病
65+
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_emojimix" // 合成emoji
6566
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_fortune" // 运势
6667
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_funny" // 笑话
6768
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_gif" // 制图
@@ -118,6 +119,7 @@ import (
118119

119120
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_ai_reply" // 人工智能回复
120121

122+
121123
// ^^^^ //
122124
// ^^^^^^^^^^^^^^ //
123125
// ^^^^^^^低优先级区^^^^^^^ //

plugin_emojimix/emoji.go

Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
// Package emojimix 合成emoji
2+
package emojimix
3+
4+
var emojis = map[rune]int64{
5+
128516: 20201001, // 😄 grinning face with smiling eyes
6+
128512: 20201001, // 😀 grinning face
7+
128578: 20201001, // 🙂 slightly smiling face
8+
128579: 20201001, // 🙃 upside-down face
9+
128521: 20201001, // 😉 winking face
10+
128522: 20201001, // 😊 smiling face with smiling eyes
11+
128518: 20201001, // 😆 grinning squinting face
12+
128515: 20201001, // 😃 grinning face with big eyes
13+
128513: 20201001, // 😁 beaming face with smiling eyes
14+
129315: 20201001, // 🤣 rolling on the floor laughing
15+
128517: 20201001, // 😅 grinning face with sweat
16+
128514: 20201001, // 😂 face with tears of joy
17+
128519: 20201001, // 😇 smiling face with halo
18+
129392: 20201001, // 🥰 smiling face with hearts
19+
128525: 20201001, // 😍 smiling face with heart-eyes
20+
128536: 20201001, // 😘 face blowing a kiss
21+
129321: 20201001, // 🤩 star-struck
22+
128535: 20201001, // 😗 kissing face
23+
128538: 20201001, // 😚 kissing face with closed eyes
24+
128537: 20201001, // 😙 kissing face with smiling eyes
25+
128539: 20201001, // 😛 face with tongue
26+
128541: 20201001, // 😝 squinting face with tongue
27+
128523: 20201001, // 😋 face savoring food
28+
129394: 20201001, // 🥲 smiling face with tear
29+
129297: 20201001, // 🤑 money-mouth face
30+
128540: 20201001, // 😜 winking face with tongue
31+
129303: 20201001, // 🤗 smiling face with open hands hugs
32+
129323: 20201001, // 🤫 shushing face quiet whisper
33+
129300: 20201001, // 🤔 thinking face question hmmm
34+
129325: 20201001, // 🤭 face with hand over mouth embarrassed
35+
129320: 20201001, // 🤨 face with raised eyebrow question
36+
129296: 20201001, // 🤐 zipper-mouth face
37+
128528: 20201001, // 😐 neutral face
38+
128529: 20201001, // 😑 expressionless face
39+
128566: 20201001, // 😶 face without mouth
40+
129322: 20201001, // 🤪 zany face
41+
128527: 20201001, // 😏 smirking face suspicious
42+
128530: 20201001, // 😒 unamused face
43+
128580: 20201001, // 🙄 face with rolling eyes
44+
128556: 20201001, // 😬 grimacing face
45+
128558: 20210218, // 😮 face exhaling
46+
129317: 20201001, // 🤥 lying face
47+
128524: 20201001, // 😌 relieved face
48+
128532: 20201001, // 😔 pensive face
49+
128554: 20201001, // 😪 sleepy face
50+
129316: 20201001, // 🤤 drooling face
51+
128564: 20201001, // 😴 sleeping face
52+
128567: 20201001, // 😷 face with medical mask
53+
129298: 20201001, // 🤒 face with thermometer
54+
129301: 20201001, // 🤕 face with head-bandage
55+
129314: 20201001, // 🤢 nauseated face
56+
129326: 20201001, // 🤮 face vomiting throw
57+
129319: 20201001, // 🤧 sneezing face
58+
129397: 20201001, // 🥵 hot face warm
59+
129398: 20201001, // 🥶 cold face freezing ice
60+
128565: 20201001, // 😵 face with crossed-out eyes
61+
129396: 20201001, // 🥴 woozy face drunk tipsy drug high
62+
129327: 20201001, // 🤯 exploding head mindblow
63+
129312: 20201001, // 🤠 cowboy hat face
64+
129395: 20201001, // 🥳 partying face
65+
129400: 20201001, // 🥸 disguised face
66+
129488: 20201001, // 🧐 face with monocle glasses
67+
128526: 20201001, // 😎 smiling face with sunglasses
68+
128533: 20201001, // 😕 confused face
69+
128543: 20201001, // 😟 worried face
70+
128577: 20201001, // 🙁 slightly frowning face
71+
128559: 20201001, // 😯 hushed face
72+
128562: 20201001, // 😲 astonished face
73+
129299: 20201001, // 🤓 nerd face glasses
74+
128563: 20201001, // 😳 flushed face
75+
129402: 20201001, // 🥺 pleading face
76+
128551: 20201001, // 😧 anguished face
77+
128552: 20201001, // 😨 fearful face
78+
128550: 20201001, // 😦 frowning face with open mouth
79+
128560: 20201001, // 😰 anxious face with sweat
80+
128549: 20201001, // 😥 sad but relieved face
81+
128557: 20201001, // 😭 loudly crying face
82+
128553: 20201001, // 😩 weary face
83+
128546: 20201001, // 😢 crying face
84+
128547: 20201001, // 😣 persevering face
85+
128544: 20201001, // 😠 angry face
86+
128531: 20201001, // 😓 downcast face with sweat
87+
128534: 20201001, // 😖 confounded face
88+
129324: 20201001, // 🤬 face with symbols on mouth
89+
128542: 20201001, // 😞 disappointed face
90+
128555: 20201001, // 😫 tired face
91+
128548: 20201001, // 😤 face with steam from nose
92+
129393: 20201001, // 🥱 yawning face
93+
128169: 20201001, // 💩 pile of poo
94+
128545: 20201001, // 😡 pouting face
95+
128561: 20201001, // 😱 face screaming in fear
96+
128127: 20201001, // 👿 angry face with horns
97+
128128: 20201001, // 💀 skull
98+
128125: 20201001, // 👽 alien
99+
128520: 20201001, // 😈 smiling face with horns devil
100+
129313: 20201001, // 🤡 clown face
101+
128123: 20201001, // 👻 ghost
102+
129302: 20201001, // 🤖 robot
103+
128175: 20201001, // 💯 hundred points percent
104+
128064: 20201001, // 👀 eyes
105+
127801: 20201001, // 🌹 rose flower
106+
127804: 20201001, // 🌼 blossom flower
107+
127799: 20201001, // 🌷 tulip flower
108+
127797: 20201001, // 🌵 cactus
109+
127821: 20201001, // 🍍 pineapple
110+
127874: 20201001, // 🎂 birthday cake
111+
127751: 20210831, // 🌇 sunset
112+
129473: 20201001, // 🧁 cupcake muffin
113+
127911: 20210521, // 🎧 headphone earphone
114+
127800: 20210218, // 🌸 cherry blossom flower
115+
129440: 20201001, // 🦠 microbe germ bacteria virus covid corona
116+
128144: 20201001, // 💐 bouquet flowers
117+
127789: 20201001, // 🌭 hot dog food
118+
128139: 20201001, // 💋 kiss mark lips
119+
127875: 20201001, // 🎃 jack-o-lantern pumpkin
120+
129472: 20201001, // 🧀 cheese wedge
121+
9749: 20201001, // ☕ hot beverage coffee cup tea
122+
127882: 20201001, // 🎊 confetti ball
123+
127880: 20201001, // 🎈 balloon
124+
9924: 20201001, // ⛄ snowman without snow
125+
128142: 20201001, // 💎 gem stone crystal diamond
126+
127794: 20201001, // 🌲 evergreen tree
127+
129410: 20210218, // 🦂 scorpion
128+
128584: 20201001, // 🙈 see-no-evil monkey
129+
128148: 20201001, // 💔 broken heart
130+
128140: 20201001, // 💌 love letter heart
131+
128152: 20201001, // 💘 heart with arrow
132+
128159: 20201001, // 💟 heart decoration
133+
128158: 20201001, // 💞 revolving hearts
134+
128147: 20201001, // 💓 beating heart
135+
128149: 20201001, // 💕 two hearts
136+
128151: 20201001, // 💗 growing heart
137+
129505: 20201001, // 🧡 orange heart
138+
128155: 20201001, // 💛 yellow heart
139+
10084: 20210218, // ❤ mending heart
140+
128156: 20201001, // 💜 purple heart
141+
128154: 20201001, // 💚 green heart
142+
128153: 20201001, // 💙 blue heart
143+
129294: 20201001, // 🤎 brown heart
144+
129293: 20201001, // 🤍 white heart
145+
128420: 20201001, // 🖤 black heart
146+
128150: 20201001, // 💖 sparkling heart
147+
128157: 20201001, // 💝 heart with ribbon
148+
127873: 20211115, // 🎁 wrapped-gift
149+
129717: 20211115, // 🪵 wood
150+
127942: 20211115, // 🏆 trophy
151+
127838: 20210831, // 🍞 bread
152+
128240: 20201001, // 📰 newspaper
153+
128302: 20201001, // 🔮 crystal ball
154+
128081: 20201001, // 👑 crown
155+
128055: 20201001, // 🐷 pig face
156+
129412: 20210831, // 🦄 unicorn
157+
127771: 20201001, // 🌛 first quarter moon face
158+
129420: 20201001, // 🦌 deer
159+
129668: 20210521, // 🪄 magic wand
160+
128171: 20201001, // 💫 dizzy
161+
128049: 20201001, // 🐱 meow cat face
162+
129409: 20201001, // 🦁 lion
163+
128293: 20201001, // 🔥 fire
164+
128038: 20210831, // 🐦 bird
165+
129415: 20201001, // 🦇 bat
166+
129417: 20210831, // 🦉 owl
167+
127752: 20201001, // 🌈 rainbow
168+
128053: 20201001, // 🐵 monkey face
169+
128029: 20201001, // 🐝 honeybee bumblebee wasp
170+
128034: 20201001, // 🐢 turtle
171+
128025: 20201001, // 🐙 octopus
172+
129433: 20201001, // 🦙 llama alpaca
173+
128016: 20210831, // 🐐 goat
174+
128060: 20201001, // 🐼 panda
175+
128040: 20201001, // 🐨 koala
176+
129445: 20201001, // 🦥 sloth
177+
128059: 20210831, // 🐻 bear
178+
128048: 20201001, // 🐰 rabbit face
179+
129428: 20201001, // 🦔 hedgehog
180+
128054: 20211115, // 🐶 dog puppy
181+
128041: 20211115, // 🐩 poodle dog
182+
129437: 20211115, // 🦝 raccoon
183+
128039: 20211115, // 🐧 penguin
184+
128012: 20210218, // 🐌 snail
185+
128045: 20201001, // 🐭 mouse face rat
186+
128031: 20210831, // 🐟 fish
187+
127757: 20201001, // 🌍 globe showing Europe-Africa
188+
127774: 20201001, // 🌞 sun with face
189+
127775: 20201001, // 🌟 glowing star
190+
11088: 20201001, // ⭐ star
191+
127772: 20201001, // 🌜 last quarter moon face
192+
129361: 20201001, // 🥑 avocado
193+
127820: 20211115, // 🍌 banana
194+
127827: 20210831, // 🍓 strawberry
195+
127819: 20210521, // 🍋 lemon
196+
127818: 20211115, // 🍊 tangerine orange
197+
}
198+
199+
var qqface = map[int]rune{
200+
0: 128558, // 😮 face exhaling
201+
1: 128556, // 😬 grimacing face
202+
2: 128525, // 😍 smiling face with heart-eyes
203+
4: 128526, // 😎 smiling face with sunglasses
204+
5: 128557, // 😭 loudly crying face
205+
6: 129402, // 🥺 pleading face
206+
7: 129296, // 🤐 zipper-mouth face
207+
8: 128554, // 😪 sleepy face
208+
11: 128545, // 😡 pouting face
209+
12: 128539, // 😛 face with tongue
210+
13: 128513, // 😁 beaming face with smiling eyes
211+
14: 128578, // 🙂 slightly smiling face
212+
15: 128577, // 🙁 slightly frowning face
213+
16: 128526, // 😎 smiling face with sunglasses
214+
19: 129326, // 🤮 face vomiting throw
215+
20: 129325, // 🤭 face with hand over mouth embarrassed
216+
21: 128522, // 😊 smiling face with smiling eyes
217+
23: 128533, // 😕 confused face
218+
24: 128523, // 😋 face savoring food
219+
27: 128531, // 😓 downcast face with sweat
220+
28: 128516, // 😄 grinning face with smiling eyes
221+
31: 129324, // 🤬 face with symbols on mouth
222+
32: 129300, // 🤔 thinking face question hmmm
223+
33: 129323, // 🤫 shushing face quiet whisper
224+
34: 128565, // 😵 face with crossed-out eyes
225+
35: 128547, // 😣 persevering face
226+
37: 128128, // 💀 skull
227+
46: 128055, // 🐷 pig face
228+
53: 127874, // 🎂 birthday cake
229+
59: 128169, // 💩 pile of poo
230+
60: 9749, // ☕ hot beverage coffee cup tea
231+
63: 127801, // 🌹 rose flower
232+
66: 10084, // ❤ mending heart
233+
67: 128148, // 💔 broken heart
234+
69: 127873, // 🎁 wrapped-gift
235+
74: 127774, // 🌞 sun with face
236+
75: 127772, // 🌜 last quarter moon face
237+
96: 128517, // 😅 grinning face with sweat
238+
104: 129393, // 🥱 yawning face
239+
109: 128535, // 😗 kissing face
240+
110: 128562, // 😲 astonished face
241+
111: 129402, // 🥺 pleading face
242+
172: 128539, // 😛 face with tongue
243+
182: 128514, // 😂 face with tears of joy
244+
187: 128123, // 👻 ghost
245+
247: 128567, // 😷 face with medical mask
246+
272: 128579, // 🙃 upside-down face
247+
320: 129395, // 🥳 partying face
248+
325: 128561, // 😱 face screaming in fear
249+
}

plugin_emojimix/mix.go

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
// Package emojimix 合成emoji
2+
package emojimix
3+
4+
import (
5+
"fmt"
6+
"net/http"
7+
"strconv"
8+
9+
"github.com/FloatTech/zbputils/control"
10+
"github.com/FloatTech/zbputils/control/order"
11+
"github.com/FloatTech/zbputils/ctxext"
12+
zero "github.com/wdvxdr1123/ZeroBot"
13+
"github.com/wdvxdr1123/ZeroBot/message"
14+
)
15+
16+
func init() {
17+
control.Register("emojimix", order.AcquirePrio(), &control.Options{
18+
DisableOnDefault: false,
19+
Help: "合成emoji\n" +
20+
"- [emoji][emoji]",
21+
}).OnMessage(match).SetBlock(true).Limit(ctxext.LimitByUser).
22+
Handle(func(ctx *zero.Ctx) {
23+
r1 := ctx.State["emojimix_e1"].(rune)
24+
r2 := ctx.State["emojimix_e2"].(rune)
25+
u1 := fmt.Sprintf("https://www.gstatic.com/android/keyboard/emojikitchen/%d/u%x/u%x_u%x.png", emojis[r1], r1, r1, r2)
26+
u2 := fmt.Sprintf("https://www.gstatic.com/android/keyboard/emojikitchen/%d/u%x/u%x_u%x.png", emojis[r2], r2, r2, r1)
27+
client := &http.Client{}
28+
resp1, err := client.Head(u1)
29+
if err == nil && resp1.StatusCode == http.StatusOK {
30+
ctx.SendChain(message.Image(u1))
31+
resp1.Body.Close()
32+
return
33+
}
34+
resp2, err := client.Head(u2)
35+
if err == nil && resp2.StatusCode == http.StatusOK {
36+
ctx.SendChain(message.Image(u2))
37+
resp2.Body.Close()
38+
return
39+
}
40+
})
41+
}
42+
43+
func match(ctx *zero.Ctx) bool {
44+
r := []rune(ctx.Event.RawMessage)
45+
if len(r) == 2 {
46+
if _, ok := emojis[r[0]]; !ok {
47+
return false
48+
}
49+
if _, ok := emojis[r[1]]; !ok {
50+
return false
51+
}
52+
ctx.State["emojimix_e1"] = r[0]
53+
ctx.State["emojimix_e2"] = r[1]
54+
return true
55+
}
56+
if len(ctx.Event.Message) == 2 {
57+
r1 := face2emoji(ctx.Event.Message[0])
58+
if _, ok := emojis[r1]; !ok {
59+
return false
60+
}
61+
r2 := face2emoji(ctx.Event.Message[1])
62+
if _, ok := emojis[r2]; !ok {
63+
return false
64+
}
65+
ctx.State["emojimix_e1"] = r1
66+
ctx.State["emojimix_e2"] = r2
67+
return true
68+
}
69+
return false
70+
}
71+
72+
func face2emoji(face message.MessageSegment) rune {
73+
if face.Type == "text" {
74+
r := []rune(face.Data["text"])
75+
if len(r) != 1 {
76+
return 0
77+
}
78+
return r[0]
79+
}
80+
if face.Type != "face" {
81+
return 0
82+
}
83+
id, err := strconv.Atoi(face.Data["id"])
84+
if err != nil {
85+
return 0
86+
}
87+
if r, ok := qqface[id]; ok {
88+
return r
89+
}
90+
return 0
91+
}

0 commit comments

Comments
 (0)