mirror of
https://github.com/aljazceru/chatgpt-telegram-bot.git
synced 2025-12-20 06:05:12 +01:00
update utils.py
This commit is contained in:
@@ -390,10 +390,6 @@ class ChatGPTTelegramBot:
|
|||||||
if self.config['stream']:
|
if self.config['stream']:
|
||||||
async def _reply():
|
async def _reply():
|
||||||
nonlocal total_tokens
|
nonlocal total_tokens
|
||||||
await update.effective_message.reply_chat_action(
|
|
||||||
action=constants.ChatAction.TYPING,
|
|
||||||
message_thread_id=get_thread_id(update)
|
|
||||||
)
|
|
||||||
|
|
||||||
stream_response = self.openai.get_chat_response_stream(chat_id=chat_id, query=prompt)
|
stream_response = self.openai.get_chat_response_stream(chat_id=chat_id, query=prompt)
|
||||||
i = 0
|
i = 0
|
||||||
|
|||||||
@@ -117,7 +117,8 @@ async def edit_message_with_retry(context: ContextTypes.DEFAULT_TYPE, chat_id: i
|
|||||||
message_id=int(message_id) if not is_inline else None,
|
message_id=int(message_id) if not is_inline else None,
|
||||||
inline_message_id=message_id if is_inline else None,
|
inline_message_id=message_id if is_inline else None,
|
||||||
text=text,
|
text=text,
|
||||||
parse_mode=constants.ParseMode.MARKDOWN if markdown else None
|
parse_mode=constants.ParseMode.MARKDOWN if markdown else None,
|
||||||
|
disable_web_page_preview=True
|
||||||
)
|
)
|
||||||
except telegram.error.BadRequest as e:
|
except telegram.error.BadRequest as e:
|
||||||
if str(e).startswith("Message is not modified"):
|
if str(e).startswith("Message is not modified"):
|
||||||
@@ -127,7 +128,8 @@ async def edit_message_with_retry(context: ContextTypes.DEFAULT_TYPE, chat_id: i
|
|||||||
chat_id=chat_id,
|
chat_id=chat_id,
|
||||||
message_id=int(message_id) if not is_inline else None,
|
message_id=int(message_id) if not is_inline else None,
|
||||||
inline_message_id=message_id if is_inline else None,
|
inline_message_id=message_id if is_inline else None,
|
||||||
text=text
|
text=text,
|
||||||
|
disable_web_page_preview=True
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.warning(f'Failed to edit message: {str(e)}')
|
logging.warning(f'Failed to edit message: {str(e)}')
|
||||||
|
|||||||
Reference in New Issue
Block a user