I'm coding a telegram bot with Telegraf on node.js and I need to get some information about users. For example, the bot is asking them where they are from. Then, I want to wait for the user's response and store it in my db. However, I don't understand how to achieve that since I can't just use a bot.on('text', ...) because I'm asking multiple questions and need to differenciate responses afterwards. I found out that there are callbacks but all that I found is for buttons and keyboards. Thanks!
Oh, I found the solution, you need to use scenes to achieve that
https://github.com/telegraf/telegraf/issues/705
Related
I was making a twitter bot with Twit, I found making tutorials using T.stream('user')
to get stream data about our account, now its deprecated. So in 2021, how can i achieve these?
requirements:
Know when someone follows my bot, and make a thanks post.
Know when someone in my followers list or following list makes a tweet.
Also I have a doubt, when we use stream, old data is also coming, so how exactly stream works? if i only want latest tweets, I have to sent get by setting interval?
For the new followers, you will need to build something using the Account Activity API, which uses webhooks to send you event messages. You will need to filter for the follow events.
For new Tweets from people you are following, you will need to poll the home timeline endpoint. There’s no realtime method for this.
I want to create a twitter bot on node.js that notifies about bans / unbans and streams on twitch but I do not know how I have seen several "tutorials" but none shows any way, I am not very experienced in this and it is my first time working with Twitch Api and Twitter Api
Assuming you are familiar with how API works in general and this is to be designed for your own channel, first I would recommend reviewing the Twitch API documentation at https://dev.twitch.tv/docs/api#introduction to learn how to get started with your app.
Once you have your client-ID and Oath2 token you will be better prepared for learning to use the API calls to gather the information you're looking to pull.
For banned users there are two ways you can pull this information with the following requests:
GET https://api.twitch.tv/helix/moderation/banned
https://dev.twitch.tv/docs/api/reference#get-banned-users
and
GET https://api.twitch.tv/helix/moderation/banned/events
https://dev.twitch.tv/docs/api/reference#get-banned-events
Depending on the amount of information you want to gather will determine which requests you want to use.
I hope this helps in your ventures.
Is it possible to send a message from a node.js server to someone's mobile number or telegram Id directly?
is it possible without using a telegram bot?
I need an API like below:
function sendMessage(senderTelegramId, receiverTelegramId, messageText)
In short: No, without a bot no way for now.
Detailed explanation:
In order for you to send users messages on telegram you would need to create your own telegram bot. They have a well documented API which you can read and play around with.
There are 2 things you should know about sending messages to users using telegram bot:
You can't just send random people messages on telegram even if you know their phone number, to send them messages you need to have their chat_id. See how in the docs
To get the chat_id the user must first click the start button that comes up when they open your bot for the first time. Telegram will send you the chat id of that user and you save it for later when you would want to send messages to that user.
There are tons of libraries that makes working telegram bots very easy, it wouldn't take you more than an hour to get started.
I hope this answers the question, feel free to ask further questions, I have made some bots and you can also play around with them to see how it works.
Cheers )
There is actually one more easiest way to send a message to chat
just fetch the URL
https://api.telegram.org/bot[BOT_API_KEY]/sendMessage?chat_id=[MY_CHANNEL_NAME]&text=[MY_MESSAGE_TEXT]
you can find more details here
https://xabaras.medium.com/sending-a-message-to-a-telegram-channel-the-easy-way-eb0a0b32968
id like to start using telegram bot, i already read the documentation, but still can't get my head, what's the difference between "getUpdates" and "webhooks"
source: telegram docs
can someone explain this in plain language
thanks in advance
The difference between "getupdates" and "webhook" is just like the difference between pull and push!
Using "getupdates" you don't even need to have a sever! You call telegram server prodically by providing bot's token and it will send you new updates if there is any. It means that your bot is always busy calling telegram even if there is just a single update per your 1000 requests!!
Using "webhook", you first notify telegram about your server ip and listening port and your public key. Then telegram will call your sever whenever there is any update.
At last and not the least If you want your bot to be faster you should use webhook.
Two method can get same content, but you can only use one of them at same time.
Webhook is dependent on HTTPS server, usually use in PHP.
If you haven't a web interface, better to choose getUpdates, which doesn't required HTTPS address to receive updates.
I have a room with a couple of bots, one of them needs to read all the messages on the room including other bot's messages.
Telegram API says bots can't see other bots message otherwise they might get caught in a "loop".
Since i really need to work around this i'm wondering if there is a known workaround?
There cannot be any workaround using the Bot APIs since the messages in getUpdates or webhook of the Bot will be from Users alone.
One workaround could be to use the telegram-cli and create a normal user as a Bot.