From be58c0cece3621f523a76c801c1c7d4886fee563 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Wed, 7 Feb 2024 11:25:22 +0100 Subject: [PATCH] add online users to prompt --- README.md | 1 + src/solanaceae/rpbot/rpbot.cpp | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a3c8ac6..75b5081 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ TODO: move rpbot to own repo - System prompt that is prefixed - can contain specific formatters: - `{self_name}` username for specified chat + - `{online_users}` coma seperated list of online users - default: `Transcript of a group chat, where {self_name} talks to online strangers.\n{self_name} is creative and curious. {self_name} is writing with precision, but also with occasional typos.\n` - `RPBot`, `min_messages`(, opt contact ID) diff --git a/src/solanaceae/rpbot/rpbot.cpp b/src/solanaceae/rpbot/rpbot.cpp index f8aa63e..c4bf692 100644 --- a/src/solanaceae/rpbot/rpbot.cpp +++ b/src/solanaceae/rpbot/rpbot.cpp @@ -62,12 +62,20 @@ void RPBot::stateTransition(const Contact3 c, const StateIdle& from, StateNextAc to.prompt = _conf.get_string("RPBot", "system_prompt").value(); } + std::string online_users; + for (const auto& [_, name] : mpb.names) { + if (!online_users.empty()) { + online_users += ", "; + } + online_users += name; + } + to.prompt = fmt::format(fmt::runtime(to.prompt), - fmt::arg("self_name", to.possible_names.at(self)) + fmt::arg("self_name", to.possible_names.at(self)), //fmt::arg("chat_name", "test_group"), //fmt::arg("chat_type", "Group") //fmt::arg("chat_topic", "Group") - // current online? + fmt::arg("online_users", online_users) // current date? ); }