telebot-polycb/config.js

90 lines
1.9 KiB
JavaScript
Raw Normal View History

2019-10-23 11:07:22 +02:00
const fs = require('fs');
const Markup = require('telegraf/markup');
const Extra = require('telegraf/extra');
const request = require('request');
const db_json = require('./jsondb.js');
const url = 'https://polylan.ch';
const groupid = -14795224;
const regex_pre = /<!--STARTOFPREINS-->([0-9]*)<!--ENDOFPREINS-->/
const regex_ins = /<!--STARTOFINS-->([0-9]*)<!--ENDOFINS-->/
function get_count(){
return new Promise((resolve,reject)=>{
request(url, function (error, response, body) {
try{
let d1 = parseInt(body.match(regex_pre)[1]);
let d2 = parseInt(body.match(regex_ins)[1]);
resolve([d1,d2]);
}catch(e){
reject(e);
}
});
})
}
//=== MAIN MODULE CONFIG
module.exports = function(name){
this.db = db_json(name);
return {
name : "PolyCB",
key : "pycb",
version : 0.1,
requirements : {
gps: false,
},
text : [
{
trigger : ["/combien"],
public : true,
desc : {0:"Shows how many people registered to polylan",
1:"Affiche combien de personnes se sont enregistré pour le PolyLAN",
},
requirements : (bot,event,message)=>{
return new Promise((resolve, reject)=>{
return resolve(200);
});
},
action : (bot,event,message)=>{
return get_count().then(res=>{
2019-10-23 11:16:29 +02:00
return event.replyWithMarkdown("*"+res[0]+"* pré-inscrits\n*"+res[1]+"* inscrits");
2019-10-23 11:07:22 +02:00
}).catch(err=>{
return bot.error(err);
});
}
},
],
reply : [],
regex : [],
media : [],
callback : [],
inline : [],
new_member : (bot,event)=>{},
weburl : [],
cron : [
{
cstr : '59 34 0,6,12,18 * * *',
public : true,
desc : {
0: "Tries to reply to the PolyCombien Values At right time",
},
params : [ null, true],
timezone : 'Europe/Zurich',
2019-11-17 21:47:12 +01:00
action : ()=>{
2019-11-06 18:02:21 +01:00
//return this.bot.telegram.sendMessage(groupid,"Mieux que 0 !",{});
2019-10-23 11:07:22 +02:00
}
}
2019-11-17 21:47:12 +01:00
],
register_bot: (bot)=>{
this.bot = bot;
}
2019-10-23 11:07:22 +02:00
}
2019-11-06 18:02:21 +01:00
}