Skip to content

Commit d758c85

Browse files
committed
Update ollama_bot.py: translate comments to English
1 parent b9bf502 commit d758c85

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

python/ollama.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Script metadata
66
SCRIPT_NAME = "ollama_bot"
77
SCRIPT_AUTHOR = "teraflops"
8-
SCRIPT_VERSION = "1.5"
8+
SCRIPT_VERSION = "1.6"
99
SCRIPT_LICENSE = "MIT"
1010
SCRIPT_DESC = "Automatically responds to mentions using Ollama and allows manual queries, including PMs"
1111
OLLAMA_API_URL = "http://localhost:11434/api/generate"
@@ -17,6 +17,8 @@
1717
def setup_config():
1818
if not weechat.config_is_set_plugin("highlight_response"):
1919
weechat.config_set_plugin("highlight_response", "on") # Enable auto-responses by default
20+
if not weechat.config_is_set_plugin("pm_response"):
21+
weechat.config_set_plugin("pm_response", "off") # Disable PM responses by default
2022
setup_config()
2123

2224
def ask_ollama(message):
@@ -49,7 +51,11 @@ def message_callback(data, buffer, date, tags, displayed, highlight, prefix, mes
4951
username = weechat.info_get("irc_nick", "") # Get current IRC username
5052
is_mentioned = username.lower() in message.lower()
5153

52-
if int(highlight) or is_private or is_mentioned:
54+
# Check if PM responses are disabled
55+
if is_private and weechat.config_get_plugin("pm_response") == "off":
56+
return weechat.WEECHAT_RC_OK
57+
58+
if int(highlight) or is_mentioned or is_private:
5359
response = ask_ollama(message)
5460
weechat.command(buffer, f"/msg {prefix} {response}")
5561
return weechat.WEECHAT_RC_OK
@@ -60,8 +66,10 @@ def config_callback(data, option, value):
6066
return weechat.WEECHAT_RC_OK
6167

6268
# Register configuration with /set
63-
weechat.config_set_desc_plugin("highlight_response", "Automatically respond to mentions and PMs (on/off)")
69+
weechat.config_set_desc_plugin("highlight_response", "Automatically respond to mentions in channels (on/off)")
70+
weechat.config_set_desc_plugin("pm_response", "Automatically respond to private messages (on/off)")
6471
weechat.hook_config("plugins.var.python.ollama_bot.highlight_response", "config_callback", "")
72+
weechat.hook_config("plugins.var.python.ollama_bot.pm_response", "config_callback", "")
6573

6674
# Register commands and hooks
6775
weechat.hook_command("ollama", "Ask something to Ollama", "<question>", "Example: /ollama What is Python?", "", "command_ollama", "")

0 commit comments

Comments
 (0)