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

Optional command prefix #2

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

james-choncholas
Copy link

Adds the option to use the !gpt prefix to get a response from the bot. Note the bot still records all messages to later use as context when prompted.

@williamkray
Copy link
Owner

in my testing this seems to interfere with the clear subcommand... my bot is only responding to the clear command, rather than clearing the context of the conversation from the in-memory cache.

apologies for the slow response here, i was having trouble with testing due to server issues.

@williamkray
Copy link
Owner

at this point this conflicts with other changes that have happened to the code as well, so it would need to be resolved.

Copy link
Contributor

@BhasherBEL BhasherBEL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also really interested by this feature and hope this could be merged soon. That way, the plugin can be integrated to a more global bot.

Exepect the comments I placed, I don't see any conflict reason with the !clear. Maybe an empty command_prefix, so an empty command ? This case could be handled with a default value of gpt.

@@ -154,7 +162,7 @@ async def _call_gpt(self, prompt):
#self.log.debug(content)
return content

@command.new(name='gpt', help='control chatGPT functionality', require_subcommand=True)
@command.new(name=f"self.config['command_prefix']", help='control chatGPT functionality', require_subcommand=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The f-string here is wrong and unecessary. It should just be self.config['command_prefix']

return

if len(command_prefix) > 0 and not event.content.body.startswith(f"!{command_prefix}"):
return # ignore a comand does not match the required prefix
if len(command_prefix) == 0 and event.content.body.startswith(f'!'):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of this could be replaced by

if not command_prefix or not event.content.body.startswith(f'!{command_prefix}'):
    return

@@ -45,6 +47,7 @@ async def on_message(self, event: MessageEvent) -> None:
user = ''
content = ''
timestamp = datetime.today().strftime('%Y-%m-%d %H:%M:%S')
command_prefix = self.config['command_prefix']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be interesting to strip the config value to avoid "strange" behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants