-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathchatping.js
More file actions
29 lines (27 loc) · 925 Bytes
/
chatping.js
File metadata and controls
29 lines (27 loc) · 925 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
settings.register({
name: 'Enable ping toasts',
key: 'underscript.enable.pingToast',
category: 'Ping Me',
page: 'Chat',
});
settings.register({
name: 'On',
key: 'underscript.ping.extras',
type: 'array',
experimental: true,
category: 'Ping Me',
page: 'Chat',
});
(() => {
eventManager.on('Chat:getMessage', function pingToast(data) {
if (this.canceled || !settings.value('underscript.enable.pingToast')) return;
const msg = JSON.parse(data.chatMessage);
if (shouldIgnore(msg)) return;
if (!fn.pingRegex().test(msg.message)) return;
const avatar = !settings.value('chatAvatarsDisabled') ? `<img src="/images/avatars/${msg.user.avatar.image}.png" class="avatar ${msg.user.avatar.rarity}" height="35" style="float: left; margin-right: 7px;">` : '';
fn.toast({
title: `${avatar}${msg.user.username} (${chatRoomNames[data.room]})`,
text: msg.message,
});
});
})();