Better emoji parser (#56)

* Better emoji parser

* Remove yarn.lock
This commit is contained in:
MeiMei 2020-08-24 20:33:42 +09:00 committed by GitHub
parent d1c0087986
commit f7ca0bb726
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View file

@ -13,12 +13,12 @@
"@types/random-seed": "0.3.3",
"@types/request-promise-native": "1.0.17",
"@types/seedrandom": "2.4.28",
"@types/twemoji-parser": "12.1.0",
"@types/uuid": "8.3.0",
"@types/ws": "7.2.6",
"autobind-decorator": "2.4.0",
"canvas": "2.6.1",
"chalk": "4.1.0",
"emoji-regex": "9.0.0",
"lokijs": "1.5.11",
"mecab-async": "0.1.2",
"misskey-reversi": "0.0.5",
@ -30,6 +30,7 @@
"seedrandom": "3.0.5",
"timeout-as-promise": "1.0.0",
"ts-node": "9.0.0",
"twemoji-parser": "13.0.0",
"typescript": "4.0.2",
"uuid": "8.3.0",
"ws": "7.3.1"

View file

@ -1,5 +1,5 @@
import autobind from 'autobind-decorator';
const emojiRegex = require('emoji-regex');
import { parse } from 'twemoji-parser';
import { Note } from '../../misskey/note';
import Module from '../../module';
@ -44,8 +44,8 @@ export default class extends Module {
return react(customEmojis[0]);
}
const emojis = note.text.match(emojiRegex());
if (emojis) {
const emojis = parse(note.text).map(x => x.text);
if (emojis.length > 0) {
// 絵文字が複数種類ある場合はキャンセル
if (!emojis.every((val, i, arr) => val === arr[0])) return;