forked from pajlada/plugAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheventObjectTypes.js
More file actions
42 lines (38 loc) · 1.3 KB
/
Copy patheventObjectTypes.js
File metadata and controls
42 lines (38 loc) · 1.3 KB
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
/*
This file contains functions for converting plug.dj socket objects to plugAPI objects (easier to read and extend).
When adding new function, be sure to call it the event type name and then change the messageHandler to use the new object.
*/
/**
* @param {{m: Object, t: String, h: Number, d: Array, c: Number, p: Number}} data
* @returns {{media: Object, startTime: String, historyID: Number, djs: Array, currentDJ: Number, playlistID: Number}}
* @constructor
*/
function AdvanceEventObject(data) {
return {
media: data.m,
startTime: data.t,
historyID: data.h,
djs: data.d,
currentDJ: data.c,
playlistID: data.p
};
}
exports.advance = AdvanceEventObject;
var encoder = require('node-html-encoder').Encoder('entity');
/**
* @param {{message: String, un: String, type: String, uid: Number, cid: String}} data
* @param {Room} room
* @return {{raw: Object, id: (playback.media.cid|*), from: (User|null), message: String, mentions: User[], muted: Boolean}}
* @constructor
*/
function ChatEventObject(data, room) {
return {
raw: data,
id: data.cid,
from: room.getUser(data.uid),
message: encoder.htmlDecode(data.message),
mentions: [],
muted: room.isMuted(data.uid)
};
}
exports.chat = ChatEventObject;