Scrape Telegram channel for changes - python

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

Related

Is there a way to find if someone your server in Discord belongs to a particular server?

I was looking for a way if you can find all the members from a particular server in discord to let's say remove them from your server as they can be from your opponents' server lurking around. If there is a way I want to create a discord bot for it. Any help related to it will be appreciated.
Yes there is, but this would require that the user authorizes your application. It would work something like this:
Your bot has some sort of webserver listening
Your bot gives them a link
They click the link, discord asks them to authorize your bot
Discord redirects them to your webserver with a token in the parameters
Using that token, you can access info such as what guilds they are in.
This is easiest if you already have a bot dashboard, but can still be achieved without one (though you still need a webserver to listen for the callback).
If you have a quart webserver (which is how I would recommend doing it) then take a look at this: https://github.com/jnawk/Quart-Discord
Edit: Also note that, if your bot is in this other guild, you can do a simple check, like this:
g = bot.get_guild(guild_id)
await g.chunk()
if member in g.members:
# ban them

is there a way to make a telepot bot read messages from other bots?

I am developing a telegram bot using the telepot library for python and needed to have two bots communicate with each other in a group.
for some reason, neither bot cannot read messages sent by bots.
can someone tell me how i could do ?
here are the bots settings:
Privacy mode = OFF
Group privacy = OFF
Allow groups = ON
Thank you.
you'll never be able to let two bots communicate on the same group.
though, they can communicate -not on a group- using a different approach which is a channel.
bots can read all channel's messages, hence you can make both of your bots read each other's messages by sending it on the same channel.
for more information, check this out what messages will my bot get

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 join my Telegram Bot to PUBLIC channel

My question is:
how to join my telegram bot to a telegram public channel that I am not an administrator of it, and without asking the channel's admin to add my bot to the channel?
Maybe, the chatId of channel or thru link of channel?
I have heard that some people claim to do this join their bot to channels, and scrape data.
So if Telegram does not allow it, how can they do it? can you think of any work around?
Thank you in advance :)
Answer to your edited question.
It was possible to add a bot to a group/channel with just an invite link. This was achieved by allowing a bot to access the mtproto methods like messages.importChatInvite for private links and channels.joinChannel. However telegram patched this. However, you can still do this with normal user accounts! Since you are using python you can give this a shot. I can confirm the methods still work on Madeline Proto.
Till today, only the Channel Creator can add a bot (as Administrator or Member) to the Channel, whether public or private. Even the other Channel Administrators cannot add a normal member leave alone adding a bot, rather they can only post into the channel.
As far as joining the bot via the invite link, there is yet no such method in Bot API to do so. All such claims of adding the bot to a channel by non Creator are false.
Another way of "scraping the data" from several channels would be to listen to these channels with a Junction Bot aka Channels, Multi Feed Edge Bot, or alike. You just need to go to the channel info and share the link of the desired channel with the Junction Bot to automate the process of receiving new messages from the(se) channel(s). There are also other quite advanced ways described in their FAQ.
Multi Feed Edge Bot also seems to work O'kay, however, you need to follow these steps to add the redirection:
/add #TelespaceNews https://t.me/joinchat/AAAAAFIaTHjZp8ltykgwEQ
You can only add bots to channels you are an admin in them and bots can only be added as admins. for this go to Manager Channel, click on Administrators / Add Administrator then search for the bot you want to add to your channel.

Categories

Resources