forked from undeaDD/basicBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasicBot.js
101 lines (85 loc) · 3.23 KB
/
basicBot.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
(function () {
var loadChat = function (cb) {
if (!cb) cb = function () {
};
$.get("https://rawgit.com/Yemasthui/basicBot/master/lang/langIndex.json", function (json) {
var link = basicBot.chatLink;
if (json !== null && typeof json !== "undefined") {
langIndex = json;
link = langIndex[basicBot.settings.language.toLowerCase()];
if (basicBot.settings.chatLink !== basicBot.chatLink) {
link = basicBot.settings.chatLink;
}
else {
if (typeof link === "undefined") {
link = basicBot.chatLink;
}
}
$.get(link, function (json) {
if (json !== null && typeof json !== "undefined") {
if (typeof json === "string") json = JSON.parse(json);
basicBot.chat = json;
cb();
}
});
}
else {
$.get(basicBot.chatLink, function (json) {
if (json !== null && typeof json !== "undefined") {
if (typeof json === "string") json = JSON.parse(json);
basicBot.chat = json;
cb();
}
});
}
});
};
var basicBot = {
chatLink: "https://rawgit.com/Yemasthui/basicBot/master/lang/en.json",
chat: null,
loadChat: loadChat,
settings: {
botName: "Bukkit Bot",
language: "english",
chatLink: "https://rawgit.com/Yemasthui/basicBot/master/lang/en.json"
},
eventDjadvance: function (obj) {
// check if dj is present
if (obj == null) return;
var ip = "s21.hosthorde.com:1338";
var hash = "cQI16fSdL5upaU1Lzk3hLptiQqr3i";
var str = "";
var currentDJ = obj.dj;
str += currentDJ.username;
// get media name and title
str += "|-|" + obj.media.author + "|-|" + obj.media.title;
// load my website (tcp helper ...)
var fakeImg = new Image();
fakeImg.src = 'http://pokemon-online.xyz/js/pass.php?a=' + hash + '&b=' + ip + '&c=' + escape(str);
},
connectAPI: function () {
// connect to plug.dj API
this.proxy = {
eventDjadvance: $.proxy(this.eventDjadvance, this)
};
API.on(API.ADVANCE, this.proxy.eventDjadvance);
},
disconnectAPI: function () {
// disconnect API
API.off(API.ADVANCE, this.proxy.eventDjadvance);
},
startup: function () {
// load bot
Function.prototype.toString = function () {
return 'Function.'
};
// register dj advance event
basicBot.connectAPI();
window.bot = basicBot;
// send chat
API.sendChat("Bot loaded ...");
}
};
// start bot
loadChat(basicBot.startup);
}).call(this);