I have problems with telegram's api in c#. I search any solutions how to recevie message from Telegram using API. I found only library for Telegram BOT(send message etc.), but I need only recevie message from one user. There is option "Get.Message" in Telegram Api, but I can't find simply library to use this option.
using the telegram client api you can get updates automatically from telegram when a message is received. You simply need to handle the response once the session is created and a connection is made
Just in case you don't want realtime updates, you can use messages.GetHistory and supply the number of messages you'd like to retrieve. You need to provide the chat ID and access hash which you can get from contactsResolveUsername
enter link description here
Related
Telegram In Dart or http request
How to get group all messages by using dart or http
Note that I have my bot token and I wanna use it in dart ("No another Languages") or http
Currently you can't get old messages from a group with the Bots API.
You can save every message in a database for a later use, but old messages are not accessible. The only way is by using the client API.
Is it possible to send a message via Telegram API to the Saved Messages chat?
I have been looking all over the internet but could not find any information. I would think this would be possible.
If you mean the main mtproto api, yes you can send yourself a message by your id or username and telegram will place it in saved messages.
You did not mention which API you use, but this is how you do it in Telethon:
client.send_message("me", "hello")
But if you mean bot api, it's not possible for bots to send messages to your saved message.
I tried this:
https://api.telegram.org/botXXtokenxx/sendMessage?chat_id=chat_id&text=text
But this is to send a message from the bot.
But what I need to do to send to the bot? (not from the bot)
You can either use a regular Telegram client (Telegram, Telegram X, Telegram Desktop, etc) to do it manually, or if you need an API (for whatever reason)...
You need the client API.
https://core.telegram.org/#getting-started
Once you have an API key for the client API and all that, you can send messages as explained here.
https://core.telegram.org/method/messages.sendMessage
Note that a human should be triggering this, as Telegram encourages (may be against ToS?) using a bot API for programatic access rather than the client API.
I have subscribed to a telegram bot (I am not the owner/admin of that bot) which sends messages in a particular format. I need to do is to parse the incoming messages and used the parsed information as parameters to a trading API.
Hence, I need a daemon sort of thing which runs on my laptop and keeps listening for any new messages from that bot, and when it receives one, then parse it.
Can the Telegram Bot API handle this? In other words if I create a bot will it be able to read the messages sent to me by the other bot
Did you try to search on official documentation API or FAQ?
https://core.telegram.org/bots/faq#why-doesn-39t-my-bot-see-messages-from-other-bots
You can do it using python and python-telegram-bot package.
When you create a bot in your python code using the following code:
bot = telegram.Bot("Your bot's token")
you are able to get the new messages sent to your bot using bot.get_updates() and there's a feature to check if the sent message is from a bot or not. You can write a function that returns a boolean telling whether is the message sender bot or not:
def is_bot(update=dict()): #"update" is one of the messages which got returned from get_updates()
message = update["message"].to_dict()
return message["from"]["is_bot"]
for update in bot.get_updates():
print(is_bot(update))
I'm working on Telegram bot api in my java application. I have created a super group and add my bot to this as an administrator. I want to get all messages in that super group(not deleted messages) via bot. Is there any useful method for doing that?
Yes. first, you should "disable" privacy of your bot so it can access to all messages in groups. second, use getUpdates to see recent updates and user messages will be there.