Recently I've been writing bot which parses site and sends message to users, whenever new information appears. Is it possible to make it on aiogram? Thank you for your answer in advance
Yes. it is.
But you have to store user_id of your users, then when "information appears" you take from your storage user_ids and send message to each user. Also it is unreal to send message for all users in one time due to telegram limits (see here).
Related
What I'm trying to understand is how Discord.py creates and sends responses from their on_message function.
Take this as an example:
#client.event()
async def on_message(message):
print(message.content)
I'm trying to understand how Discord.py retrieves new messages from Discord without refreshing the channel histories for every single channel in every single server to scan for new messages which would surely hit Discord's rate limit.
Is there a way to scan for new messages with Discord's API using fetch or post requests? I am not trying get a solution on how to scan new messages using an already made library. I want to achieve this using only the requests module in python.
I'm trying to understand how Discord.py retrieves new messages from Discord without refreshing the channel histories for every single channel in every single server to scan for new messages which would surely hit Discord's rate limit.
Discord bots establish a websocket connection with Discord's servers, which is essentially a (secure) two-way tunnel. This means that once the connection is up, Discord can send events to you. Instead of you having to manually fetch every single channel, Discord tells you "Hey, a message was created", and the payload attached will give all the additional info about it.
The Discord (not discord.py) docs have detailed info about how everything works behind the scenes, to help the people creating the Bot libraries for you. For example, this section details which types of events Discord can send to you. To see how something is constructed, click on one of the event types and read up on the data that Discord provides.
Is there a way to scan for new messages with Discord's API using fetch or post requests? I am not trying get a solution on how to scan new messages using an already made library. I want to achieve this using only the requests module in python.
Not really, unless you do in fact send a GET for every single channel, which will get you ratelimited. There's really no reason to ever use only GET/POST requests (other than Webhooks, where you just send a POST with your info to send a message to a channel without a bot).
If you'd like to read up on Discord's API, the docs I linked contain a full spec of everything, so you could try to do whatever your heart desires (... and the API supports).
this Platform is really really helpful. My issue is that is it possible to send 500k promotional messages per day? I have the script ready using the API # and API ID using Telethon. But anytime i try to send Messages, the accounts get banned. Maybe it got banned because i was on the same IP Address while scraping the users and sending messages. But what I really need to know is that is it even Possible to send 500k messages in day, if yes:
How many Accounts are needed(where can I get these number of
accounts from)?
Do I have to manually create accounts and receive
OTP's for each or is there a script ready for that as well that I
can implement?
What should be the duration between each messages and
how many messages from one single account.
How to shuffle between accounts while send messages? Manually or is there again a script
ready for it?
Please guys I really really need help. If not 500k how many can i send per day maximum.
You can send up to 20 messages per second in the same chat on Telegram.
I have 2 discord client instances a bot and a user account. I have already figured out how to copy messages from one channel to another channel, basically a on_message event. However, I want to know if there is a way I can use the user account to fetch the messages, I've tried fetching messages in different guilds but they didn't work because the bot was not in the server and the bot is fetching messages. I've tried using the user account instance to do it but it didn't really work.
The comments were there as a guide for myself because I'm not that familiar with Python it's fairly new to me. If anyone knows how I can use the user account to get or fetch the messages I'd appreciate the help...
PS: I know that some of the code isn't needed, I haven't removed anything that isn't needed. I wanted to actually finish the project before inspecting it.
I just wanted to know that I have tried this myself and it is not possible. Because from discord.py's Docs. Which you can find down below, does not allow users (user account) to transfer data to a bot since you would need to request from discord API which leads to user getting banned (Very quickly) theere are some work arrounds but I would suggest not doing so since self botting is against the TOS of discord
https://discordpy.readthedocs.io/en/stable/
EDIT: Another thing is that discord API blocks users from fetching or getting anything using a user account with discord.py
Is it possible to get a bot to send the first message in the chat without running a command like "/Start"?
Maybe it possible to save the chat_id of the requested user in advance and send him a message in the future, thus allowing the bot to send a first message in chat according to a predefined condition that will trigger him?
I searched for an answer online but could not find one.
Can you send me a link to a tutorial that explains how to do this?
Thanks in advance
Yoav Giladi :)
One solution is to use a Telegram Bot deeplink to provide an entry point to the Chatbot that does not require the users typing the /Start command.
After the very first interaction you can the obtain the chat_id which can be stored for using it to initiate a message later:
context.bot.send_message(chat_id, text='Howdy')
I'm having a problem forwarding messages with multiple media files (in my particular case, photos).
I'm using forwardMessage method to forward the message that user sends to bot (which, in some cases, might contain more than one photo):
bot.forwardMessage(admin_id, from_chat_id, message_id)
But, the thing is, according to Telegram API v3.5, the message which contain media group breaks up into array of messages, and hence the bot breaks up the message from user into multiple messages. E.g. if user have sent a message with 3 photos, then the bot forwards 3 messages, each of which contains a photo.
What I want is to forward a message with multiple media files as it is, as one message, not as multiple messages.
I know that probably I can take each photo from each message that the bot receives, put them one-by-one into array, and then send it from the bot using sendMediaGroup method, but I'd like to know if I can get it working with forwardMessage method.
Thanks in advance.
You can't forward original content via forwardMessage, for instance, you can't forward with an inline keyboard.
I think this may be a mistake, you can suggest that to #BotSupport.
Telegram API had updated a method call sendMediaGroup for sending images as album.
https://core.telegram.org/bots/api#sendmediagroup
Have a look :)