from telethon import TelegramClient, connection
from config import api_hash, api_id
client = TelegramClient(
'session', api_id, api_hash,
connection=connection.ConnectionTcpMTProxyRandomizedIntermediate,
proxy=('95.169.173.237', 8443, 'eeNEgYdJvXrFGRMCIMJdCQ')
)
async def saved_messages():
# Get the user
me = await client.get_me()
await client.send_message('me', 'it worked :D')
# Run the client
with client:
client.loop.run_until_complete(saved_messages())
I'm a little confused. Can you please give an example for UpdateInlineBotCallbackQuery?
Читать полностью…there was nothing about them in the docs, just found this:
https://tl.telethon.dev/constructors/input_client_proxy.html
does this work for making a userbot use a mtproto proxy?
proxy = {Читать полностью…
'address': 'PROXY_ADDRESS',
'port': 443,
'secret': b'PROXY_SECRET'
}
# Create the client and set up MTProto proxy
client = TelegramClient(
StringSession(),
api_id,
api_hash,
connection=ConnectionTcpMTProxy,
proxy=(proxy['address'], proxy['port'], proxy['secret'])
)
In this case I have to use get_permissions multiple times to be able to change the text and data of the buttons using it
But apparently this is not working properly
I am sending multiple inline buttons with a message. I want to change the text and data of that button when the user clicks on one of the inline buttons (only that button).
But when the user clicks on the buttons, the buttons are not there in the update that comes.
Did you create the session in the same runtime/client object it was terminated at?
Читать полностью…Using
(Timeouts)
try:
with client:
result = client.get_me(timeout=10)
except TimeoutError:
print("Session might be terminated.")
from telethon import TelegramClient, connection
from config import api_hash, api_id
client = TelegramClient(
'session', api_id, api_hash,
connection=connection.ConnectionTcpMTProxyRandomizedIntermediate,
proxy=('194.120.230.96', 85, '7hs4KdquAf0HwOI8kXxmQARpdmlmLmly')
)
async def saved_messages():
# Get the user
me = await client.get_me()
# Send 'hi' to saved messages
await client.send_message('me', 'hi')
# Run the client
with client:
client.loop.run_until_complete(saved_messages())
Attempt 1 at connecting failed: ConnectionError: Proxy closed the connection after sending initial payloadЧитать полностью…
you're probaby using events, which are telethon's custom types, wrapping the original updates.
i just wanted to highlight that the original update does not contain the message object
the event should have a method to refetch the message by id
correct.
https://tl.telethon.dev/constructors/update_bot_callback_query.html
https://tl.telethon.dev/constructors/update_inline_bot_callback_query.html
you can however refetch the message
I thought the buttons were in the callback queries
and I wanted to get the buttons this way and just change the text and data of the button in question
then resend them
is there any way to connect a userbot via mtproto proxy? (for countries that telegram is cencorshipped in)
Читать полностью…Use Telethon events:
from telethon.events import Raw
@client.on(Raw)
async def handle_raw(event):
print(f"Received event: {event}")
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.