Merge branch 'master' of https://gitea.ditaajipratama.net/aji/hendrik into product/public
This commit is contained in:
commit
7e21d829bd
@ -11,6 +11,7 @@ xmpp:
|
||||
nickname: "" # custom MUC nickname (empty = use username)
|
||||
selective_response: true # true = only response if mentioned/relevant
|
||||
debug: false # true = tampilkan log debug menyeluruh (semua stanza XML, lifecycle, dll)
|
||||
mute_session_end: false # true = tidak kirim pesan saat sesi berakhir (timeout)
|
||||
|
||||
telegram:
|
||||
enabled: false
|
||||
@ -19,3 +20,4 @@ telegram:
|
||||
# - "123456789"
|
||||
# - "987654321"
|
||||
selective_response: true # true = only response if mentioned/relevant
|
||||
mute_session_end: false # true = tidak kirim pesan saat sesi berakhir (timeout)
|
||||
|
||||
@ -11,6 +11,7 @@ xmpp:
|
||||
nickname: "" # custom MUC nickname (empty = use username)
|
||||
selective_response: true # true = only response if mentioned/relevant
|
||||
debug: false # true = tampilkan log debug menyeluruh (semua stanza XML, lifecycle, dll)
|
||||
mute_session_end: false # true = tidak kirim pesan saat sesi berakhir (timeout)
|
||||
|
||||
telegram:
|
||||
enabled: false
|
||||
@ -19,3 +20,4 @@ telegram:
|
||||
# - "123456789"
|
||||
# - "987654321"
|
||||
selective_response: true # true = only response if mentioned/relevant
|
||||
mute_session_end: false # true = tidak kirim pesan saat sesi berakhir (timeout)
|
||||
|
||||
@ -38,6 +38,7 @@ xmpp:
|
||||
nickname: "" # custom MUC nickname (empty = use username)
|
||||
selective_response: true # true = only response if mentioned/relevant
|
||||
debug: false # true = tampilkan log debug menyeluruh (semua stanza XML, lifecycle, dll)
|
||||
mute_session_end: false # true = tidak kirim pesan saat sesi berakhir (timeout)
|
||||
|
||||
telegram:
|
||||
enabled: false
|
||||
@ -46,3 +47,4 @@ telegram:
|
||||
# - "123456789"
|
||||
# - "987654321"
|
||||
selective_response: true # true = only response if mentioned/relevant
|
||||
mute_session_end: false # true = tidak kirim pesan saat sesi berakhir (timeout)
|
||||
|
||||
16
config.py
16
config.py
@ -63,6 +63,7 @@ XMPP_MUC_ROOMS = _as_list(_yaml_get("xmpp", "muc_rooms", default=[]))
|
||||
XMPP_NICKNAME = _yaml_get("xmpp", "nickname", default="").strip()
|
||||
XMPP_DEBUG = str(_yaml_get("xmpp", "debug", default="false")).strip().lower() in ("true", "1", "yes")
|
||||
XMPP_SELECTIVE_RESPONSE = str(_yaml_get("xmpp", "selective_response", default="true")).strip().lower() in ("true", "1", "yes")
|
||||
XMPP_MUTE_SESSION_END = str(_yaml_get("xmpp", "mute_session_end", default="false")).strip().lower() in ("true", "1", "yes")
|
||||
|
||||
|
||||
# ─── Telegram ──────────────────────────────────────────────────────────────────
|
||||
@ -71,6 +72,7 @@ TELEGRAM_ENABLED = str(_yaml_get("telegram", "enabled", default="false")).strip(
|
||||
TELEGRAM_TOKEN = _yaml_get("telegram", "token", default="")
|
||||
TELEGRAM_ALLOWED_GROUP_IDS = _as_list(_yaml_get("telegram", "allowed_group_ids", default=[]))
|
||||
TELEGRAM_SELECTIVE_RESPONSE = str(_yaml_get("telegram", "selective_response", default="true")).strip().lower() in ("true", "1", "yes")
|
||||
TELEGRAM_MUTE_SESSION_END = str(_yaml_get("telegram", "mute_session_end", default="false")).strip().lower() in ("true", "1", "yes")
|
||||
|
||||
|
||||
# ─── Session (TinyDB) ────────────────────────────────────────────────────────────
|
||||
@ -155,9 +157,9 @@ SERVICE_YAML_PATH = None # Path service.yaml milik karakter aktif, jika ada
|
||||
def _reset_service_from_config():
|
||||
"""Reset konfigurasi service (xmpp/telegram) dari config.yaml global."""
|
||||
global XMPP_ENABLED, XMPP_USERNAME, XMPP_PASSWORD, XMPP_MUC_ROOMS
|
||||
global XMPP_NICKNAME, XMPP_DEBUG, XMPP_SELECTIVE_RESPONSE
|
||||
global XMPP_NICKNAME, XMPP_DEBUG, XMPP_SELECTIVE_RESPONSE, XMPP_MUTE_SESSION_END
|
||||
global TELEGRAM_ENABLED, TELEGRAM_TOKEN, TELEGRAM_ALLOWED_GROUP_IDS
|
||||
global TELEGRAM_SELECTIVE_RESPONSE, SERVICE_YAML_PATH
|
||||
global TELEGRAM_SELECTIVE_RESPONSE, TELEGRAM_MUTE_SESSION_END, SERVICE_YAML_PATH
|
||||
|
||||
XMPP_USERNAME = _yaml_get("xmpp", "username", default="")
|
||||
XMPP_PASSWORD = _yaml_get("xmpp", "password", default="")
|
||||
@ -166,11 +168,13 @@ def _reset_service_from_config():
|
||||
XMPP_NICKNAME = _yaml_get("xmpp", "nickname", default="").strip()
|
||||
XMPP_DEBUG = str(_yaml_get("xmpp", "debug", default="false")).strip().lower() in ("true", "1", "yes")
|
||||
XMPP_SELECTIVE_RESPONSE = str(_yaml_get("xmpp", "selective_response", default="true")).strip().lower() in ("true", "1", "yes")
|
||||
XMPP_MUTE_SESSION_END = str(_yaml_get("xmpp", "mute_session_end", default="false")).strip().lower() in ("true", "1", "yes")
|
||||
|
||||
TELEGRAM_ENABLED = str(_yaml_get("telegram", "enabled", default="false")).strip().lower() in ("true", "1", "yes")
|
||||
TELEGRAM_TOKEN = _yaml_get("telegram", "token", default="")
|
||||
TELEGRAM_ALLOWED_GROUP_IDS = _as_list(_yaml_get("telegram", "allowed_group_ids", default=[]))
|
||||
TELEGRAM_SELECTIVE_RESPONSE = str(_yaml_get("telegram", "selective_response", default="true")).strip().lower() in ("true", "1", "yes")
|
||||
TELEGRAM_MUTE_SESSION_END = str(_yaml_get("telegram", "mute_session_end", default="false")).strip().lower() in ("true", "1", "yes")
|
||||
|
||||
SERVICE_YAML_PATH = None
|
||||
|
||||
@ -180,9 +184,9 @@ def load_service_config(char_override=None):
|
||||
karakter aktif, jika file tersebut ada di agent/characters/<char>/.
|
||||
Memanggil load_character() bila char_override diberikan."""
|
||||
global XMPP_ENABLED, XMPP_USERNAME, XMPP_PASSWORD, XMPP_MUC_ROOMS
|
||||
global XMPP_NICKNAME, XMPP_DEBUG, XMPP_SELECTIVE_RESPONSE
|
||||
global XMPP_NICKNAME, XMPP_DEBUG, XMPP_SELECTIVE_RESPONSE, XMPP_MUTE_SESSION_END
|
||||
global TELEGRAM_ENABLED, TELEGRAM_TOKEN, TELEGRAM_ALLOWED_GROUP_IDS
|
||||
global TELEGRAM_SELECTIVE_RESPONSE, SERVICE_YAML_PATH
|
||||
global TELEGRAM_SELECTIVE_RESPONSE, TELEGRAM_MUTE_SESSION_END, SERVICE_YAML_PATH
|
||||
|
||||
_reset_service_from_config()
|
||||
|
||||
@ -225,6 +229,8 @@ def load_service_config(char_override=None):
|
||||
XMPP_DEBUG = str(xmpp_data["debug"]).strip().lower() in ("true", "1", "yes")
|
||||
if "selective_response" in xmpp_data:
|
||||
XMPP_SELECTIVE_RESPONSE = str(xmpp_data["selective_response"]).strip().lower() in ("true", "1", "yes")
|
||||
if "mute_session_end" in xmpp_data:
|
||||
XMPP_MUTE_SESSION_END = str(xmpp_data["mute_session_end"]).strip().lower() in ("true", "1", "yes")
|
||||
|
||||
telegram_data = data.get("telegram") or {}
|
||||
if "enabled" in telegram_data:
|
||||
@ -235,6 +241,8 @@ def load_service_config(char_override=None):
|
||||
TELEGRAM_ALLOWED_GROUP_IDS = _as_list(telegram_data["allowed_group_ids"])
|
||||
if "selective_response" in telegram_data:
|
||||
TELEGRAM_SELECTIVE_RESPONSE = str(telegram_data["selective_response"]).strip().lower() in ("true", "1", "yes")
|
||||
if "mute_session_end" in telegram_data:
|
||||
TELEGRAM_MUTE_SESSION_END = str(telegram_data["mute_session_end"]).strip().lower() in ("true", "1", "yes")
|
||||
|
||||
|
||||
# ─── Model Config (model.yaml per karakter) ────────────────────────────────────
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 55 KiB |
@ -59,5 +59,9 @@ mindmapDiagram {
|
||||
*** World
|
||||
**** Building
|
||||
***** Room
|
||||
** Mute Session End (Per Character) <<done>>
|
||||
***_ Tidak Menampilkan "*Session End*" saat session timeout
|
||||
** Continuous Greet after session end (Per Character)
|
||||
***_ Untuk reset history di chat
|
||||
|
||||
@endmindmap
|
||||
@ -332,7 +332,7 @@ class TelegramClient:
|
||||
loggorilla.prcss('telegram', f'Natural close triggered for {chat_id}')
|
||||
self._session_mgr.reset(str(chat_id))
|
||||
else:
|
||||
timeout = 86400 if chat_type == 'private' else 300
|
||||
timeout = 86400 if chat_type == 'private' else 1800
|
||||
session.start_timer(timeout, self._timeout_session, chat_id)
|
||||
|
||||
def _schedule_send(self, chat_id, text, reply_to_msg_id=None):
|
||||
@ -355,6 +355,7 @@ class TelegramClient:
|
||||
|
||||
def _timeout_session(self, chat_id):
|
||||
loggorilla.fyinf('telegram', f'Session timeout: {chat_id}')
|
||||
if not config.TELEGRAM_MUTE_SESSION_END:
|
||||
body = '*session end*' if 'roleplayer' in self._skill else 'Sesi ditutup. Sampai jumpa'
|
||||
self._schedule_send(chat_id, body)
|
||||
self._session_mgr.reset(str(chat_id))
|
||||
|
||||
@ -652,7 +652,7 @@ class XMPPClient(ClientXMPP):
|
||||
print(f'[{_ts()}] Natural close triggered for {jid}', flush=True)
|
||||
self._session_mgr.reset(jid)
|
||||
else:
|
||||
# DM: timeout 24 jam (efektif tidak auto-close), MUC tetap 5 menit
|
||||
# DM: timeout 24 jam (efektif tidak auto-close), MUC 30 menit
|
||||
session.start_timer(86400, self._timeout_session, jid, 'chat')
|
||||
|
||||
async def _process_muc_async(self, room, nick, body):
|
||||
@ -692,7 +692,7 @@ class XMPPClient(ClientXMPP):
|
||||
)
|
||||
if not gate_ok:
|
||||
print(f'[{_ts()}] MUC: need_response=False → staying silent', flush=True)
|
||||
session.start_timer(300, self._timeout_session, room, 'groupchat')
|
||||
session.start_timer(1800, self._timeout_session, room, 'groupchat')
|
||||
return
|
||||
|
||||
# Delay 1: simulasi membaca pesan user (hanya saat akan merespon)
|
||||
@ -772,7 +772,7 @@ class XMPPClient(ClientXMPP):
|
||||
self._session_mgr.reset(room)
|
||||
return
|
||||
|
||||
session.start_timer(300, self._timeout_session, room, 'groupchat')
|
||||
session.start_timer(1800, self._timeout_session, room, 'groupchat')
|
||||
|
||||
def _execute_tool(self, tool_call):
|
||||
from lib.agent_loop import execute_tool
|
||||
@ -879,6 +879,7 @@ class XMPPClient(ClientXMPP):
|
||||
|
||||
def _timeout_session(self, session_id, mtype):
|
||||
print(f'[{_ts()}] Session timeout: {session_id}', flush=True)
|
||||
if not config.XMPP_MUTE_SESSION_END:
|
||||
body = '*session end*' if 'roleplayer' in self._skill else 'Sesi ditutup. Sampai jumpa'
|
||||
self._schedule_send(session_id, body, mtype)
|
||||
self._session_mgr.reset(session_id)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user