fix issues with chat fetching
This commit is contained in:
parent
857cdf9cfb
commit
b40b2d5b48
6 changed files with 90 additions and 39 deletions
|
|
@ -37,6 +37,7 @@ namespace SecondBotEvents.Commands
|
||||||
{
|
{
|
||||||
return Failure("Invaild channel", new [] { channel, message });
|
return Failure("Invaild channel", new [] { channel, message });
|
||||||
}
|
}
|
||||||
|
master.DataStoreService.BotRecordLocalchatReply(message);
|
||||||
GetClient().Self.Chat(message, channelnum, ChatType.Normal);
|
GetClient().Self.Chat(message, channelnum, ChatType.Normal);
|
||||||
return BasicReply("ok");
|
return BasicReply("ok");
|
||||||
|
|
||||||
|
|
@ -59,6 +60,7 @@ namespace SecondBotEvents.Commands
|
||||||
{
|
{
|
||||||
return Failure("Message empty", new [] { avatar, message });
|
return Failure("Message empty", new [] { avatar, message });
|
||||||
}
|
}
|
||||||
|
master.DataStoreService.OpenChatWindow(false, avataruuid, avataruuid);
|
||||||
master.BotClient.SendIM(avataruuid, message);
|
master.BotClient.SendIM(avataruuid, message);
|
||||||
return BasicReply("ok", new [] { avatar, message });
|
return BasicReply("ok", new [] { avatar, message });
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -325,6 +325,14 @@ namespace SecondBotEvents.Commands
|
||||||
return BasicReply(JsonConvert.SerializeObject(master.DataStoreService.GetGroups()));
|
return BasicReply(JsonConvert.SerializeObject(master.DataStoreService.GetGroups()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[About("Forces the bot to reload the groups list")]
|
||||||
|
[ReturnHints("Working on it")]
|
||||||
|
public object ForceLoadGroups()
|
||||||
|
{
|
||||||
|
master.BotClient.client.Groups.RequestCurrentGroups();
|
||||||
|
return BasicReply("Working on it");
|
||||||
|
}
|
||||||
|
|
||||||
[About("Requests the roles for the selected group")]
|
[About("Requests the roles for the selected group")]
|
||||||
[ReturnHints("GroupRoleDetails object")]
|
[ReturnHints("GroupRoleDetails object")]
|
||||||
[ReturnHintsFailure("Group is not currently known")]
|
[ReturnHintsFailure("Group is not currently known")]
|
||||||
|
|
@ -419,6 +427,7 @@ namespace SecondBotEvents.Commands
|
||||||
return Failure("Unknown group", new[] { group });
|
return Failure("Unknown group", new[] { group });
|
||||||
}
|
}
|
||||||
GetClient().Self.InstantMessageGroup(groupUUID, message);
|
GetClient().Self.InstantMessageGroup(groupUUID, message);
|
||||||
|
master.DataStoreService.BotRecordReplyIM(groupUUID, message);
|
||||||
return BasicReply("Sending");
|
return BasicReply("Sending");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using BetterSecondBot.Static;
|
using BetterSecondBot.Static;
|
||||||
|
using Discord;
|
||||||
using LibreMetaverse;
|
using LibreMetaverse;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenMetaverse.Assets;
|
using OpenMetaverse.Assets;
|
||||||
|
|
@ -186,6 +187,38 @@ namespace SecondBotEvents.Commands
|
||||||
return BasicReply("Ok", new [] { item });
|
return BasicReply("Ok", new [] { item });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[About("Replaces the current avatar outfit with the contents of the given folder")]
|
||||||
|
[ReturnHints("ok")]
|
||||||
|
[ReturnHints("Named folder value is empty")]
|
||||||
|
[ReturnHints("Cant find target folder")]
|
||||||
|
[ReturnHints("invaild folder uuid")]
|
||||||
|
[ReturnHints("target folder is empty or so full I cant get it in 5 secs...")]
|
||||||
|
[ArgHints("folder", "UUID of the folder")]
|
||||||
|
public object SwapOutfit(string folder)
|
||||||
|
{
|
||||||
|
UUID folderUUID = UUID.Zero;
|
||||||
|
if(UUID.TryParse(folder, out folderUUID) == false)
|
||||||
|
{
|
||||||
|
return Failure("invaild folder uuid", new[] { folder });
|
||||||
|
}
|
||||||
|
List<InventoryBase> contents = GetClient().Inventory.FolderContents(folderUUID, GetClient().Self.AgentID, true, true, InventorySortOrder.ByName, 5 * 1000);
|
||||||
|
List<InventoryItem> wareables = new();
|
||||||
|
if (contents == null)
|
||||||
|
{
|
||||||
|
return Failure("target folder is empty or so full I cant get it in 5 secs...", new[] { folder });
|
||||||
|
}
|
||||||
|
foreach (InventoryBase item in contents)
|
||||||
|
{
|
||||||
|
if ((item is InventoryWearable) || (item is InventoryObject))
|
||||||
|
{
|
||||||
|
wareables.Add((InventoryItem)item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
master.CurrentOutfitFolder.ReplaceOutfit(wareables);
|
||||||
|
return BasicReply("ok", new[] { folder });
|
||||||
|
}
|
||||||
|
|
||||||
[About("Replaces the current avatar outfit with the Clothing/[NAME] folder<br/>Please note: This does not use the outfits folder!<br/>Please do not use links in the folder!")]
|
[About("Replaces the current avatar outfit with the Clothing/[NAME] folder<br/>Please note: This does not use the outfits folder!<br/>Please do not use links in the folder!")]
|
||||||
[ReturnHints("ok")]
|
[ReturnHints("ok")]
|
||||||
[ReturnHints("Named folder value is empty")]
|
[ReturnHints("Named folder value is empty")]
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ namespace SecondBotEvents.Commands
|
||||||
return BasicReply("ok", new [] { x, y, z });
|
return BasicReply("ok", new [] { x, y, z });
|
||||||
}
|
}
|
||||||
|
|
||||||
[About("Attempt to teleport to a new region")]
|
[About("Stop the auto pilot system from walking")]
|
||||||
[ReturnHints("ok")]
|
[ReturnHints("ok")]
|
||||||
public object AutoPilotStop()
|
public object AutoPilotStop()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ namespace SecondBotEvents.Services
|
||||||
}
|
}
|
||||||
public void SendIM(UUID avatar, string message)
|
public void SendIM(UUID avatar, string message)
|
||||||
{
|
{
|
||||||
// @todo add message to IM chat
|
master.DataStoreService.BotRecordReplyIM(avatar,message);
|
||||||
client.Self.InstantMessage(avatar, message);
|
client.Self.InstantMessage(avatar, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@ using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using SecondBotEvents.Commands;
|
using SecondBotEvents.Commands;
|
||||||
|
using OpenMetaverse.ImportExport.Collada14;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace SecondBotEvents.Services
|
namespace SecondBotEvents.Services
|
||||||
{
|
{
|
||||||
|
|
@ -281,6 +283,7 @@ namespace SecondBotEvents.Services
|
||||||
{
|
{
|
||||||
return new List<string>();
|
return new List<string>();
|
||||||
}
|
}
|
||||||
|
chatWindowsUnread[group] = false;
|
||||||
return chatWindows[group];
|
return chatWindows[group];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -385,6 +388,23 @@ namespace SecondBotEvents.Services
|
||||||
return groupMembers[Group];
|
return groupMembers[Group];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void BotRecordReplyIM(UUID sessionid,string message)
|
||||||
|
{
|
||||||
|
RecordChat(sessionid, "Bot", message);
|
||||||
|
}
|
||||||
|
public void BotRecordLocalchatReply(string message)
|
||||||
|
{
|
||||||
|
lock (localChatHistory)
|
||||||
|
{
|
||||||
|
localChatHistory.Add("{BOT} " + GetClient().Self.Name + ": " + message);
|
||||||
|
if (localChatHistory.Count <= myConfig.GetLocalChatHistoryLimit())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
localChatHistory.RemoveAt(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void RecordChat(UUID sessionID, string fromname, string message)
|
protected void RecordChat(UUID sessionID, string fromname, string message)
|
||||||
{
|
{
|
||||||
lock (chatWindows)
|
lock (chatWindows)
|
||||||
|
|
@ -438,7 +458,7 @@ namespace SecondBotEvents.Services
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void OpenChatWindow(bool group, UUID sessionID, UUID ownerID)
|
public void OpenChatWindow(bool group, UUID sessionID, UUID ownerID)
|
||||||
{
|
{
|
||||||
lock (chatWindows)
|
lock (chatWindows)
|
||||||
{
|
{
|
||||||
|
|
@ -492,15 +512,6 @@ namespace SecondBotEvents.Services
|
||||||
return groupsKey2Name.ContainsValue(name);
|
return groupsKey2Name.ContainsValue(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<string> GetGroupChat(UUID groupId)
|
|
||||||
{
|
|
||||||
if(chatWindows.ContainsKey(groupId) == false)
|
|
||||||
{
|
|
||||||
return new List<string>();
|
|
||||||
}
|
|
||||||
return chatWindows[groupId];
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* checks if the avatar is known to the system
|
* checks if the avatar is known to the system
|
||||||
* if not the bot will attempt to
|
* if not the bot will attempt to
|
||||||
|
|
@ -645,28 +656,6 @@ namespace SecondBotEvents.Services
|
||||||
return avatarsName2Key[name].ToString();
|
return avatarsName2Key[name].ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<string> GetAvatarIms(UUID avatarId)
|
|
||||||
{
|
|
||||||
if(chatWindowsOwner.ContainsValue(avatarId) == false)
|
|
||||||
{
|
|
||||||
return new List<string>();
|
|
||||||
}
|
|
||||||
UUID sessionID = UUID.Zero;
|
|
||||||
foreach(KeyValuePair<UUID, UUID> links in chatWindowsOwner)
|
|
||||||
{
|
|
||||||
if(links.Value == avatarId)
|
|
||||||
{
|
|
||||||
sessionID = links.Key;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (sessionID == UUID.Zero)
|
|
||||||
{
|
|
||||||
return new List<string>();
|
|
||||||
}
|
|
||||||
return chatWindows[sessionID];
|
|
||||||
}
|
|
||||||
|
|
||||||
public Dictionary<UUID,string> GetAvatarImWindows()
|
public Dictionary<UUID,string> GetAvatarImWindows()
|
||||||
{
|
{
|
||||||
Dictionary<UUID, string> windows = new();
|
Dictionary<UUID, string> windows = new();
|
||||||
|
|
@ -704,6 +693,7 @@ namespace SecondBotEvents.Services
|
||||||
{
|
{
|
||||||
return new List<string>();
|
return new List<string>();
|
||||||
}
|
}
|
||||||
|
chatWindowsUnread[sessionID] = false;
|
||||||
return chatWindows[sessionID];
|
return chatWindows[sessionID];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -869,6 +859,19 @@ namespace SecondBotEvents.Services
|
||||||
protected void BotLoggedIn(object o, SimConnectedEventArgs e)
|
protected void BotLoggedIn(object o, SimConnectedEventArgs e)
|
||||||
{
|
{
|
||||||
GetClient().Network.SimConnected -= BotLoggedIn;
|
GetClient().Network.SimConnected -= BotLoggedIn;
|
||||||
|
botConnected = true;
|
||||||
|
LogFormater.Info("DataStore Service [Attaching]");
|
||||||
|
GetAvatarName(GetClient().Self.AgentID);
|
||||||
|
Task.Factory.StartNew(() =>
|
||||||
|
{
|
||||||
|
Thread.Sleep(2000);
|
||||||
|
attachEventsAfterDelay();
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void attachEventsAfterDelay()
|
||||||
|
{
|
||||||
GetClient().Groups.CurrentGroups += GroupCurrent;
|
GetClient().Groups.CurrentGroups += GroupCurrent;
|
||||||
GetClient().Groups.GroupJoinedReply += GroupJoin;
|
GetClient().Groups.GroupJoinedReply += GroupJoin;
|
||||||
GetClient().Groups.GroupLeaveReply += GroupLeave;
|
GetClient().Groups.GroupLeaveReply += GroupLeave;
|
||||||
|
|
@ -881,9 +884,6 @@ namespace SecondBotEvents.Services
|
||||||
GetClient().Groups.GroupRoleDataReply += GroupRoles;
|
GetClient().Groups.GroupRoleDataReply += GroupRoles;
|
||||||
GetClient().Estate.EstateBansReply += EstateBans;
|
GetClient().Estate.EstateBansReply += EstateBans;
|
||||||
GetClient().Groups.RequestCurrentGroups();
|
GetClient().Groups.RequestCurrentGroups();
|
||||||
botConnected = true;
|
|
||||||
LogFormater.Info("DataStore Service [Active]");
|
|
||||||
GetAvatarName(GetClient().Self.AgentID);
|
|
||||||
}
|
}
|
||||||
readonly string[] hard_blocked_agents = new[] { "secondlife", "second life" };
|
readonly string[] hard_blocked_agents = new[] { "secondlife", "second life" };
|
||||||
protected void ChatFromSim(object o, ChatEventArgs e)
|
protected void ChatFromSim(object o, ChatEventArgs e)
|
||||||
|
|
@ -895,6 +895,10 @@ namespace SecondBotEvents.Services
|
||||||
case ChatType.Shout:
|
case ChatType.Shout:
|
||||||
{
|
{
|
||||||
if (hard_blocked_agents.Contains(e.FromName.ToLowerInvariant()) == true)
|
if (hard_blocked_agents.Contains(e.FromName.ToLowerInvariant()) == true)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (e.SourceID == GetClient().Self.AgentID)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -1035,7 +1039,10 @@ namespace SecondBotEvents.Services
|
||||||
}
|
}
|
||||||
AddAvatar(e.IM.FromAgentID, e.IM.FromAgentName);
|
AddAvatar(e.IM.FromAgentID, e.IM.FromAgentName);
|
||||||
OpenChatWindow(false, e.IM.IMSessionID, e.IM.FromAgentID);
|
OpenChatWindow(false, e.IM.IMSessionID, e.IM.FromAgentID);
|
||||||
|
if (e.IM.FromAgentID != GetClient().Self.AgentID)
|
||||||
|
{
|
||||||
RecordChat(e.IM.IMSessionID, e.IM.FromAgentName, e.IM.Message);
|
RecordChat(e.IM.IMSessionID, e.IM.FromAgentName, e.IM.Message);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue