-
Notifications
You must be signed in to change notification settings - Fork 5
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
base: main
Are you sure you want to change the base?
Conversation
in my testing this seems to interfere with the apologies for the slow response here, i was having trouble with testing due to server issues. |
at this point this conflicts with other changes that have happened to the code as well, so it would need to be resolved. |
There was a problem hiding this 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) |
There was a problem hiding this comment.
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'!'): |
There was a problem hiding this comment.
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'] |
There was a problem hiding this comment.
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.
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.