Skip to content

Commit b9bf502

Browse files
committed
Update ollama.py: translate comments to English
1 parent 271efce commit b9bf502

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

python/ollama.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,51 @@
22
import requests
33
import json
44

5-
# Configuración inicial
5+
# Script metadata
66
SCRIPT_NAME = "ollama_bot"
77
SCRIPT_AUTHOR = "teraflops"
88
SCRIPT_VERSION = "1.5"
99
SCRIPT_LICENSE = "MIT"
10-
SCRIPT_DESC = "Responde automáticamente a menciones con Ollama y permite consultas manuales, incluyendo PMs"
10+
SCRIPT_DESC = "Automatically responds to mentions using Ollama and allows manual queries, including PMs"
1111
OLLAMA_API_URL = "http://localhost:11434/api/generate"
1212

13-
# Registrar el script
13+
# Register the script
1414
weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", "")
1515

16-
# Configuración del script en Weechat
16+
# Script configuration in Weechat
1717
def setup_config():
1818
if not weechat.config_is_set_plugin("highlight_response"):
19-
weechat.config_set_plugin("highlight_response", "on") # Responder a menciones y PMs por defecto
19+
weechat.config_set_plugin("highlight_response", "on") # Enable auto-responses by default
2020
setup_config()
2121

2222
def ask_ollama(message):
23-
"""Consulta a Ollama enviando un mensaje y devuelve la respuesta completa."""
23+
"""Send a query to Ollama and return the complete response."""
2424
try:
2525
data = {"model": "gemma", "prompt": message, "stream": False}
2626
response = requests.post(OLLAMA_API_URL, json=data)
2727
response_json = response.json()
28-
return response_json.get("response", "No se recibió respuesta de Ollama.")
28+
return response_json.get("response", "No response received from Ollama.")
2929
except Exception as e:
30-
return f"Error al conectar con Ollama: {str(e)}"
30+
return f"Error connecting to Ollama: {str(e)}"
3131

3232
def command_ollama(data, buffer, args):
33-
"""Comando /ollama para preguntar manualmente a Ollama."""
33+
"""Command /ollama to manually ask Ollama a question."""
3434
if not args:
35-
weechat.prnt(buffer, "[Ollama] Uso: /ollama <pregunta>")
35+
weechat.prnt(buffer, "[Ollama] Usage: /ollama <question>")
3636
return weechat.WEECHAT_RC_OK
3737

3838
response = ask_ollama(args)
3939
weechat.prnt(buffer, f"[Ollama] {response}")
4040
return weechat.WEECHAT_RC_OK
4141

4242
def message_callback(data, buffer, date, tags, displayed, highlight, prefix, message):
43-
"""Detecta menciones en canales o mensajes privados y responde automáticamente con Ollama."""
43+
"""Detect mentions in channels or private messages and respond automatically with Ollama."""
4444
if weechat.config_get_plugin("highlight_response") == "off":
45-
return weechat.WEECHAT_RC_OK # No responde si la opción está deshabilitada
45+
return weechat.WEECHAT_RC_OK # Do not respond if auto-response is disabled
4646

4747
buffer_type = weechat.buffer_get_string(buffer, "localvar_type")
4848
is_private = buffer_type == "private"
49-
username = weechat.info_get("irc_nick", "") # Obtiene tu nombre de usuario en IRC
49+
username = weechat.info_get("irc_nick", "") # Get current IRC username
5050
is_mentioned = username.lower() in message.lower()
5151

5252
if int(highlight) or is_private or is_mentioned:
@@ -55,17 +55,17 @@ def message_callback(data, buffer, date, tags, displayed, highlight, prefix, mes
5555
return weechat.WEECHAT_RC_OK
5656

5757
def config_callback(data, option, value):
58-
"""Callback para cambios en la configuración de Weechat."""
59-
weechat.prnt("", f"[Ollama] Configuración cambiada: {option} = {value}")
58+
"""Callback for Weechat configuration changes."""
59+
weechat.prnt("", f"[Ollama] Configuration changed: {option} = {value}")
6060
return weechat.WEECHAT_RC_OK
6161

62-
# Registrar configuración con /set
63-
weechat.config_set_desc_plugin("highlight_response", "Responde automáticamente a menciones y PMs (on/off)")
62+
# Register configuration with /set
63+
weechat.config_set_desc_plugin("highlight_response", "Automatically respond to mentions and PMs (on/off)")
6464
weechat.hook_config("plugins.var.python.ollama_bot.highlight_response", "config_callback", "")
6565

66-
# Registrar comandos y hooks
67-
weechat.hook_command("ollama", "Pregunta algo a Ollama", "<pregunta>", "Ejemplo: /ollama ¿Qué es Python?", "", "command_ollama", "")
66+
# Register commands and hooks
67+
weechat.hook_command("ollama", "Ask something to Ollama", "<question>", "Example: /ollama What is Python?", "", "command_ollama", "")
6868
weechat.hook_print("", "notify_highlight", "", 1, "message_callback", "")
69-
weechat.hook_print("", "notify_message", "", 1, "message_callback", "") # Captura mensajes normales
69+
weechat.hook_print("", "notify_message", "", 1, "message_callback", "") # Capture normal messages
7070
weechat.hook_print("", "notify_private", "", 1, "message_callback", "")
7171

0 commit comments

Comments
 (0)