Skip to content

Commit

Permalink
Merge pull request #85 from FuseFairy/master
Browse files Browse the repository at this point in the history
fix bug
  • Loading branch information
FuseFairy committed May 27, 2023
2 parents 718f262 + a3936be commit 0f85571
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
15 changes: 9 additions & 6 deletions cogs/edgegpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,22 @@ async def cookies_setting(self, interaction: discord.Interaction, choice: app_co
if cookie.get("name") == "_U":
auth_cookie = cookie.get("value")
break
users_image_generator[interaction.user.id] = ImageGenAsync(auth_cookie, True)
users_image_generator[interaction.user.id] = ImageGenAsync(auth_cookie, quiet=True)
users_chatbot[interaction.user.id] = UserChatbot(cookies=content)
user_conversation_style[interaction.user.id] = "balanced"
await interaction.followup.send("> **Upload successful!**")
logger.warning(f"\x1b[31m{interaction.user} set bing cookies successful\x1b[0m")
except:
await interaction.followup.send("> **Please upload your cookies.**")
else:
del users_chatbot[interaction.user.id]
del users_image_generator[interaction.user.id]
del user_conversation_style[interaction.user.id]
await interaction.followup.send("> **Delete finish.**")
logger.warning(f"\x1b[31m{interaction.user} delete cookies\x1b[0m")
try:
del users_chatbot[interaction.user.id]
del users_image_generator[interaction.user.id]
del user_conversation_style[interaction.user.id]
await interaction.followup.send("> **Delete finish.**")
logger.warning(f"\x1b[31m{interaction.user} delete cookies\x1b[0m")
except:
await interaction.followup.send("> **You haven't set up Bing cookies.**")

# Create images
@app_commands.command(name = "create_image", description = "generate image by bing image creator")
Expand Down
3 changes: 1 addition & 2 deletions cogs/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ async def send_message(chatbot: Chatbot, message, user_message: str):
async with sem:
if isinstance(message, discord.message.Message):
await message.channel.typing()
superscript_map = {'0': '⁰', '1': '¹', '2': '²', '3': '³', '4': '⁴', '5': '⁵', '6': '⁶', '7': '⁷', '8': '⁸', '9': '⁹'}
reply = ''
text = ''
link_embed = ''
Expand All @@ -124,7 +123,7 @@ async def send_message(chatbot: Chatbot, message, user_message: str):
text = f"{reply['item']['messages'][4]['text']}"
except:
text = f"{reply['item']['messages'][1]['text']}"
text = re.sub(r'\[\^(\d+)\^\]', lambda match: ''.join(superscript_map.get(digit, digit) for digit in match.group(1)), text)
text = re.sub(r'\[\^(\d+)\^\]', lambda match: '', text)
# Get the URL, if available
try:
if len(reply['item']['messages'][1]['sourceAttributions']) != 0:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
discord.py==2.2.3
python-dotenv==0.20.0
PyYAML==6.0
EdgeGPT==0.4.4
EdgeGPT==0.6.5
3 changes: 1 addition & 2 deletions src/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ async def set_using_send(user_id, status: bool):

async def send_message(chatbot: Chatbot, interaction: discord.Interaction, user_message: str, conversation_style: str):
using_func[interaction.user.id] = True
superscript_map = {'0': '⁰', '1': '¹', '2': '²', '3': '³', '4': '⁴', '5': '⁵', '6': '⁶', '7': '⁷', '8': '⁸', '9': '⁹'}
reply = ''
text = ''
link_embed = ''
Expand All @@ -65,7 +64,7 @@ async def send_message(chatbot: Chatbot, interaction: discord.Interaction, user_
text = f"{reply['item']['messages'][4]['text']}"
except:
text = f"{reply['item']['messages'][1]['text']}"
text = re.sub(r'\[\^(\d+)\^\]', lambda match: ''.join(superscript_map.get(digit, digit) for digit in match.group(1)), text)
text = re.sub(r'\[\^(\d+)\^\]', lambda match: '', text)
# Get the URL, if available
try:
if len(reply['item']['messages'][1]['sourceAttributions']) != 0:
Expand Down

0 comments on commit 0f85571

Please sign in to comment.