can Telegram CLI mimick Telegram bots? - telegram

I saw on internet that there is some programs that can use Telegram CLI.
I want to choose between them
for Telegram bot API there is much more documents explaining its functionality, but for CLI there isn't much that explains its features
it seems the only way to know about is to experiment with it.
unfortunately i don't have a linux distro installed on my pc so experimenting isn't an option right know.
so I thought to ask from people who already used it
I know about Telegram bot api, its powers and its limitations
here is my questions:
what can I do using Telegram CLI that I can't do with with bot api, and vice versa?

Telegram bot API:
do not require to register new Telegram account, so you don't need to have another phone number;
bot cannot write to user first, only after user sends a first message to bot;
already has the commands interface (/command);
can do stuff by simple HTTP POST (by sending request via cURL, for example). So you can hook to this tons of stuff (notifications about new articles at the website or so);
you can rather easily create lots of them;
you can write you own implementation in almost any programming language;
you have a list of bots you have created (thanks to #BotFather). If you have lost somehow control of your bot - just revoke the token via #BotFather and it's yours again;
pretty simple to use.
Telegram client application (in this case - CLI):
requires new Telegram account registration with phone number;
acts like any other actual Telegram user (can write to other users first, without invitation). Well, that's a good thing;
not really good cross-platform abilities for now (some lack of CLI-realisations);
not really easy to install and use;
you have to implement the commands handling part;
if you have lost your phone number - pretty much you lose this account, because it's not like you would make some precautions for CLI client account. So you will have to register a new one and repeat the setting procedure for client.
In conclusion, bots actually got rid of CLI clients, in my opinion. I had CLI account right to the moment the bots appeared. After that I deleted it and created a bot. And not just one :)
So, bots are for the "robot" stuff, and real accounts are for the real people.

The Telegram CLI library interacts directly with their MTproto protocol, which means it's like their desktop/mobile app...but for the console. You can send messages from one phone number to another. This means that when authenticating with the CLI application, you use your real number as if you were logging into the mobile application.
I wouldn't suggest using it for bot behavior as you have to write an application that wraps the Telegram CLI and parses the log file as it is displayed...since it doesn't implement all the MTproto methods and the outputs for the log file are custom...it can be quite annoying and different than what you would expect.
With Telegram CLI you can send a number to another Telegram user without having them initiate the conversation first (since it functions just like a normal Telegram client) where the Bot API requires the user to add the Bot and start interaction before the Bot knows you are there.

previous answers are almost correct. Two different interfaces for different purposes:
Telegram Bot API allows to develop a Telegram Bot.
Telegram CLI (as this one, as an implementation example: https://github.com/vysheng/tg) are telegram client implementations, running from command line, based on MTproto protocol, as Chris Brand said.
As a bot developer, I'm interested to have a TG CLI interface (2) to automatize dialogs tests, with bash scripts, with a bot made with (1).

Related

Best solution for a small Discord bot and external file/db

I made a Discord bot. Its only function is if a DC member writes a keyword, the bot will send the:
link to an image
Link to a post
So, for each keyword, I have 2 URLs. Currently, this data is written in code. I wish to store this data in an external file or a database.
Now the problem is what is the best solution to host a bot and a file or database. I need a small free hosting service. Bot and data are very small really, so I don't need anything complex.
I thought about a few options now, although I don't know would it work:
to store the Discord bot at Heroku and to create a Database at the Firebase. Can the bot and db communicate this way?
to store both db/file and bot in Google Cloud micro instance (if it's for free). Although it sounds too complex for such a small task.
I've heard about the "Zapier" but I don't understand how it works, is it a good solution for my case?
In short, I need to host both a bot and a source of data, and those two should communicate. The bot should read the data.

Telethon, can I log in to many clients? What are the telegram limits?

How are you?
I am developing a telegram service for my clients.
I wanted to know if using the telegram API I can develop a service that manages the Telegram account of each client of mine (and if I can do this at scale with my api_id and hash_id) or does Telegram put some kind of restrictions?
Being able to develop this would be of great value to my clients but first I want to know if I am breaking any telegram rules. I was looking but I did not find anything very clear.
The main functionalities would be to manage your chats, folders, push notifications.
Do you know with what precautions I must have to develop this?
Thanks!!

How do I send & receives Telegram messages programmatically?

I want to create an app that sends telegram messages to different people by phone number, and/or telegram id.
I've heard about the "Telegram Bot API", but from my understanding it has some limitations (like it can't send messages unless users authorize it and send the first message to it, and it doesn't support sending messages using phone number)
And there is the "Telegram API", which looks like a lot of work and coding..? I'm a 1 man developer and I don't want to spend years to create a Telegram app from scratch that talks to telegram servers and does all the protocols and then I have to update it constantly and so on and so fourth.
I just want something that is easy to code & maintain, and can use my telegram account to programmatically send/receive messages. That's it. Something like :
send.message(phone number, message)
or some sort of REST API that let's me authenticate my telegram account and then provides methods that I can use to send messages to contacts.
Any ideas on how I can implement this? Any pointers would be appreciated!
Have a look at MTProto libraries like telethon or pyrogram. They are user-friendly (with lots of helper functions to abstract raw telegram api calls and their interfaces somewhat resemble the telegram bot api)
Here is a sample code (from the telethon docs):
from telethon import TelegramClient
# Remember to use your own values from my.telegram.org!
api_id = 12345
api_hash = '0123456789abcdef0123456789abcdef'
client = TelegramClient('anon', api_id, api_hash)
async def main():
# You can send messages to yourself...
await client.send_message('me', 'Hello, myself!')
# ...to some chat ID
await client.send_message(-100123456, 'Hello, group!')
# ...to your contacts
await client.send_message('+34600123123', 'Hello, friend!')
# ...or even to any username
await client.send_message('TelethonChat', 'Hello, Telethon!')
with client:
client.loop.run_until_complete(main())
Actually, telegram did a decent job to provide a powerful yet very simple API for its Bots (Attention: You can also use telegram applications like MadelineProto or telegram CLI to send messages and this is different from using Bot APIs. The applications are like your mobile/desktop app and use a real account with a particular authenticated phone numbers and you can do mostly anything that you can do with your phone app. But this is a different story).
For sending messages using bots, you can find all the documentations here. To use these APIs, you need:
Create a bot using Bot Father robot: he will help you to create a robot and will eventually give you some secret token that you should use with your robot
Some users should "/start" your robot. After starting a robot or any communication from user, you have two different options: (i) you can read the updates by a polling the updates from Telegram server using update method or (ii) setting a webhook: this way, telegram will call that webhook to make you inform about the message. Either way you use, to send message to an account you need the so called "chat_id" of that user (and you should obtain it using one of the mentioned approach)
The final step is to send a message: for the simplest case, you want to send a simple text message to a person with some particular chat_id. You only need to call this URL (i.e. the API):
https://api.telegram.org/bot{BOTTOKEN}/sendMessage?chat_id={CHAT_ID}&text={SOME_TEXT}
With this sort of calling REST api, you can call many of the functions and this is only the first step and you can do much more complex and fun stuff! For many languages, there are some packages to work with the API which make everything simple and abstract to developers. A list of most popular packages could be found here.

Telegram client to listen for channel updates

I need a way to automate processing of messages/files sent in a Telegram channel. I've been told that is can't be done with a telegram bot since they can't join channels, nor am I the owner of the channel, so I would need to set up a client or to use regular Telegram API to be able to do that. I'm looking for guidance, suggestions, anything that could help me. The script/client will have to run on Windows (so I can't use the cli linux version).
You can try UNOFFICIAL PWRTelegram API, it can be login in use a user account, and have HTTP API like bots.
You can click here to see usages.

Tools for receiving build notifications in Skype group chat

My team uses skype group chat, and I would love to have a tool that could post notifications to our group chat.
I would like to avoid relying on an RSS feed, but it may come down to that. But even that it seems hard to find -- there seems to have been a tool called Anothr that perhaps went out of existence.
I would also prefer to not have a 3rd party (outside of Skype) that receives the messages -- e.g. I don't want a bot that is hosted by a third party on a server somewhere, with their bot sitting in our group chat.
You did not state what kind of build server you use.
If you are happy with Jenkins, there is a plugin for that:
https://wiki.jenkins-ci.org/display/JENKINS/Skype+Plugin
I did not check whether it can send groupchat messages, though.

Resources