That is not related to Telethon. Please move to a different group with the correct topic to continue that conversation
Читать полностью…Hi and welcome to the group. Before asking any questions, please read the rules from the group's description, and don't forget to read the docs. Make sure you are using the latest version with pip3 install -U telethon
, since most problems have already been fixed in newer versions.
When I write the name of the book to the bot, I want it to send it to me as a pdf. How is this possible?
Читать полностью…hello all! Question: why does telegram show the same emoji 🟰 in different ways in the same message?? (only on some mobile phones)
Читать полностью…Hi, I really like the Silvia bot over here. I remember that it has a OS github. can someone share the link please?
Читать полностью…I want to pass multiple patterns to a decorator
is it possible? if yes how?
I passed a list of patterns and didn't work
The example was for implicit updates that get sent to usual NewMessage handler by sever, you're not obliged to set the limit to 1 if you want to parse the difference new_messages, you can pass any number like 100
Читать полностью…Thanks for the quick reply. The only problem I cannot deal with channel differencetoolong problem. It occurs when difference is more then 1 message. In this my case my code just skip this messages but I would like to get them as well. Here is code: import asyncio
from telethon.tl.functions.updates import GetChannelDifferenceRequest
from telethon.tl.types import ChannelMessagesFilterEmpty
from telethon.tl.functions.channels import GetFullChannelRequest
from telethon import TelegramClient,errors
from pprint import pprint
api_id = 1111
api_hash = 'aaaaaa'
client = TelegramClient('anon', api_id, api_hash)
client.start()
async def request_updates(chats):
# Get the initial "points in time" (pts) for each chat
pts = {chat: (await client(GetFullChannelRequest(chat))).full_chat.pts for chat in chats}
while True:
for chat in chats:
# Get channel differences for each chat
diff = await client(GetChannelDifferenceRequest(chat, ChannelMessagesFilterEmpty(), pts[chat], 1))
if hasattr(diff, 'new_messages'):
for message in diff.new_messages:
print (message.message)
if hasattr(diff, 'pts'):
pts[chat] = diff.pts
else:
pts[chat] += 1
# Sleep for a short duration between iterations
await asyncio.sleep(5)
# List of chat URLs to monitor
chat_urls = ["/channel/ourgroup444"]
# Run the Telethon client until it is disconnected
client.loop.run_until_complete(request_updates(chat_urls))
Hi and welcome to the group. Before asking any questions, please read the rules from the group's description, and don't forget to read the docs. Make sure you are using the latest version with pip3 install -U telethon
, since most problems have already been fixed in newer versions.
The goal. not what you're doing now, are you trying to create album photo handler?
Читать полностью…That is not related to Telethon. Please move to a different group with the correct topic to continue that conversation
Читать полностью…the telegram app will stop changing emojis to the apps built-in emojis after a certain amount, and fallback to the system emoji font
Читать полностью…Because Telegram wants to. you can't do much about it, certain accounts or sessions when used under unofficial apps will get logged out to protect the account when doing certain actions or by just being logged in
Читать полностью…After initialisation of my session i got log out from all devices. Why telegram did this? I literally can only call get_me() but it always happens
Читать полностью…ok, I think I figured it out
@client.on(events.NewMessage(1234060895))Читать полностью…
async def normal_handler(event):
if event.photo:
with open("id.txt", "r") as txt:
lines = txt.readlines()
for line in lines:
if str(event.photo.id) == line[:-1]:
await client.send_message(1234060895, '👎')
break
return
with open("id.txt", "a") as txt:
txt.write(str(event.photo.id) + '\n')
print(current_time, event.photo.id)
```@client.on(events.NewMessage(1234060895))
async def normal_handler(event):
if event.photo:
with open("id.txt", "r") as txt:
lines = txt.readlines()
for line in lines:
if str(event.photo.id) == line[:-1]:
await client.send_message(1234060895, '👎')
return
with open("id.txt", "a") as txt:
txt.write(str(event.photo.id) + '\n')
print(current_time, event.photo.id)```
so that this is only executed once per message
throws more than one exception at a time, since it records all the photos from the message, and it seems that in the verification cycle it throws an exception for each matching record :(
Читать полностью…I receive photos from the bot, sometimes several in one message, one message - one exception, ideally, all exceptions are written to a file, the bot can be repeated, so I need to compare each message with entries in the file in order to automatically respond to repetitions
Читать полностью…where is return located, in this place I do not need to continue execution, but go into wait mode until the next event
or did I do everything right with "return"...
@client.on(events.NewMessage(1234060895))
async def normal_handler(event):
if event.photo:
with open("id.txt", "r") as txt:
lines = txt.readlines()
for line in lines:
if str(event.photo.id) == line[:-1]:
await client.send_message(1234060895, '👎')
return
with open("id.txt", "a") as txt:
txt.write(str(event.photo.id) + '\n')
print(current_time, event.photo.id)