-
Notifications
You must be signed in to change notification settings - Fork 234
Open
Labels
Description
Hello, I have a problem with sending a message to a group chat. Some times ago after created the group chat a function of sending a message then it returned an error message: "Bad Request: group chat was upgraded to a supergroup chat".
I review the code zbxtg.py and found a mistake these if tg.error.find("migrated") > -1 and tg.error.find("supergroup") > -1:
if not is_single_message:
tg.send_message(uid, zbxtg_body_text)
if not tg.ok:
# first case – if group has been migrated to a supergroup, we need to update chat_id of that group
**if tg.error.find("migrated") > -1 and tg.error.find("supergroup") > -1:**
#if tg.result["description"].find("supergroup chat") > -1:
migrate_to_chat_id = tg.result["parameters"]["migrate_to_chat_id"]
tg.update_cache_uid(zbx_to, migrate_to_chat_id, message="Group chat is migrated to supergroup, "
"updating cache file")
uid = migrate_to_chat_id
tg.send_message(uid, zbxtg_body_text)
# another case if markdown is enabled and we got parse error, try to remove "bad" symbols from message
if tg.markdown and tg.error.find("Can't find end of the entity starting at byte offset") > -1:
markdown_warning = "Original message has been fixed due to {0}. " \
"Please, fix the markdown, it's slowing down messages sending."\
.format(url_wiki_base + "/" + settings_description["markdown"]["url"])
markdown_fix_attempts = 0
while not tg.ok and markdown_fix_attempts != 3:
offset = re.search("Can't find end of the entity starting at byte offset ([0-9]+)", tg.error).gr$
zbxtg_body_text = markdown_fix(zbxtg_body_text, offset, emoji=internal_using_emoji) + \
["\n"] + [markdown_warning]
tg.disable_web_page_preview = True
tg.send_message(uid, zbxtg_body_text)
markdown_fix_attempts += 1
if tg.ok:
print_message(markdown_warning)
In my opinion, the error code of the Telegram API was changed, but it was not in code. That's why I updated key find words from 'migrated' to 'upgraded' then it worked for me.
if tg.error.find("upgraded") > -1 and tg.error.find("supergroup") > -1: