Create plugins/conexion.js
Browse files- plugins/conexion.js +46 -0
plugins/conexion.js
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import QRCode from 'qrcode';
|
2 |
+
var message="Esperando conexion";
|
3 |
+
export default function(client,app,special){
|
4 |
+
client.on('ready', () => {
|
5 |
+
message="Su cliente esta funcionado";
|
6 |
+
console.log('Client is ready!');
|
7 |
+
});
|
8 |
+
client.on('message_create',async msg=>{
|
9 |
+
if(!msg.fromMe || msg.body.toString()!=`${special.prefix}ping`) return;
|
10 |
+
await msg.reply("PONG!");
|
11 |
+
})
|
12 |
+
client.on('loading_screen', (percent, message) => {
|
13 |
+
console.log('LOADING SCREEN', percent, message);
|
14 |
+
});
|
15 |
+
client.on('authenticated', () => {
|
16 |
+
console.log('AUTHENTICATED');
|
17 |
+
});
|
18 |
+
|
19 |
+
client.on('auth_failure', msg => {
|
20 |
+
console.error('AUTHENTICATION FAILURE', msg);
|
21 |
+
});
|
22 |
+
|
23 |
+
|
24 |
+
client.on('DISCONNECTED', () => {
|
25 |
+
console.log('Desconectado');
|
26 |
+
});
|
27 |
+
client.on('qr', qr => {
|
28 |
+
console.log('Codigo Qr recibido');
|
29 |
+
QRCode.toDataURL(qr, function (err, url) {
|
30 |
+
message='Escanee el codigo(Si no deja, reinicie el espacio, asegurese que el estado diga "Running")<br><img src="'+url+'"></img>';
|
31 |
+
|
32 |
+
});
|
33 |
+
|
34 |
+
|
35 |
+
});
|
36 |
+
client.on('remote_session_saved', () => {
|
37 |
+
message="Sesion guardada(MongoDB)";
|
38 |
+
console.log("Guardado");
|
39 |
+
});
|
40 |
+
app.get('/', (req, res) => {
|
41 |
+
res.writeHead(200, { 'Content-Type': 'text/html' })
|
42 |
+
res.end('<head><meta http-equiv="refresh" content="5"></head>'+message);
|
43 |
+
});
|
44 |
+
return {name:"Sistema",
|
45 |
+
comandos:[{name:"ping",description:"Consulta si esta encendido",args:[""]}]}
|
46 |
+
}
|