serjopepper / bot-brother Goto Github PK
View Code? Open in Web Editor NEWNode.js framework for telegram bots
Node.js framework for telegram bots
bot.command('round').keyboard(...).answer(function (ctx) {
...
});
doesn't work.
Is it possible to have this enabled? I don't necessarily have to send a message before every a command. Specifically, when redirecting with ctx.go()
, it isn't always necessary in my use case.
Already tried
bot.command('round').keyboard(...)
.invoke(function (ctx) {
return Promise.resolve(ctx);
}).
.answer(function (ctx) {
...
});
doesn't seem to work either.
Unhandled rejection TimeoutError: operation timed out
at afterTimeout (/root/bb/node_modules/bluebird/js/main/timers.js:16:15)
at Timeout.timeoutTimeout [as _onTimeout] (/root/bb/node_modules/bluebird/js/main/timers.js:59:9)
at listOnTimeout (node:internal/timers:564:17)
at process.processTimers (node:internal/timers:507:7)
Is there a plan to extend bot-brother
to handle the new Telegram Bots 2.0 API?
Good night
I want to make a bot answer my 3 messages and at the end of the answer will combine the message I'm delivering.
Example
me> / unlock
bot> what is your account?
me> drow-ranger
bot> what is your computer name?
me> PC-99
bot> what's your ticket number?
me> TICKET-001
bot> admin pls unlock drow-ranger on PC-99 with TICKET-001
is this possible? Please help
bot.command('unlock')
.invoke(function (ctx) {
ctx.data.user = ctx.meta.user;
return ctx.sendMessage('Hello <%=user.first_name%>. what is your account?');
})
.answer(function (ctx) {
ctx.data.answer = ctx.answer;
return ctx.sendMessage('User Account: <%=answer%>. what is your computer name?');
});
so far I use the command above. but can only accept 1 message. Please help
Is it possible to use asynchronous db with BotBrother. As I understood callbacks must always return promises. But when I want to get some information from db and send it to user I can't return "sendmessage promise". So it making imposible to use async dbs.
Am I right?
How to reset current state after first answer on command?
For example user need to add his name once:
(how it has to be)
U: /name
B: Write your name
U: John
B: Thanks, John.
U: Mike
....nothing happens
(how it is)
U: /name
B: Write your name
U: John
B: Thanks, John.
U: Mike
B: Thanks, Mike.
U: Pavel
B: Thanks, Mike.
..
These methods doesn't help:
context.go()
context.goParent()
context.goBack()
context.repeat()
context.end()
I try use your awesome framework to build a simple test on heroku and I received this error on deploy:
webhook res: undefined
index.js
var bb = require('bot-brother')
var bot = module.exports = bb({
key: process.env.TOKEN,
webHook: {
url: process.env.HEROKU_URL,
port: 8443,
https: false
}
})
Have you any suggestion? Thank you!
Hello everyone!
I'm writing a Telegram bot that works also with normal conversation. I need to handle context and middleware issues that this awesome lib provides but I'm not sure how to use it.
The bot.api.on('message') receives the msg from Telegram, but I need to retrieve the current context to know where in the conversation the user is.
Can someone help me?
Is there any example how I get document or photo from user. Something similar with .getFile or .downloadFile methods from node-telegram-bot-api.
Can this package be used with typescript ?
Is there currently a way to match any regular expression and pick-up text that isn't an answer to a current session ? I don't see a way to do an arbitrary match on any incoming text if it doesn't start with /
...
Использование context.inlineKeyboard не дает никаких результатов, кроме ошибки в консоле сразу же после отправки сообщения
UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: 400 {"ok":false,"error_code":400,"description":"Bad Request: message can't be edited"} (node:16320) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code
Если попытаться отправить клавиатура через параметр reply_markup, то она появляется в сообщении, но после нажатия появляется ошибка
Unhandled rejection SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>) at CommandHandler.handle (D:\nodejs\vkm2\node_modules\bot-brother\lib\command-handler.js:211:30) at D:\nodejs\vkm2\node_modules\bot-brother\lib\bot.js:349:42 at tryCatcher (D:\nodejs\vkm2\node_modules\bluebird\js\main\util.js:26:23) at Promise._settlePromiseFromHandler (D:\nodejs\vkm2\node_modules\bluebird\js\main\promise.js:510:31) at Promise._settlePromiseAt (D:\nodejs\vkm2\node_modules\bluebird\js\main\promise.js:584:18) at Promise._settlePromises (D:\nodejs\vkm2\node_modules\bluebird\js\main\promise.js:700:14) at Async._drainQueue (D:\nodejs\vkm2\node_modules\bluebird\js\main\async.js:123:16) at Async._drainQueues (D:\nodejs\vkm2\node_modules\bluebird\js\main\async.js:133:10) at Immediate.Async.drainQueues (D:\nodejs\vkm2\node_modules\bluebird\js\main\async.js:15:14) at runCallback (timers.js:800:20) at tryOnImmediate (timers.js:762:5) at processImmediate [as _immediateCallback] (timers.js:733:5)
Пример из readme также нерабочий. Тут даже нет метода отправки сообщения с inlineKeyboard
`bot.bommand('inline_example')
.use('before', function (ctx) {
// set any your data to callbackData.
// IMPORTANT! Try to fit your data in 60 chars, because Telegram has limit for inline buttons
ctx.inlineKeyboard([[
{'Option 1': {callbackData: {myVar: 1}, isShown: function (ctx) { return ctx.callbackData.myVar != 1 }}},
{'Option 2': {callbackData: {myVar: 2}, isShown: function (ctx) { return ctx.callbackData.myVar != 2 }}},
// use syntax:
// 'callback${{CALLBACK_COMMAND}}' (or 'cb${{CALLBACK_COMMAND}}')
// 'invoke${{INVOKE_COMMAND}}'
// to go to another command
{'Option 3': {go: 'cb$go_inline_example'}},
{'Option 4': {go: 'invoke$go_inline_example'}}
]])
})
.answer(function (ctx) {
ctx.sendMessage('Inline data example')
})
.callback(function (ctx) {
ctx.updateText('Callback data: ' + ctx.callbackData.myVar)
})
bot.command('go_inline_example')
.invoke(function (ctx) {
ctx.sendMessage('This command invoked directly')
})
.callback(function (ctx) {
ctx.updateText('Command invoked via callback! type /inline_example to start again')
})`
on original node-telegram-bot-api there is a listener for "inline_query", is there a way to work with inline_query in current version of bot_brother?
Is it possible to handle all rejections at the same time using one method?
what is the difference between:
.answer(function (ctx) {
ctx.data.answer = ctx.answer;
return ctx.sendMessage('OK. I understood. You feel <%=answer%>');
});
and:
.answer(function (ctx) {
return ctx.sendMessage(`OK. I understood. You feel ${ctx.data}`);
});
?
request_contact: true
in the node-telegram-bot-api?
Hi, thanks for job.
Dependance "botanio" is outdated.
Service is down as write in readme of this dependance, "This service will be shut down on 25th May 2018".
npm audit fix
don't like it :
node_modules/botanio/node_modules/tunnel-agent
request 2.2.6 - 2.80.0
Depends on vulnerable versions of bl
Depends on vulnerable versions of hawk
Depends on vulnerable versions of qs
Depends on vulnerable versions of tunnel-agent
node_modules/botanio/node_modules/request
botanio >=0.0.4
Depends on vulnerable versions of request
node_modules/botanio
12 vulnerabilities (5 moderate, 7 high)
To address issues that do not require attention, run:
npm audit fix
Some issues need review, and may require choosing
a different dependency.
Custom Redis options don't work for me. I had to fix directly into the redis module for now.
Don't know if this issue is related to the outdated redis module version...
--- node_modules/bot-brother/node_modules/redis/index_original.js 2016-01-17 21:12:07.000000000 -0200
+++ node_modules/bot-brother/node_modules/redis/index.js 2016-01-17 21:12:37.000000000 -0200
@@ -1262,8 +1262,8 @@
var createClient_tcp = function (port_arg, host_arg, options) {
var cnxOptions = {
- 'port' : port_arg || default_port,
- 'host' : host_arg || default_host,
+ 'port' : options.port || default_port,
+ 'host' : options.host || default_host,
'family' : (options && options.family === 'IPv6') ? 6 : 4
};
var net_client = net.createConnection(cnxOptions);
By the way, great job!
Template Literal is fastest, smallest and simplest template engine, because it use JS's literal template feature.
It's 55 times faster than EJS, and it also use less CPU and RAM ressources, so it may be a good idea to use it instead of EJS 😀
bot-brother/src/context.coffee
Line 28 in c338727
Currently reads @property {Object} command object tha represent current command. Has follow fields: name, args, type. Where type is 'answer' or 'invoke'
Might read better as @property {Object} command object that represent the current command. Has the following fields: name, args, type. Where the type is 'answer' or 'invoke'
My translation are in a json file.
When I required them:
var texts = {};
texts.es = require('./locales/es.json');
texts.en = require('./locales/en.json');
I have access to both translations.
I can do this console.log(texts.en.start.language_selected);
I got "English is selected."
bot when I do this: bot.texts(texts.en, { locale: 'en' });
It change my json and it isn't valid anymore.
My json looks like this:
{
"start": {
"language_selected": "English is selected.",
"choose_your_country": "Now choose your country"
}
}
But then when I do console.log(texts.en.start.language_selected);
it return { [Function] dependencies: [] }
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.