Answer the question
In order to leave comments, you need to log in
How to get the id of the sender of the message?
The question is in the header.
Telethon.
The bottom line is to add a check for the sender's ID (if *sender id* == *my id**:), so that the script does not react to all messages with the tag !.
from telethon.sync import TelegramClient, events
import time
with TelegramClient('name', api_id="123", api_hash="abcd") as client:
client.start()
print("Logined")
@client.on(events.NewMessage(pattern='!'))
async def handler(event):
try:
print("Message got")
text = event.text.split(" ")
print(text)
if text[0]=="!spam":
i = 0
while i < int(text[1]):
await event.respond(text[2])
print ('Message '+text[2]+ ' send!')
i += 1
time.sleep(int(text[3]))
except Exception as e:
await event.respond(e)
client.run_until_disconnected()
Answer the question
In order to leave comments, you need to log in
Do you have errors enabled? Perhaps some content is given before the headings?
Is the domain from which the page is called the same?
cookies you have are not "not saved", but not sent.
because in addition to the headers, something has already been sent to the client.
The most common (and for beginners, the most mysterious) reason is that
in PHP, everything that is not in <? ... ?>
is output to the browser. For example:
<?PHP
echo 'Это PHP код';
?>
а это не PHP код, и в браузер будет выведено как простой текст, даже если это просто пробел или символ перевода строки.
?>
or not use the closing tag at all, which in the comments above was correctly advised by @maxaon By theDidn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question