Telegram: Store chat id or Channel with bot inside? - python

I'm starting to learn telegram bot. My plan was to have a bot that daily sends you at a specific time a message, but also I wanted the option to manually poll the bot for getting that daily message, or a random one. Right now I have a bot running on pythonanywhere that can respond to the 2 commands, but what about sending the user the daily message at some time?
What's the way to go, create a channel and then schedule a task on my webhook to daily send the message to the channel, or store all chat-id in my service and talk to them everytime? The first one seems obviously better but I was wondering if there's some trick to make everything works in the bot.

For now I managed to create a channel, make the bot an admin and scheduled a task on the webhook to daily send a message as admin to the channel

Related

Telegram start new chat with Python

I want to start a new chat in Telegram with a Python script but I know with neither Telegram's BOT nor its API it is possibile.
I don't want the user starts the chat with a BOT before!
However I was wandering if you can achieve this in anther way. I mean, when you create a new chat with Telegram application, there will be, somehow, and endpoint which handle this request.
Why is it impossibile to create a Python script which emulates this action?
I don't want the user starts the chat with a BOT before!
This is not possible. A Bot can never start a chat, that has to be done by the user him/her self.
After the user has started a conversation with the Bot, you can send anything to the user until the user stops the conversation.

How can i get someone telegram chat id with python?

Hi everyone i want to create a new telegram bot similar to #usinifobot.
this is how it works:
you just send someone username to this bot and it will give you back his/her chat id.
i want to do same thing but i dont khow how to do it with python-telegram-bot.
python-telegram-bot can't help with this, because telegram bot api can't provide ids of unrelated entities to the bot - only ones with which bot iteracts
you need telegram client api for this and to hold a real account (not a bot) online to make checks by another library
and with bot library like python-telegram-bot you could only get ids of users who write to bot, channels and groups bot is in and reposted messages from other users
I created similar bot #username_to_id_bot for getting ids of any entity and faced all these moments

Is it possible to get all channels a slack bot is allowed to write?

I am trying to build a slack bot based on heroku and python which writes messages every 10 minutes to all channels the bot is allowed to write messages. It would be perfect if I could just read from the slack api to which channelId's the bot is connected and let the bot post the message to all channels at the same time.
Till now I couldnt find such function in the slack api. On the other hand I have to addmit that I am pretty new to slack. Is there a similiar function out there or can you think of a work around? If possible I would like to avoid storing data additionally somewhere.
Yes there is. Call users.conversations with your bot token to get the list of channels it is a member of.
From the documentation:
This method helps answer questions like:
Which conversations am I a member of?
Which public channels is my bot user in?
Do I have any direct messages open with my friend Suzy?
Is my bot a member of any private channels?

How to save a message from a telegram chat and send other messages with your own account?

I want to build a code that save a certain telegram message, from a user, as an input (ex: "David: Hello how are you doing?") and be able to send a certain message back, with my own telegram account (ex: "Me: I'm fine! How are you?")
Is there a way I can do this in python without using a telegram bot? Because I dont think bots can actually connect to your own telegram account and send messages
Unfortunately, the only way to achieve this kind of results is by creating your own customized Telegram app, take a look at the API docs at https://core.telegram.org/api

Scrape Telegram channel for changes

Can anyone point me to a way to programatically check for changes in a Telegram room? I can't decipher the API. I want to do something like:
telegram.onMessageReceived('room_id', (msg) => {
console.log(msg.content);
}
I usually use Python, but open to using NodeJS because I want to have it always running, monitoring for changes on an Ubuntu server.
As far as I can find on the internet, everything is pointing to the bot API, but as I understand it, it would only be notified of updates to messages to the bot. I want to monitor public rooms in which I cannot add the bot as an administrator since I did not create the room. Or is there some way to add a bot to public rooms? I don't think so.
Also the room I want to monitor doesn't allow anyone to chat. It's just to notify subscribers.
I've read these SOs so far and am still confused:
Can a Telegram bot read messages of channel
How do I join my bot to the Channel?
How to join my Telegram Bot to PUBLIC channel
in node.js telegram library you can check the last message.date and compare with last date you have stored. if changed there is new message

Categories

Resources