Skip to content
This repository was archived by the owner on Feb 7, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/telebot.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const request = require('request');
const socks5Agent = require('socks5-https-client/lib/Agent');

const webhook = require('./webhook.js');
const standardUpdates = require('./updates.js');
const standardMethods = require('./methods.js');
Expand Down Expand Up @@ -34,6 +36,7 @@ class TeleBot {

const poll = cfg.polling || {};

this.tor = poll.tor;
this.proxy = poll.proxy;
this.limit = poll.limit > 0 && poll.limit <= 100 ? poll.limit : 100;
this.interval = poll.interval >= 0 ? poll.interval : 300;
Expand Down Expand Up @@ -303,6 +306,15 @@ class TeleBot {
json: true
};

if(this.tor) {
options.agentClass = socks5Agent;
options.strictSSL = true;
options.agentOptions = {
// socksHost: 'localhost', // Defaults to 'localhost'.
socksPort: 9050 // Defaults to 1080.
};
}

if (this.proxy) options.proxy = this.proxy;

if (form) {
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"node": ">= 6.0.0"
},
"dependencies": {
"request": "^2.81.0"
"request": "^2.81.0",
"socks5-https-client": "^1.2.1",
"dashbot": "^10.2.1"
},
"devDependencies": {
"ava": "^0.19.1",
Expand Down
30 changes: 0 additions & 30 deletions plugins/botan.js

This file was deleted.

49 changes: 49 additions & 0 deletions plugins/dashbot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
Requires "dashbot" npm package.

Advanced analytics bot - https://www.dashbot.io/docs

Create a bot to get an API key - https://dashbot.io/bots
Platform -> Universal
*/

module.exports = {

id: 'dashbot',
defaultConfig: null,

plugin(bot, config) {

// Create a bot to get an API key - https://dashbot.io/bots
const API_KEY = config;

if (API_KEY) {

const dashbot = require('dashbot')(API_KEY).universal;

// Track every type of message
bot.on('text', (data) => {
const { from, text } = data,
uName = from.first_name + " "+from.last_name;
dashbot.logIncoming({
"text": text,
"userId": "USER"+from.id,
"platformJson": JSON.stringify(data)
});
});
bot.on('*', (msg, props) => {
if(props.type == "text") return;
dashbot.logIncoming({
"text": props.type,
"userId": "USER"+msg.from.id,
"platformJson": JSON.stringify(msg)
});
});

}
else
console.error('[dashbot] API Key not specified');

}

};
5 changes: 4 additions & 1 deletion plugins/namedButtons.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ module.exports = {
buttons: {
// myButton: {
// label: '😄 My Button Name',
// command: '/myBotCommand'
// command: '/myBotCommand',
// cb: _=> { console.log("Event My Button"); }
// }
}
},
Expand All @@ -23,6 +24,8 @@ module.exports = {
for (let buttonId in buttons) {
const button = buttons[buttonId];
if (button.label === text) {
if(typeof button.cb === "function")
button.cb(msg);
return bot.event(button.command, msg, props);
}
}
Expand Down