MajMcCloud / TelegramBotFramework

This is a context based application framework for the C# TelegramBot library.
https://www.t.me/tgbotbase
MIT License
149 stars 43 forks source link

How to use the repo to chat with some chat bot? #24

Closed zydjohnHotmail closed 2 years ago

zydjohnHotmail commented 2 years ago

Hello: I have a number of json format text in foreign language, which I don’t understand. I found that there are some translation bot in Telegram, it can translate the text into English. I did some test by copying and pasting some Json format text to the chat bot, and I got reply with translation very fast. The Json format message looks like this: { "id": 123, "type": "message", "date": "2022-06-22T01:00:22", "date_unixtime": "1655859622 ", "edited": "2022-06-22T01:22:36", "edited_unixtime": "1655868575", "from": "Україна 24", "from_id": "channel12345", "text": [ "⚡️", { "type": "bold", "text": "Термінове Звернення Президента України Володимира Зеленського!" }, "Дивіться онлайн: ", { "type": "link", "text": "https://youtu.be/aLOh7uyk2-w" }, "" ] },

I want to know how I can write C# program to send json format text to the translation bot, let’s say its ID# 123456789.

I have used other C# Telegram framework, I can start my bot and join some public channel. But I don’t know how to chat with a translate bot or chat bot. I want to know how to send json format text to chat bot and read reply from it. What is the speed limit to send json format text? If I send too quick, I will be banned. So I want to set some kind of speed limit, like 10 json format data per second? Is this speed too fast or it is OK? Please show me some code samples on this topic. I also need some code samples on how to reuse session data after I got verification code. By the way, I am using Visual Studio 2022 Version 17.2.5 on Windows 10 Version 21H2. Thanks,

MajMcCloud commented 2 years ago

Hey @zydjohnHotmail

if the translation bot is a telegram bot this is not possible. Cause this framework is only for building you own bots.

And Telegram bots do not can communicate with each other. Telegram limits are around 30 (+/-) messages per second.

Warm regards Florian

zydjohnHotmail commented 2 years ago

Hello: Thanks for your reply. Is there any way I can write some C# code to simulate human copy and paste some text into telegram bot and read reply from the translation bot?

MajMcCloud commented 2 years ago

Depends on the platform you are on. But I would say probably it is possible. But I dont know how yet.

zydjohnHotmail commented 2 years ago

Hello: I am using C# on Windows 10, basically I use Telegram desktop version 4.0.2. I want to know if I can send HTTP message to telegram translation bot via HttpClient/WebClient and get response from translation bot with http communication?

MajMcCloud commented 2 years ago

Could be possible, but you have to build your own telegram client for that or use an existing one. Why not using a translation api of some available services ? If your main point is to translate something ?

zydjohnHotmail commented 2 years ago

Hello: It could be a good idea on build my own telegram client, but I have to learn how to do this first. To use a translation bot has one important feature: the preformance. If I can get 30 messages per second, then within 10 hours, I can get more than 1M messages with translation. Using API or other ways, the performance may not be good enough. If I send 1M messages to use API, then the web server could block my IP for some time. I can use C# to easily send only one message (one Json object) to translation bot each time. Sometime, it is necessary to get 1M messages to translate, even it is not often, but it is the maximum requirement. Thanks for your advice.

MajMcCloud commented 2 years ago

How is that Bot called ? Maybe you find a website of them or get an info which service they are using or if they build one on their own.

zydjohnHotmail commented 2 years ago

The bot is made by Yandex, I think they have their own API or other stuff. But the bot works every fast, usually give translation in the same second when I copy/paste the json text. I don't think I can get too much information from their website. I can give you the bot ID: @YTranslateBot, can you find some useful information? Thanks,

MajMcCloud commented 2 years ago

As far as I can tell this is not an official bot. Which means it has its custom api. I can imagine to decompile the official yandex translate android app and use the service from inside. Maybe the bot developer did it the same.

zydjohnHotmail commented 2 years ago

Hi, If you think it is not an official bot, then can you tell me what is the official bot in telegram?

MajMcCloud commented 2 years ago

There is no offical bot. As you can see on their websites.

MajMcCloud commented 2 years ago

I'll close this now, cause the topic should be cleared.