Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master #89

Merged
merged 2 commits into from
May 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 19 additions & 16 deletions cogs/edgegpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async def bing(self, interaction: discord.Interaction, *, message: str):
user_id = interaction.user.id
if user_id not in users_chatbot:
await interaction.response.defer(ephemeral=True, thinking=True)
await interaction.followup.send("> **Please use */bing_cookies* command to set your bing cookies first**")
await interaction.followup.send("> **Please use */bing_cookies* command to set your Bing Cookies first.**")
else:
await interaction.response.defer(ephemeral=False, thinking=True)
conversation_style = user_conversation_style[user_id]
Expand All @@ -54,29 +54,32 @@ async def bing(self, interaction: discord.Interaction, *, message: str):
await interaction.response.defer(ephemeral=True, thinking=True)
await interaction.followup.send("> **Please wait for your last conversation to finish.**")

# Reset Bing conversation history
@app_commands.command(name="reset", description="Complete reset Bing conversation history")
# Reset Bing conversation
@app_commands.command(name="reset", description="Reset Bing conversation")
async def reset(self, interaction: discord.Interaction):
await interaction.response.defer(ephemeral=True, thinking=True)
try:
await users_chatbot[interaction.user.id].reset()
await interaction.followup.send("> **Info: Reset finish.**")
logger.warning("\x1b[31mBing has been successfully reset\x1b[0m")
except:
await interaction.followup.send(f"> **Info: You don't have any conversation yet.**")
await interaction.followup.send(f"> **Please use /bing_cookies command to set your Bing Cookies first.**")
logger.exception("Bing reset failed.")

# Switch conversation style
@app_commands.command(name="switch_style", description="Switch conversation style")
@app_commands.choices(style=[app_commands.Choice(name="Creative", value="creative"), app_commands.Choice(name="Balanced", value="balanced"), app_commands.Choice(name="Precise", value="precise")])
async def switch_style(self, interaction: discord.Interaction, style: app_commands.Choice[str]):
await interaction.response.defer(ephemeral=True, thinking=True)
user_conversation_style[interaction.user.id] = style.value
await interaction.followup.send(f"> **Info: successfull switch conversation style to {style.value}.**")
logger.warning(f"\x1b[31mConversation style has been successfully switch to {style.value}\x1b[0m")
if interaction.user.id not in users_chatbot:
await interaction.followup.send("> **Please use /bing_cookies command to set your Bing Cookies first.**")
else:
user_conversation_style[interaction.user.id] = style.value
await interaction.followup.send(f"> **Info: successfull switch conversation style to {style.value}.**")
logger.warning(f"\x1b[31mConversation style has been successfully switch to {style.value}\x1b[0m")

# Set and delete bing cookies
@app_commands.command(name="bing_cookies", description="Set or delete bing cookies")
# Set and delete Bing Cookies
@app_commands.command(name="bing_cookies", description="Set or delete Bing Cookies")
@app_commands.choices(choice=[app_commands.Choice(name="set", value="set"), app_commands.Choice(name="delete", value="delete")])
async def cookies_setting(self, interaction: discord.Interaction, choice: app_commands.Choice[str], cookies_file: Optional[discord.Attachment]=None):
await interaction.response.defer(ephemeral=True, thinking=True)
Expand All @@ -91,25 +94,25 @@ async def cookies_setting(self, interaction: discord.Interaction, choice: app_co
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")
logger.warning(f"\x1b[31m{interaction.user} set Bing Cookies successful\x1b[0m")
except:
await interaction.followup.send("> **Please upload your cookies.**")
await interaction.followup.send("> **Please upload your Bing Cookies.**")
else:
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")
logger.warning(f"\x1b[31m{interaction.user} delete Cookies\x1b[0m")
except:
await interaction.followup.send("> **You haven't set up Bing cookies.**")
await interaction.followup.send("> **You don't have any Bing Cookies.**")

# Create images
@app_commands.command(name = "create_image", description = "generate image by bing image creator")
@app_commands.command(name="create_image", description="generate image by Bing image creator")
async def create_image(self, interaction: discord.Interaction, *, prompt: str):
if interaction.user.id not in users_image_generator:
if interaction.user.id not in users_chatbot:
await interaction.response.defer(ephemeral=True, thinking=True)
await interaction.followup.send("> **Please use */bing_cookies* command to set your bing cookies first.**")
await interaction.followup.send("> **Please use */bing_cookies* command to set your Bing Cookies first.**")
else:
try:
using = await get_using_create(interaction.user.id)
Expand Down
17 changes: 17 additions & 0 deletions cogs/help.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import discord
from core.classes import Cog_Extension
from discord import app_commands

class Help(Cog_Extension):
@app_commands.command(name = "help", description = "Show how to use")
async def help(self, interaction: discord.Interaction):
embed=discord.Embed(title="Help", description="**You need to use /bing_cookies command to set your Bing Cookies first.**\n[see more](https://github.com/FuseFairy/DiscordBot-EdgeGPT/blob/main/README.md)\n\n**COMMANDS -**")
embed.add_field(name="/bing_cookies", value="Set and delete your Bing Cookies.", inline=False)
embed.add_field(name="/bing", value="Chat with Bing.", inline=False)
embed.add_field(name="/reset", value="Reset your Bing conversation.", inline=False)
embed.add_field(name="/switch_style", value="Switch your Bing conversation style.", inline=False)
embed.add_field(name="/create_image", value="Generate image by Bing Image Creator.", inline=False)
await interaction.response.send_message(embed=embed)

async def setup(bot):
await bot.add_cog(Help(bot))