adds custom name for the AI

This commit is contained in:
Madpeter 2025-01-28 22:55:28 +00:00
parent 4148d6d832
commit 68a71f5e0d
2 changed files with 14 additions and 3 deletions

View file

@ -27,6 +27,12 @@ namespace SecondBotEvents.Config
settings.Add("ChatHistoryTimeout"); settings.Add("ChatHistoryTimeout");
settings.Add("ShowDebug"); settings.Add("ShowDebug");
settings.Add("Provider"); settings.Add("Provider");
settings.Add("CustomName");
}
public string GetCustomName()
{
return ReadSettingAsString("CustomName", "<!FIRSTNAME!>");
} }
public bool GetShowDebug() public bool GetShowDebug()

View file

@ -288,19 +288,24 @@ namespace SecondBotEvents.Services
} }
// trim history // trim history
List<KeyValuePair<string, string>> history = chatHistoryAI[user]; List<KeyValuePair<string, string>> history = chatHistoryAI[user];
string yourname = GetClient().Self.FirstName;
if(myConfig.GetCustomName() != "<!FIRSTNAME!>")
{
yourname = myConfig.GetCustomName();
}
if (history.Count() == 0) if (history.Count() == 0)
{ {
if (avatarchat == true) if (avatarchat == true)
{ {
history.Add(new KeyValuePair<string, string>("system", "You are " + GetClient().Self.FirstName + ", "+myConfig.GetChatPrompt()+", you are talking to " + name + ".")); history.Add(new KeyValuePair<string, string>("system", "You are " + yourname + ", "+myConfig.GetChatPrompt()+", you are talking to " + name + "."));
} }
else if (groupchat == true) else if (groupchat == true)
{ {
history.Add(new KeyValuePair<string, string>("system", "You are " + GetClient().Self.FirstName + ", "+myConfig.GetChatPrompt()+", you are talking to a group of people.")); history.Add(new KeyValuePair<string, string>("system", "You are " + yourname + ", "+myConfig.GetChatPrompt()+", you are talking to a group of people."));
} }
else else
{ {
history.Add(new KeyValuePair<string, string>("system", "You are " + GetClient().Self.FirstName + ", "+myConfig.GetChatPrompt()+", you are talking to people in a public place.")); history.Add(new KeyValuePair<string, string>("system", "You are " + yourname + ", "+myConfig.GetChatPrompt()+", you are talking to people in a public place."));
} }
} }
history.Add(new KeyValuePair<string, string>("user", "" + name + " says " + message)); history.Add(new KeyValuePair<string, string>("user", "" + name + " says " + message));