-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
188 lines (157 loc) · 4.58 KB
/
index.js
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
'use strict'
module.exports = function afknotify(mod) {
const notifier = mod.require ? mod.require.notifier : require('tera-notifier')(mod)
let cid,
playerName
/////Command
mod.command.add('afk', {
$none() {
enabled=!enabled
mod.command.message( enabled ? '(AFK Notify) Enabled' : '(AFK Notify) Disabled')
},
$default() {
mod.command.message('Error in command! afk or afk test only.')
},
test() {
notification('This is a test alert')
mod.command.message('Test message Sent')
}
})
mod.game.on('enter_game', () => {
cid = mod.game.me.gameId,
playerName = mod.game.me.name.toLowerCase()
})
/////Dispatches
//Instance Match (ims)
mod.hook('S_FIN_INTER_PARTY_MATCH', 'raw', () => {
parseconfig({
configname: 'ims',
message:'[Instance Match] Ready'
})
})
//Whispers (whisper)
mod.hook('S_WHISPER', 2, event => {
if(event.authorName.toLowerCase()===playerName) return
parseconfig({
configname:'whisper',
message:'[Whisper] '+event.authorName+'\n'+event.message
})
})
//Contracts (trade,duel,friendsummon,deathmatch,party)
mod.hook('S_REQUEST_CONTRACT', 1, event => {
if(event.senderName.toLowerCase() === playerName) return
switch(event.type) {
case 3: //trade
parseconfig({
configname:'trade',
message:'[Request Trade]\n'+event.senderName+' wants to trade'
})
break
case 4: //party
parseconfig({
configname:'party',
message:'[Request Party]\n'+event.senderName+' wants to party'
})
break
case 11: //Duel
parseconfig({
configname:'duel',
message:'[Request Duel]\n'+event.senderName+' wants to duel'
})
break
case 56: //Friend summon
parseconfig({
configname: 'friendsummon',
message: '[Request Friend Summon]\n' + event.senderName + ' wants to summon you'
})
break
case 18: //Deathmatch
parseconfig({
configname: 'deathmatch',
message: '[Request Deathmatch]\n' + event.senderName + ' wants to deathmath'
})
break
}
})
//Party Request (party) Not sure about this yet
mod.hook('S_OTHER_USER_APPLY_PARTY', 1, event => {
parseconfig({
configname:'lfgrequest',
message:'[LFG Request]\n'+event.name+' wants to join the party'
})
})
//Party
mod.hook('S_BEGIN_THROUGH_ARBITER_CONTRACT', 1, event => {
if(event.sender.toLowerCase() === playerName || event.type !== 4) return
else
parseconfig({
configname: 'party',
message: '[Request Party]\n' + event.sender + ' wants to party'
})
})
//Combat status changed (incombat)
mod.hook('S_USER_STATUS', 3, event => {
if(event.gameId===cid && event.status === 1) parseconfig({
configname:'incombat',
message:'[Combat]\nYou are in combat'
})
})
//Chat notification
mod.hook('S_CHAT', 2, event => {
if(event.authorName.toLowerCase()===playerName) return
if(mod.settings.chatTerm !== '' && event.message.toLowerCase().includes(mod.settings.chatTerm)) {
parseconfig({
configname:'chatcheckterm',
message:'[Chat Mention] '+event.authorName+'\n'+event.message
})
}
if(event.message.toLowerCase().includes(playerName)) {
parseconfig({
configname:'chatcheckname',
message:'[Chat Mention] '+event.authorName+'\n'+event.message
})
}
})
/*//Teleport Request
mod.hook('S_ASK_TELEPORT', 1, event => {
parseconfig({
configname: 'partysum',
message: '[Request Party Summon]\n' + event.name + ' wants to summon you'
})
})*/
//BG matching
mod.hook('S_BATTLE_FIELD_ENTRANCE_INFO', 'raw', () => {
parseconfig({
configname: 'bgmatched',
message: '[Battleground Match] Ready'
})
})
/////Functions
function parseconfig(set) {
if(!mod.settings[set.configname]) return;
if(mod.settings[set.configname].toLowerCase() === 'afk') {
let send = notificationafk(set.message)
if(mod.settings.log && send) console.log(set.message.replace('\n',' '))
}
else if(mod.settings[set.configname].toLowerCase() === 'notify') {
notification(set.message)
if(mod.settings.log) console.log(set.message.replace('\n',' '))
}
}
function notification(msg) {
notifier.notify({
title: 'AFK Notification',
message: msg,
wait:false,
sound:mod.settings.soundId,
})
}
function notificationafk(msg,timeout) { //timeout in milsec
notifier.notifyafk({
title: 'AFK Notification',
message: msg,
wait:false,
sound:mod.settings.soundId,
},timeout)
}
}