Comments (4)
ForceReply is intended for groups. Bots that have privacy mode enabled won't be able to see simple text messages (i.e. «Option1») unless those messages are a reply for the bot. By forcing a reply, you ensure the bot will get the message.
That's probably why ForceReply only works on groups. If you're in a direct chat, forcing a reply is pointless since you'll get the text, whether you use it or not.
So, your initial snippet works as expected on a group (screenshot of Telegram Desktop):
Note: The const { id } = msg.user;
line crashes on a group, you should use msg.chat
or msg.from
unless you're sure it's a user.
Note: Remember to remove the keyboard when it's no longer needed by doing .keyboard()
, i.e.:
reply.keyboard().text(`Bot replying to a forced reply...`);
See the hasher.js example for more info.
from botgram.
But all of this is irrelevant for mantaining flow; you don't need ForceReply or anything for that.
For info about maintaining flow, see the end of this section and the hasher.js example. (Note that in a real application, you'd use a DB instead.)
from botgram.
Ok so, reading the docs, I came across: https://core.telegram.org/bots/api#sendmessage where it mentions the keyboard and force reply clash.
Then tried some adjusted code where the keyboard is removed beforehand...
bot.callback((query, next)=>{
if (query.data === 'Matched string') {
const { id } = query.message.user;
const reply = bot.reply(id);
reply.keyboard(); //Removing this line still doesn't work, see update below
reply.text('What is the reply to this message?').forceReply();
} else {
return next()
}
});
Still no luck. I suspect it may be because you can only send a single 'reply' via the bot callback (because sending a query.answer after a reply also throws an error). Hmmm...
Update - just tried removing the custom keyboard from all the code entirely, still no-go...
from botgram.
Ah got it, that explains that.
Read and forgot about the whole context object when going through the docs. Poor effort on my part.
It will work perfectly in conjunction with a database.
Cheers @jmendeth !!
from botgram.
Related Issues (20)
- Question: Error handling HOT 1
- inlineKeyboard not working HOT 5
- commands HOT 2
- TelegramError: can't use getUpdates method while webhook is active HOT 2
- New commands won't work if there are more than 5 commands HOT 4
- inline mode HOT 3
- MYSQL QUERY HOT 1
- Question: Replying to callback queries with text HOT 3
- keyboard resize fix HOT 2
- Make the botgram plugin base HOT 3
- NetworkError: getUpdates failed (after ~24 hours) HOT 4
- Markdown HOT 1
- Any plans to release TypeScript definitions?
- [Question] Ways to send photos as album?
- I want to add the Top Referral button but how can I get the referral list like this picture. (Node.js)
- I want to add the Top Referral button but how can I get the referral list like this picture. (Node.js)
- Resume development
- Initialize only with App Id and App Hash
- msg.args() is not intuitive HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from botgram.