I know how to get all the IDs from a chat via the received message (update.message.chat.id)
However I couldn't find a function in the docs of Pybot that allows to get a message with a specific ID from the chat (from the past).
Is there such a function available?
EDIT:
I found a function that should do what I want but it seems it is not available in Python-Telegram-Bot?
https://core.telegram.org/method/messages.getMessages#
According to the note, it should be useable by bots as well.
There is a difference between Telegram API and Telegram Bot API.
Link you provided is about Telegram API, and Bot API doesn't have method like that you want.
Related
What I'm trying to understand is how Discord.py creates and sends responses from their on_message function.
Take this as an example:
#client.event()
async def on_message(message):
print(message.content)
I'm trying to understand how Discord.py retrieves new messages from Discord without refreshing the channel histories for every single channel in every single server to scan for new messages which would surely hit Discord's rate limit.
Is there a way to scan for new messages with Discord's API using fetch or post requests? I am not trying get a solution on how to scan new messages using an already made library. I want to achieve this using only the requests module in python.
I'm trying to understand how Discord.py retrieves new messages from Discord without refreshing the channel histories for every single channel in every single server to scan for new messages which would surely hit Discord's rate limit.
Discord bots establish a websocket connection with Discord's servers, which is essentially a (secure) two-way tunnel. This means that once the connection is up, Discord can send events to you. Instead of you having to manually fetch every single channel, Discord tells you "Hey, a message was created", and the payload attached will give all the additional info about it.
The Discord (not discord.py) docs have detailed info about how everything works behind the scenes, to help the people creating the Bot libraries for you. For example, this section details which types of events Discord can send to you. To see how something is constructed, click on one of the event types and read up on the data that Discord provides.
Is there a way to scan for new messages with Discord's API using fetch or post requests? I am not trying get a solution on how to scan new messages using an already made library. I want to achieve this using only the requests module in python.
Not really, unless you do in fact send a GET for every single channel, which will get you ratelimited. There's really no reason to ever use only GET/POST requests (other than Webhooks, where you just send a POST with your info to send a message to a channel without a bot).
If you'd like to read up on Discord's API, the docs I linked contain a full spec of everything, so you could try to do whatever your heart desires (... and the API supports).
My goal is to make a Telegram Bot using Python that does the following:
The user types a command
The bot explains what the user should type next.
The user types certain information
I use that info to fetch a value in a python dictionary.
The bot replies with that info
I have already created the bot and set the command. The problem is that I don't know how to keep the bot "listening" . I have looked up in the docs but I have only found getUpdates, which gets the user's responses but only when you hit run.
res=requests.get(url=f"https://api.telegram.org/bot{bot_token}/getUpdates")
I would like to set a webhook, and I know there is a method for this but I'm not shure about how this works.
When you are a PHP programmer, setting the webhook through a URL and using setWebhook would do the trick and telegram will send the result to this link whenever a user sends an update to the bot. But, Python programmers have to use a different approach, I think. The main, and while, the easiest approach to make the bot listen permanently to the request is to python-telegram-bot module.
There are a few links that can help to build your first pythonic bot that can respond to users' updates.:
Python-Telegram-Bot Repository, which is the repository of the module.
A few examples of bots created using this module, can give you insight into the process of creating your first bot.
A conversation bot
I am writing a telegram bot in python.
One of my bot functionalities is to delete all of the messages in the chat. I find the function bot.delete_message however it delete only one message according to message id and I don't have the ids for every message.
I also saw in the telegram api some functions that can help me, like https://core.telegram.org/method/channels.deleteHistory or https://core.telegram.org/method/messages.getHistory (will allow me to get the id of every message and then delete them). but I don't see how I can call these functions in the python api.
Is there a way to call these functions with the python api? or perhaps is there another way to delete entire chat history?
Telegram Bot API doesn't have methods to delete multiple messages. You have to know message_id to delete it.
The methods which you've mentioned in the question are not part of Telegram Bot API, but they're part of Telegram API. python-telegram-bot library has support to only Bot API. You can make use of telethon library which supports Telegram API.
I'm trying to check whether a twitch stream is online using python. This question has been asked here before however now I think the responses are out of date in relation to the twitch API.
For example https://api.twitch.tv/kraken/streams/syndicate just says that I did not specify a user ID.
{"error":"Bad Request","status":400,"message":"No client id specified"}
Thanks for any help!
As stated in the Twitch documentation, a client ID is required or a 400 is returned.
To get one go to here and register an application on the Twitch developer portal
After that, you can choose how you send the client-id, either through a request header called Client-ID or as a query parameter called client_id
For more information, you can find everything I've just summarised here
I built a Slack bot and tried to make my bot interact with another bot in the a channel, but it seems not working.
For example, I want to use the voting function of Polly (a Slack bot).
Regular users like me send /polly "Which is better?" "Tacos" "Pizza" message and Polly will create a Slack poll in a channel. But when I made my bot send the same message in the same channel (I use python-slackclient and chat.postMessage method), the message just like a simple text, in other words, it didn't trigger Polly.
So, in a channel, how can a Slack bot interact with another bot and trigger some functions of it?
Did anybody ever do something like this?
update
https://github.com/ErikKalkoken/slackApiDoc/blob/master/chat.command.md
I tried this method but got another problem...
The error message is
{'error': 'missing_scope',
'needed': 'post',
'ok': False,
'provided': 'identify,bot:basic'}
The Oauth token requires "post" scope, but official documents show that "post" scope is deprecated. How do I make my token have "post" scope?
I have tried to make two bots interact and didn't find it to work. Slack somehow recognizes the source of the message and if the message is sent by a bot or an app, it fails to respond to it. I have even tried to post the message as a user through the slack API but did not get it to work.
However, Bots can use the chat.command method to invoke a slash command.
Unofficial documentation can be found here:
https://github.com/ErikKalkoken/slackApiDoc/blob/master/chat.command.md
You are correct that the undocumented chat.command requires the post scope to work, which is not available in the standard OAuth process (e.g. you can not choose it as scope on the Slack app config site.)
The only currently working solution that I know of it to use a legacy token.
See also this answer.