For one of my projects, I need to fetch in real-time the total unread count of telegram messages
As shown under, it's possible to do it in Telegram Desktop client :
https://telegra.ph/file/d58a4c36084d79781f89c.png
it's also possible to show it on other clients
so, I wonder how I can simply do it
maybe through the Telegram API, however I didn't find anything related to this
(we can get unread mentions and unread reactions, but only for a specific chat)
An integration in python would be the best for me, as I don't really master other languages yet
NB : "fetch in real-time", not needed to have it every millisecond, but maybe each 2-3 seconds
Related
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 am a part of a public telegram channel with too much noise and only some meaningful important updates. I want to filter out noise and need to view real time updates(new messages) with specific words in text body of message of this channel using python.
I followed the code from below post by Lonami to try and get messages and it works beautifully, but it brings in all the historical messages as well.
Telegram get chat messages /posts - python Telethon
Could someone guide me to get the new messages real time one by one as they are posted ?
I am making a discord bot and I want to know how I can add a basic implementation of seeing which users are active daily on the server and how long they're active. The definition of active is not accurate but it could be if they sent a message in the group throughout the day. What would be the code to implement something like this in my discord bot? Thanks a lot!
Checking to see who has sent a message is simple enough to do,
You could use the on_message function to see who has sent a message in your server, using this method you could get the user and append them to a list and then delete the list every so often (eg. daily, or you could wait for an admin to call a command within the server).
The positive side of this method is that you can control what counts as active, for example you could also use on_reaction_add and its opposite.
This is a simple example of a bot that checks the users that have sent messages in the server and adds them to a list. Note: This script doesn't delete the list, meaning that members will be permanently in the active list, you should be able to implement this in your code fairly easily.
import discord
client = discord.Client()
activeMembers = [] #We create an empty list to hold the users that have been active
#client.event
async def on_message(message):
if message.author not in activeMembers:
activeMembers.append(message.author)
client.run("YOUR TOKEN HERE")
I've missed out some things that you probably have if you've started your bot already. If you haven't, fear not as there are multiple articles and tutorials on creating a bot.
The problem is that you want to see how long a member is active on your server, so what you could do is log the times they have sent messages, and then calculate the time they've been active on the server by deducting one value for another. This isn't accurate as you've stated, but is the best solution in my mind. The biggest problem here is that someone could send a message early in the morning and then go off about their day and then send a message at night, this would mean that the bot would think they are active for many hours (seeing as their first message was sent much much earlier) when in fact they are not. A simple workaround is to check every users last message time, and use a threshold time (if you will) to see who is no longer active.
For example, if someone sent their last message half an hour ago, they would no longer be seen as active and their total time would be calculated based on their first message and their last message. Their data would then be purged, so that if they send a message much later on, the bot doesn't use their first message of the day to calculate how long they've been on for.
Looking back on this this explanation is a bit shoddy, so Ill try quickly summarise it in a timeline sort of fashion.
A user sends a message in a channel and the bot records their id and the time they sent it -> They send another message five minutes later, the bot records the same data -> The user hasn't sent a message in half an hour (example of a threshold time, you could make yours shorter or longer) and the bot calculates their time and removes their message times. This time is then added to their total time.
This can be done using .create_task() where you pass in a function to run in the background. The function you would pass would regularly check when users sent their last message.
Should you want to define active as things other than reactions or sending messages, visit discord.py to find out the different things you can do.
Best of luck,
Ben
If you open telegram bot FAQ you can see 1 message per second inside particular chat, 30 messages per second inside group chat and less than 20 messages per minute inside group chat.
I have simple telegram bot with simple rate limiter:
it doesn't use group chats;
it sends only 1 message per second inside particular chat;
it sends less than 20 messages per minute inside particular chat;
But i always receive 429 error:
"error_code":429,"description":"Too Many Requests: retry after 236"
I confused since i don't violate telegram limitations. Please, help me to find problem.
Source code here, bot uses this library for interaction with telegram in poll mode. Steps to reproduce:
1) python3 bot.py;
2) /start in bot;
3) click "Спектакли";
4) click very fast on "Трагикомедии" or "Драма";
Your msg_count seems is tracking sended messages for each private chat. But it should be global, beacuse its seems that your current code allows your bot to send a few messages per second to unlimited users. So it would probably exceed the limit.
If you're sending bulk notifications to multiple users, the API will
not allow more than 30 messages per second or so. Consider spreading
out notifications over large intervals of 8—12 hours for best results.
Telegram Bots FAQ
I'm using Youtube Data API V3 to subscribe users to a channel. The subscription process basically tells the users that they will subscribe to certain channels by clicking a button. They can walk away from it if they don't want to subscribe. Once they click the button, they will go through Youtube's authorization process and finish the subscriptions. So there's no cheating or whatever. What I find is that on certain days, there might be over one thousand people that subscribe. Before I'd like to celebrate, all the subscribers on that day are gone. But if the subscription acitivities are not that active, say only dozens of people subscribe, nothing would happen. So I wonder if there's any "soft limit" on the number of subscribers within a period of time for API subscription. Google never mentions such limit but I've encountered this problem several times.