-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
69 lines (61 loc) · 1.67 KB
/
index.ts
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
import conf from './bconfig.json' assert { type: 'json' };
import Client from './Client.ts';
import Ubox from './ubox.ts';
const bot = new Client(conf.token, conf.name, conf.room, conf.color, conf.uri);
const box = new Ubox();
bot.mppClient.addEventListener('open', () => {
bot.connect();
bot.moveMouse(Math.random() * 100, Math.random() * 100);
});
//https://mppclone.com/?c=ts%20test%20room
bot.mppClient.addEventListener('message', e => {
const json = JSON.parse(e.data)[0];
if (json.m == 'a') {
const message: string = json.a;
const uname: string = json.p.name;
const ucolor: string = json.p.color;
const args = message.split(' ');
const command = args.shift();
const input = args.join(' ');
const uid: string = json.p.id;
// const umx = e.x;
// const umy = e.[0].y;
// console.log(json);
if (command == `--help`) {
bot.chat(
'Available commands: ts, about, disconnect, restart, whoami, dm.'
);
}
if (command == '>') {
if (
uid != '819695470c858041f5f5ad6f' &&
uid != '3bff3f33e6dc0410fdc61d13'
)
return bot.chat('No permission.');
try {
const tcode = eval(input);
bot.chat(`< ${typeof tcode} | ${tcode}`);
} catch (err) {
bot.chat(`< Error | ${err}`);
}
}
if (command == '--about') {
bot.chat('bot that is used to test TypeScript code');
}
if (command == '--disconnect') {
if (
uid != '819695470c858041f5f5ad6f' &&
uid != '3bff3f33e6dc0410fdc61d13'
)
return bot.chat('No permission.');
bot.disconnect();
} // go to cmd.ts
if (command == '--whoami') {
bot.chat(`${uname}, ${ucolor}, ${uid}.`);
}
if (command == '--dm') {
bot.chat('Sent.');
bot.dm(uid, input);
}
}
});