C
C
CookieMonster322020-05-20 17:30:27
Python
CookieMonster32, 2020-05-20 17:30:27

How to fix tegmo or msgs = client.get_messages(tegmo, limit=30) NameError: name 'tegmo' is not defined?

I decided to make a small program. I have this piece of code:

tegmo = dlg
msgs = client.get_messages(tegmo, limit=30)

And I'm getting this error:
msgs = client.get_messages(tegmo, limit=30)
NameError: name 'tegmo' is not defined

In tegmo = dlg, tegmo appears for the first time. How can the error be corrected?
Here is the complete code:
from telethon import TelegramClient

api_id = 
api_hash = ''
client = TelegramClient('', api_id, api_hash)
client.start()
dlgs = client.iter_dialogs()
for dlg in dlgs:
  print(dlg.title)
for dlg in dlgs:
  if dlg.title == '':
    tegmo = dlg
msgs = client.get_messages(tegmo, limit=30)
for msg in msgs:
  if msg.reply_markup is not None:
    button.data = msg.reply_markup.rows[0].buttons[0].data
    message_id = message_id
    print(button_data, message_id)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2020-05-20
@CookieMonster32

And what is tegmo equal to if dlg.title is not empty?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question