ChatGPT: Add 'enabled' config

This commit is contained in:
Gordon Shumway 2024-08-14 12:59:29 -04:00 committed by GitHub
parent 1ca50ad0a4
commit a5b09877e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View File

@ -54,6 +54,16 @@ ChatGPT = conf.registerPlugin("ChatGPT")
# This is where your configuration variables (if any) should go. For example:
# conf.registerGlobalValue(ChatGPT, 'someConfigVariableName',
# registry.Boolean(False, _("""Help for someConfigVariableName.""")))
conf.registerChannelValue(
ChatGPT,
"enabled",
registry.Boolean(
True,
_("""Set False to disable the plugin, True to enable."""),
),
)
conf.registerGlobalValue(
ChatGPT,
"api_key",

View File

@ -53,6 +53,8 @@ class ChatGPT(callbacks.Plugin):
channel = msg.channel
if not irc.isChannel(channel):
channel = msg.nick
if not self.registryValue("enabled", msg.channel):
return
if self.registryValue("nick_include", msg.channel):
text = "%s: %s" % (msg.nick, text)
self.history.setdefault(channel, None)