Webqq/Message/Emoji.pm untested

filter: Statementstmt 0.0% 0 / 18 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 1 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 28 CC 5 SCAR 34.0
CC
5
Cov
0%
Mojo::Webqq::emoji_parse
30.0
CRAP 30.0
1 my %EMOJI_MAP = qw(
2 :100: 100分
3 :1234: 1234
4 :grinning: 笑嘻嘻
5 :joy: 高兴
6 :smiley: 微笑
7 :emoji: 失望
8 :smirk: 假笑
9 :pensive: 沉思
10 :grin: 露齿而笑
11 :wink: 眨眼
12 :scream: 尖叫
13 :confounded: 糊涂
14 :kissing_closed_eyes: 闭上眼睛亲吻
15 :stuck_out_tongue_closed_eyes: 闭眼吐舌头
16 :relieved: 放心
17 :fearful: 担心
18 :mask: 戴口罩
19 :flushed: 脸红
20 :unamused: 无趣
21 :cold_sweat: 冒冷汗
22 :astonished: 吃惊
23 :sob: 流泪
24 :stuck_out_tongue_winking_eye: 眨眼吐舌头
25 :kissing_heart: 飞吻
26 :rage: 愤怒
27 :muscle: 秀肌肉
28 :punch: 拳头猛击
29 :thumbsup: 竖起大拇指
30 :point_up: 竖起中指
31 :clap: 鼓掌
32 :v: 胜利
33 :thumbsdown: 大拇指向下
34 :pray: 祈祷
35 :ok_hand: OK
36 :point_left: 向左指
37 :point_right: 向右指
38 :point_up_2: 向上指
39 :point_down: 向下指
40 :eyes: 大眼珠
41 :nose: 鼻子
42 :lips: 嘴唇
43 :ear: 耳朵
44 :rice: 米饭
45 :spaghetti: 意大利面
46 :ramen: 拉面
47 :rice_ball: 饭团
48 :shaved_ice: 冰沙
49 :sushi: 熟食
50 :birthday: 生日蛋糕
51 :bread: 面包
52 :hamburger: 汉堡包
53 :egg: 煎鸡蛋
54 :fries: 薯条
55 :beer: 一杯啤酒
56 :beers: 啤酒
57 :cocktail: 鸡尾酒
58 :coffee: 咖啡
59 :apple: 苹果
60 :tangerine: 蜜橘
61 :strawberry: 草莓
62 :watermelon: 西瓜
63 :pill: 胶囊
64 :smoking: 抽烟
65 :christmas_tree: 圣诞树
66 :rose: 玫瑰
67 :tada: 回头见
68 :palm_tree: 椰子树
69 :gift_heart: 心形礼物
70 :ribbon: 丝带
71 :balloon: 气球
72 :shell: 贝壳
73 :ring: 钻戒
74 :bomb: 炸弹
75 :crown: 皇冠
76 :bell: 铃铛
77 :star: 星星
78 :sparkles: 闪耀
79 :dash: 冲刺
80 :sweat_drops: 汗滴
81 :fire: 火焰
82 :trophy: 奖杯
83 :moneybag: 金钱袋
84 :zzz: 睡觉
85 :zap: 闪电
86 :feet: 脚印
87 :shit: 大便
88 :syringe: 注射器
89 :hotsprings: 温泉
90 :mailbox: 邮箱
91 :key: 钥匙
92 :lock: 锁
93 :airplane: 飞机
94 :bullettrain_side: 子弹头列车
95 :red_car: 红色小汽车
96 :speedboat: 快艇
97 :bike: 自行车
98 :racehorse: 赛马
99 :rocket: 火箭
100 :bus: 公交车
101 :boat: 帆船
102 :woman: 女人
103 :man: 男人
104 :girl: 女孩
105 :boy: 男孩
106 :monkey_face: 猴子脸
107 :octopus: 章鱼
108 :pig: 猪
109 :baby_chick: 小鸡
110 :koala: 考拉
111 :cow: 奶牛
112 :chicken: 鸡
113 :frog: 青蛙
114 :ghost: 鬼魂
115 :skull: 骷髅
116 :bug: 毛毛虫
117 :tropical_fish: 热带鱼
118 :dog: 狗狗
119 :tiger: 老虎
120 :angel: 天生
121 :penguin: 海豚
122 :whale: 鲸鱼
123 :mouse: 老鼠
124 :womans_hat: 女士帽子
125 :dress: 礼服
126 :lipstick: 唇膏
127 :high_heel: 高跟鞋
128 :boot: 长筒靴
129 :closed_umbrella: 雨伞
130 :handbag: 手提袋
131 :bikini: 比基尼
132 :shirt: 衬衫
133 :shoe: 鞋子
134 :cloud: 多云
135 :sunny: 晴天
136 :umbrella: 下雨
137 :moon: 弯月
138 :snowman: 雪人
139 :o: 圈
140 :x: 叉
141 :grey_question: 灰色问号
142 :grey_exclamation: 灰色感叹号
143 :telephone: 电话
144 :camera: 相机
145 :iphone: 手机
146 :fax: 传真机
147 :computer: 电脑
148 :movie_camera: 摄像机
149 :microphone: 麦克风
150 :gun: 手枪
151 :cd: 光盘
152 :heartbeat: 心动
153 :clubs: 梅花
154 :mahjong: 麻将牌
155 :part_alternation_mark: 衣架
156 :slot_machine: 投币机
157 :traffic_light: 红绿灯
158 :construction: 施工
159 :guitar: 吉他
160 :barber: 理发店
161 :bath: 浴缸
162 :toilet: 坐便器
163 :house: 房子
164 :church: 教堂
165 :bank: 银行
166 :hospital: 医院
167 :hotel: 旅店
168 :atm: ATM
169 :convenience_store: 便利店
170 :mens: 男洗手间
171 :womens: 女洗手间
172 );
173  
174 sub Mojo::Webqq::emoji_parse{
175 my $self = shift;
176 my $data = shift;
177 my @result;
178 my $index = 0;
179 my $last_emoji_start = undef;
180 my $last_emoji_end = undef;
181 while($data=~/:[a-z0-9_]+:/g){
182 if(exists $EMOJI_MAP{$&}){
183 $last_emoji_start = $-[0];
184 $last_emoji_end = $+[0]-1;
185 push @result,{content=>substr($data,$index,$-[0]-$index),type=>"txt"} if $-[0]-$index >0;
186 push @result,{content=>"[$EMOJI_MAP{$&}]",id=>$&,type=>"emoji"};
187 $index = $+[0];
188 }
189 }
190 if(defined $last_emoji_end){
191 push @result,{content=>substr($data,$last_emoji_end+1),type=>"txt"} if $last_emoji_end+1 < length($data);
192 }
193 else{
194 push @result,{content=>$data,type=>"txt"};
195 }
196 return \@result;
197 }