Skip to content

Commit

Permalink
Fix the bug in the translation command that uses search
Browse files Browse the repository at this point in the history
  • Loading branch information
yym68686 committed Sep 26, 2023
1 parent 4c42500 commit 5a9b851
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@
print("nick:", botNick)
translator_prompt = "You are a translation engine, you can only translate text and cannot interpret it, and do not explain. Translate the text to {}, please do not explain any sentences, just translate or leave them as they are. this is the content you need to translate: "
async def command_bot(update, context, language=None, prompt=translator_prompt, title="", robot=None, has_command=True):
if config.SEARCH_USE_GPT:
if config.SEARCH_USE_GPT and not has_command:
title = f"`🤖️ {config.DEFAULT_SEARCH_MODEL}`\n\n"
if update.message.reply_to_message is None:
if has_command == False or len(context.args) > 0:
message = update.message.text if config.NICK is None else update.message.text[botNicKLength:].strip() if update.message.text[:botNicKLength].lower() == botNick else None
if has_command:
message = ' '.join(context.args)
print("\033[32m", update.effective_user.username, update.effective_user.id, update.message.text, "\033[0m")
if prompt:
if prompt and has_command:
prompt = prompt.format(language)
message = prompt + message
if config.API and message:
await context.bot.send_chat_action(chat_id=update.message.chat_id, action=ChatAction.TYPING)
await getChatGPT(update, context, title, robot, message, config.SEARCH_USE_GPT)
await getChatGPT(update, context, title, robot, message, config.SEARCH_USE_GPT, has_command=True)
else:
message = await context.bot.send_message(
chat_id=update.message.chat_id,
Expand Down Expand Up @@ -83,7 +83,7 @@ async def reset_chat(update, context):
text="重置成功!",
)

async def getChatGPT(update, context, title, robot, message, use_search=config.SEARCH_USE_GPT):
async def getChatGPT(update, context, title, robot, message, use_search=config.SEARCH_USE_GPT, has_command=True):
result = title
text = message
modifytime = 0
Expand All @@ -96,7 +96,7 @@ async def getChatGPT(update, context, title, robot, message, use_search=config.S
)
messageid = message.message_id
try:
if use_search:
if use_search and not has_command:
for data in search_summary(text, model=config.DEFAULT_SEARCH_MODEL, use_goolge=config.USE_GOOGLE, use_gpt=config.SEARCH_USE_GPT):
result = result + data
tmpresult = result
Expand Down

0 comments on commit 5a9b851

Please sign in to comment.