5
5
# Script metadata
6
6
SCRIPT_NAME = "ollama_bot"
7
7
SCRIPT_AUTHOR = "teraflops"
8
- SCRIPT_VERSION = "1.5 "
8
+ SCRIPT_VERSION = "1.6 "
9
9
SCRIPT_LICENSE = "MIT"
10
10
SCRIPT_DESC = "Automatically responds to mentions using Ollama and allows manual queries, including PMs"
11
11
OLLAMA_API_URL = "http://localhost:11434/api/generate"
17
17
def setup_config ():
18
18
if not weechat .config_is_set_plugin ("highlight_response" ):
19
19
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
20
22
setup_config ()
21
23
22
24
def ask_ollama (message ):
@@ -49,7 +51,11 @@ def message_callback(data, buffer, date, tags, displayed, highlight, prefix, mes
49
51
username = weechat .info_get ("irc_nick" , "" ) # Get current IRC username
50
52
is_mentioned = username .lower () in message .lower ()
51
53
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 :
53
59
response = ask_ollama (message )
54
60
weechat .command (buffer , f"/msg { prefix } { response } " )
55
61
return weechat .WEECHAT_RC_OK
@@ -60,8 +66,10 @@ def config_callback(data, option, value):
60
66
return weechat .WEECHAT_RC_OK
61
67
62
68
# 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)" )
64
71
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" , "" )
65
73
66
74
# Register commands and hooks
67
75
weechat .hook_command ("ollama" , "Ask something to Ollama" , "<question>" , "Example: /ollama What is Python?" , "" , "command_ollama" , "" )
0 commit comments