Skip to content

Instantly share code, notes, and snippets.

@code-scan
Last active December 25, 2018 10:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save code-scan/b02dcd7523b6c3f6795a2960f07f3e1f to your computer and use it in GitHub Desktop.
Save code-scan/b02dcd7523b6c3f6795a2960f07f3e1f to your computer and use it in GitHub Desktop.
const TeleBot = require('telebot');
var request=require("request");
var fs = require("fs");
var path = require("path");
var iconv = require('iconv-lite');
var moment = require('moment');
var dbstatus=false;
var status=true;
var deltime=60000;
moment.locale('zh-cn');
var query_id = fs.readFileSync('./session.txt', 'utf8'); // session里面存的id列表
console.log("[*] Query_id "+query_id);
const bot = new TeleBot({
token:'token',
polling: { // Optional. Use polling.
interval: 1000, // Optional. How often check updates (in ms).
timeout: 0, // Optional. Update polling timeout (0 - short polling).
limit: 100, // Optional. Limits the number of updates to be retrieved.
retryTimeout: 5000, // Optional. Reconnecting timeout (in ms).
//proxy: 'http://192.168.199.100:1087' // Optional. An HTTP proxy to be used.
//proxy: 'http://127.0.0.1:1080'
}
});
bot.on(['/myid', '/hello'], (msg) => msg.reply.text(msg.from.id)); //获取你的id,可以获取之后返回一个网址 如 t00ls.net/tg.php?tid=xxxx然后登陆吐司账号关联起来
bot.on(/^\/add (.+)$/, (msg, props) => { //添加用户id到白名单,如果是绑定账号可以把论坛id和tg的id存在数据库里或者文件
if(msg.from.id==1173422767){ // 667是管理员id
const text = props.match[1];
query_id=query_id+text+'|';
fs.writeFile('./session.txt', query_id,function(err){
msg.reply.text("ok");
});
}else{
msg.reply.text("no prem!");
}
});
bot.on('/allid', (msg, props) => {
if(msg.from.id==1173422767){
msg.reply.text(query_id);
}else{
msg.reply.text("no prem!");
}
});
bot.on('/log', (msg, props) => {
if(msg.from.id==1173422767){
bot.sendDocument(msg.from.id, './logs.txt', { replyToMessage: msg.message_id });
}else{
msg.reply.text("no prem!");
}
});
bot.on(/^\/time (.+)$/, (msg, props) => {
if(msg.from.id==1173422767){
const text = props.match[1];
deltime=text;
msg.reply.text("ok , time is "+(deltime/1000)+"s");
}else{
msg.reply.text("no prem!");
}
});
bot.connect();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment