Better emoji parser

This commit is contained in:
mei23 2020-08-24 20:19:06 +09:00
parent d1c0087986
commit cc99a0c0ab
No known key found for this signature in database
GPG key ID: DD8628500D3E4B23
3 changed files with 1121 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;

1116
yarn.lock Normal file

File diff suppressed because it is too large Load diff