I have 2 accounts communicating with each other in the chat, but I don't understand how they can reply to each other?
m = await client.send_message(chat_id, text, reply_to=old_m.id)
not working :(
That is not related to Telethon. Please move to a different group with the correct topic to continue that conversation
Читать полностью…Is there any way I can access the date column natively through telethon without using sqlite3?
Читать полностью…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.
hi, can I use filter of iter_messages in negative way? I want to get all the NON service messages
Читать полностью…Fatal errors either throw an exception or start with the ERROR: prefix (if logging is set up correctly). Rest can be ignored most of the time.
There's also FATAL but I don't think telethon uses the level
why do i get this
Server closed the connection: 0 bytes read on a total of 8 expected bytes
from telethon import TelegramClient
api_id = 'YOUR_API_ID'
api_hash = 'YOUR_API_HASH'
bot_token = 'YOUR_BOT_TOKEN'
bot = TelegramClient('bot', api_id, api_hash).start(bot_token=bot_token)
async def main():
await bot.send_message('username_or_chat_id', 'test message')
with bot:
bot.loop.run_until_complete(main())
Try this
New StackOverflow question
Telethon client .session + socks5 proxy quick deauthorization
https://stackoverflow.com/q/79242820
currently I'm doing:
messages = [Читать полностью…
message
async for message in bot.iter_messages(channel_id, 100)
if not message.action
]
how to track when you've been accepted into a private group where request_needed?
UPD:
You can do it with this:
async def handle_crawler_chat_removal(client: TelegramClient):Читать полностью…
client_me = await get_me(client=client)
@client.on(events.Raw) # type: ignore
async def handler(event):
logger.info(event.stringify())
if isinstance(getattr(event, 'message', None), MessageService) and \
isinstance(event.message.action, MessageActionChatDeleteUser) and \
event.message.action.user_id == client_me.id:
logger.info(f'You were removed from Chat: {event.peer_id.chat_id}')
await decrease_chats_count(client=client)
async def handle_crawler_acceptance_or_removal(client: TelegramClient):
@client.on(events.Raw) # type: ignore
async def handler(event):
if isinstance(event, UpdateChatParticipants): # type Chat
logger.info(f"You were accepted into the basic_group: {event.participants.chat_id}")
input_entity = await client.get_input_entity(PeerChat(event.participants.chat_id))
await entity_like_queue.append(client=client, entity=input_entity)
elif isinstance(event, UpdateChannel): # type Channel
input_entity = await client.get_input_entity(PeerChannel(event.channel_id))
try:
entity = await client.get_entity(input_entity)
logger.info(f'You were accepted into the channel/supergroup or you get a update: {event.channel_id}')
await entity_like_queue.append(client=client, entity=entity) # type: ignore
except ChannelPrivateError:
logger.info(f'You were deleted from the channel/supergroup: {event.channel_id}')
await decrease_chats_count(client=client)
try:
check_chat = await client(functions.messages.CheckChatInviteRequest(hash=link_hash))
if check_chat.request_needed:
pass
updates = await client(functions.messages.ImportChatInviteRequest(link_hash))
await increase_chats_count(client=client)
except errors.InviteRequestSentError:
# You have successfully requested to join this chat or channel.
pass
except Exception:
pass
New StackOverflow question
Errors whilst trying to run a telethon python script made by AI
https://stackoverflow.com/q/79241748