Почему в данном коде не находит атрибут? Подскажите пожалуйста как исправить ошибку
from telethon import TelegramClient, events, sync
import re
import webbrowser
import time
from bs4 import BeautifulSoup
api_id = 76675487
api_hash = "8c86a1764611d55565d8fddf49b181bd3"
client = TelegramClient('anon', api_id, api_hash)
client.start()
dlgs = client.get_dialogs()
for dlg in dlgs:
if dlg.title == 'LTC Click Bot':
tegmo = dlg
client.send_message(tegmo, '/visit')
while True:
second_m = str(client.get_messages(tegmo, limit= 2))
first_m = str(client.get_messages(tegmo, limit= 1))
g_1 = "'''" + second_m + "'''"
g_2 = "'''" + first_m + "'''"
url_1 = re.search(r'(https://.+?)\'', g_1).group(1)
url_2 = re.search(r'(https://.+?)\'', g_2).group(1)
if url_1 == url_2:
messages = (client.get_messages(tegmo, limit=1))
messages[0].click(2)
f = str(client.get_messages(tegmo, limit= 1))
g = "'''" + f + "'''"
url = re.search(r'(https://.+?)\'', g).group(1)
print(url)
webbrowser.open(url, 1)
time.sleep(15)
код ошибки:
Traceback (most recent call last):
File "C:\Users\ars\PycharmProjects\telegram_bot_money\bot.py", line 26, in <module>
url = re.search(r'(https://.+?)\'', first_m).group(1)
AttributeError: 'NoneType' object has no attribute 'group'