You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
870 B

from edmond.plugin import Plugin
from edmond.plugins.gpt3 import Gpt3Plugin
class UnknownCommandPlugin(Plugin):
def __init__(self, bot):
super().__init__(bot)
self.priority: int = -6
self.gpt3_plugin: Gpt3Plugin
def on_welcome(self, _):
self.gpt3_plugin = self.bot.get_plugin("gpt3")
if self.gpt3_plugin is None or not self.gpt3_plugin:
self.bot.log_w("GPT-3 plugin is not available.")
self.is_ready = False
def on_pubmsg(self, event):
message = self.should_read_message(event.arguments[0])
if not message:
return False
words = message.split()
if len(words) == 0 or words[-1] != self.config["command_suffix"]:
return False
query = " ".join(words[:-1])
self.gpt3_plugin.reply(query, event.target)
return True