How to copy telegram usernames to Spreadsheet - telegram

Create a Script or bot to copy the list of usernames from my telegram channel to google spreadsheet.Can i use the bot api to do the job.

First of all, regarding your question - you can't.
But you can try some other things:
You can create a bot that will track the service messages of the channel, and will record the joining/leaving of users. If you have a new channel or with small amount of people - you could do that, and complete the few users already in the channel manually.
You can use Telegram Web to open the list of users of your channel, and then use some javascript to extract the names from the list.
You could also simulate clicks on each user to get more details about it, also automatically.
Another point, is that not everybody has a username. So the only certain thing you can get for sure is their name, which would be at least 1 character.

Related

Can another telegram user make me access his bot?

My friend has a tranding bot made with BotFather.
Is there a way to make the bot shared betweeen our account in a way we can use it together?
Bot usernames are unique to each Telegram account and only that account is able to change the settings of the bot.
But you can make use of a bot through its API_TOKEN which you can get from botfather.
It looks like this:
300123900:BARsAbMYBJv5wFhzNJ-Gbx678qpln7IgvzI
If you share the token with anyone, they can use your bot. They will receive an error if they try to use it at the same time (calling getUpdates method from more than one instance would reject the caller except for the first one).
If by sharing you meant using the bot (not developing it), you can't do that unless the bot's developer designs it in a way that multiple Telegram accounts messaging the bot are considered one account.

how to read/receive telegram channel messages in my telegram bot?

i'm trying to create a bot which can read/receive all messages in a specific channel and send them to me .
my problem here is that i can't find a way to access those messages in my bot
important thing is:
i'm not admin or creator of that channel
i don't want to ask the creator to add my bot as administrator
i've searched in google but i wasn't able to find a solution
and i'm also sure that it is possible to do it, because there are already some junction bots with exact same performance .
any references or suggestions are appreciated .
As already pointed out in the Telegram group of python-telegram-bot, bots can't receive messages from channels where they are not an admin. If you want something like this, you'll have to use a user bot, e.g. a program that controls your private Telegram account (in contrast to controlling a bot account). See here for some info on user bots.
Note that also the provider that you linked seems to be using userbots behind the scenes. More precisely, the docs on the so called "DirectConnection" state that you need to enter a phone number (associated to a telegram account) and then "Follow the instructions" which probably just means to enter the verification code that Telegram sends you. Phone number + verification code is exactly what is needed to control your private Telegram account.
Disclaimer: I'm currently the maintainer of python-telegram-bot.

How can a telegram get a list of all chats he participates in?

Relates to Retrieve all chat ids using Telegram bot but 3 years later.
My use case is a bot that notifies chat participants of home automation events. Any user might create his own chat and receive events or send commands.
Currently, it seems that the bot has no option to find the chats that it participates in. Even a potential workaround like using GetUpdates(0) seems to retrieve only new message ids which makes it impossible to get a complete list of chats from looking at the received messages.
Is there a stable solution for doing this?
This is not possible from Telegram's API. Howerver,
A bot will receive a new_chat_members which could be the bot 'joining another group':
new_chat_members -- Array of User -- Optional.
New members that were added to the group or supergroup and information about them (the bot itself may be one of these members)
To remember each user/group, you'll have to save each chat/user_id into a database.
The bot will also receive the opposite left_chat_member so you'll know when to delete a database entry.

Get some sort of notification on certain events in public channel

I'm on a telegram group of wich I'm not admin. In that particular channel, there are lots of messages and "useless" information. I want to make something so when someone in the group says a particular word, I'll get a notification (maybe a private msg?). I've searched but other answers mention the bot API, but, as far as I have found, bots can't be added to groups without being admin, not even with the invitation link. How can I access the messages of the group to process them?
As you said, bots can't get message in channel without administrator permission, and they can't join group by themselves.
If you want to get all messages in group, please disable privacy mode via /setprivacy in #BotFather, and re-invite to group.

How to echo message at telegram /start?

I'd like to set up a authentication through telegram using it's deep linking api.
In order to authenticate, in my app I ask users to click on a link like:
https://telegram.me/myloginbot?start=somesecretkey
If I understand the docs correctly, I should expect the bot to echo back somesecretky to my server.
Now, this step of the docs is unclear to me:
Configure the webhook processor to query Memcached with the parameter that is passed in incoming messages beginning with /start
If I understand correctly, I need to configure myloginbot so that when the user clicks start button on the bot's page, the bot echos back to my server a url containing somesecretkey and some user info. But I don't know how to do so.
In this answer, it is suggested that:
Let the bot retrieve the username by querying the database or key-value storage for unique_code.
But I don't know how can I make the bot query the (presumably remote) database.
So really appreciate your hints.
My understanding to deep linking is this:
You have a database of users. Each user has an ID. Suppose you want your Telegram bot to communicate with user 123. But you don't know his Telegram chat_id (which the bot needs in order to send messages to him). How do you "entice" him to talk to the bot, thus revealing his chat_id? You put a link on a web page.
But the link has to be "personalized". You want each user to press on a slightly different link, in order to distinguish them. One way to do that is to embed user ID in the link. However, user IDs are not something you want to expose, so you generate a (temporary) key associated with each user ID, and embed that key in the link. For example, user 123 has the key abcde. His personalized link will be:
https://telegram.me/myloginbot?start=abcde
Someone clicks on the link, and is led to a conversation with your bot. At the same time (or when he presses the START button), your bot will receive a message:
/start abcde
On receiving that message, the bot sees that abcde is associated with user 123. Telegram chat_id can also be extracted from the message. Now, the bot knows user 123's chat_id, and can send him messages afterwards.
To experiment with deep linking, you need a bot that can handle /start messages, supported by a "datastore" that remembers the key-ID associations. When Telegram docs say "memcache", they just mean something that stores the key-ID associations. For an experiment, it may be as simple as a dictionary, or an associative array. In real life, it may be Memcached (the memory caching software), or a database table.
If you use Python, I recommend taking a look at telepot, a Python framework for Telegram Bot API. It does not do deep linking per se, but it does help you in receiving messages for a bot, and other bot operations in general. I also have an example there demonstrating how to output a personalized link, set up a webhook, and parse the incoming /start command with the key.

Resources