Open sourced NatiBot
This commit is contained in:
77
SLBot/bot/Commands/Search/Key2NameCommand.cs
Normal file
77
SLBot/bot/Commands/Search/Key2NameCommand.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : Key2NameCommand.cs
|
||||
Version : 1.0.326
|
||||
Author(s) : Natalia Portillo
|
||||
|
||||
Component : NatiBot
|
||||
|
||||
Revision : r326
|
||||
Last change by : Natalia Portillo
|
||||
Date : 2010/01/01
|
||||
|
||||
--[ License ] --------------------------------------------------------------
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Copyright (C) 2008-2014 Claunia.com
|
||||
****************************************************************************/
|
||||
namespace bot.Commands
|
||||
{
|
||||
using bot;
|
||||
using OpenMetaverse;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
public class Key2NameCommand : Command
|
||||
{
|
||||
ManualResetEvent WaitforAvatar = new ManualResetEvent(false);
|
||||
UUID avatarID;
|
||||
string avatarName;
|
||||
|
||||
public Key2NameCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "key2name";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Key2Name.Description") + " " +
|
||||
bot.Localization.clResourceManager.getText("Commands.Key2Name.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
WaitforAvatar = new ManualResetEvent(false);
|
||||
bool isGroupID = false;
|
||||
|
||||
avatarID = UUID.Zero;
|
||||
avatarName = "";
|
||||
|
||||
if (!UUID.TryParse(args[0], out avatarID))
|
||||
return bot.Localization.clResourceManager.getText("Commands.Key2Name.Usage");
|
||||
|
||||
if (base.Client.key2Name(avatarID, out avatarName, out isGroupID))
|
||||
if (!isGroupID)
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Key2Name.Found"), avatarID, avatarName);
|
||||
else
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Key2Name.Group"), avatarID, avatarName);
|
||||
else
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Key2Name.Timeout"), avatarID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
93
SLBot/bot/Commands/Search/SearchClassifiedsCommand.cs
Normal file
93
SLBot/bot/Commands/Search/SearchClassifiedsCommand.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : SearchClassifiedsCommand.cs
|
||||
Version : 1.0.326
|
||||
Author(s) : Natalia Portillo
|
||||
|
||||
Component : NatiBot
|
||||
|
||||
Revision : r326
|
||||
Last change by : Natalia Portillo
|
||||
Date : 2010/01/01
|
||||
|
||||
--[ License ] --------------------------------------------------------------
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Copyright (C) 2008-2014 Claunia.com
|
||||
****************************************************************************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace bot.Commands
|
||||
{
|
||||
class SearchClassifiedsCommand : Command
|
||||
{
|
||||
System.Threading.AutoResetEvent waitQuery = new System.Threading.AutoResetEvent(false);
|
||||
|
||||
public SearchClassifiedsCommand(SecondLifeBot secondLifeBot)
|
||||
{
|
||||
Name = "searchclassifieds";
|
||||
Description = bot.Localization.clResourceManager.getText("Commands.SearchClassifieds.Description") + " " + bot.Localization.clResourceManager.getText("Commands.SearchClassifieds.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
if (args.Length < 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.SearchClassifieds.Usage");
|
||||
|
||||
string searchText = string.Empty;
|
||||
for (int i = 0; i < args.Length; i++)
|
||||
searchText += args[i] + " ";
|
||||
searchText = searchText.TrimEnd();
|
||||
waitQuery.Reset();
|
||||
|
||||
StringBuilder result = new StringBuilder();
|
||||
|
||||
EventHandler<DirClassifiedsReplyEventArgs> callback = delegate(object sender, DirClassifiedsReplyEventArgs e)
|
||||
{
|
||||
result.AppendFormat(bot.Localization.clResourceManager.getText("Commands.SearchClassifieds.Results") + System.Environment.NewLine,
|
||||
searchText, e.Classifieds.Count);
|
||||
foreach (DirectoryManager.Classified ad in e.Classifieds)
|
||||
{
|
||||
result.AppendLine(ad.ToString());
|
||||
}
|
||||
|
||||
// classifieds are sent 16 ads at a time
|
||||
if (e.Classifieds.Count < 16)
|
||||
{
|
||||
waitQuery.Set();
|
||||
}
|
||||
};
|
||||
|
||||
Client.Directory.DirClassifiedsReply += callback;
|
||||
|
||||
UUID searchID = Client.Directory.StartClassifiedSearch(searchText, DirectoryManager.ClassifiedCategories.Any, DirectoryManager.ClassifiedQueryFlags.Mature | DirectoryManager.ClassifiedQueryFlags.PG);
|
||||
|
||||
if (!waitQuery.WaitOne(20000, false) && Client.Network.Connected)
|
||||
{
|
||||
result.AppendLine(bot.Localization.clResourceManager.getText("Commands.SearchClassifieds.Timeout"));
|
||||
}
|
||||
|
||||
Client.Directory.DirClassifiedsReply -= callback;
|
||||
|
||||
return result.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
103
SLBot/bot/Commands/Search/SearchEventsCommand.cs
Normal file
103
SLBot/bot/Commands/Search/SearchEventsCommand.cs
Normal file
@@ -0,0 +1,103 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : SearchEventsCommand.cs
|
||||
Version : 1.0.326
|
||||
Author(s) : Natalia Portillo
|
||||
|
||||
Component : NatiBot
|
||||
|
||||
Revision : r326
|
||||
Last change by : Natalia Portillo
|
||||
Date : 2010/01/01
|
||||
|
||||
--[ License ] --------------------------------------------------------------
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Copyright (C) 2008-2014 Claunia.com
|
||||
****************************************************************************/
|
||||
namespace bot.Commands.Commands
|
||||
{
|
||||
using bot;
|
||||
using bot.Commands;
|
||||
using OpenMetaverse;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Text;
|
||||
|
||||
internal class SearchEventsCommand : Command
|
||||
{
|
||||
System.Threading.AutoResetEvent waitQuery = new System.Threading.AutoResetEvent(false);
|
||||
int resultCount;
|
||||
StringBuilder sbResult = new StringBuilder();
|
||||
|
||||
public SearchEventsCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "searchevents";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.SearchEvents.Description") + " " + bot.Localization.clResourceManager.getText("Commands.SearchEvents.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
sbResult = new StringBuilder();
|
||||
|
||||
if (args.Length < 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.SearchEvents.Usage");
|
||||
|
||||
string searchText = string.Empty;
|
||||
for (int i = 0; i < args.Length; i++)
|
||||
searchText += args[i] + " ";
|
||||
searchText = searchText.TrimEnd();
|
||||
waitQuery.Reset();
|
||||
|
||||
Client.Directory.DirEventsReply += Directory_DirEvents;
|
||||
Client.Directory.StartEventsSearch(searchText, 0);
|
||||
|
||||
if (waitQuery.WaitOne(20000, false) && Client.Network.Connected)
|
||||
{
|
||||
sbResult.AppendFormat(bot.Localization.clResourceManager.getText("Commands.SearchEvents.Matched"), searchText, resultCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
sbResult.AppendLine(bot.Localization.clResourceManager.getText("Commands.SearchEvents.Timeout"));
|
||||
}
|
||||
Client.Directory.DirEventsReply -= Directory_DirEvents;
|
||||
return sbResult.ToString();
|
||||
;
|
||||
}
|
||||
|
||||
void Directory_DirEvents(object sender, DirEventsReplyEventArgs e)
|
||||
{
|
||||
if (e.MatchedEvents[0].ID == 0 && e.MatchedEvents.Count == 1)
|
||||
{
|
||||
sbResult.AppendLine(bot.Localization.clResourceManager.getText("Commands.SearchEvents.NoResults"));
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (DirectoryManager.EventsSearchData ev in e.MatchedEvents)
|
||||
{
|
||||
sbResult.AppendFormat(bot.Localization.clResourceManager.getText("Commands.SearchEvents.Event"), ev.ID, ev.Name, ev.Date);
|
||||
sbResult.AppendLine();
|
||||
}
|
||||
}
|
||||
resultCount = e.MatchedEvents.Count;
|
||||
waitQuery.Set();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
100
SLBot/bot/Commands/Search/SearchGroupsCommand.cs
Normal file
100
SLBot/bot/Commands/Search/SearchGroupsCommand.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : SearchGroupsCommand.cs
|
||||
Version : 1.0.326
|
||||
Author(s) : Natalia Portillo
|
||||
|
||||
Component : NatiBot
|
||||
|
||||
Revision : r326
|
||||
Last change by : Natalia Portillo
|
||||
Date : 2010/01/01
|
||||
|
||||
--[ License ] --------------------------------------------------------------
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Copyright (C) 2008-2014 Claunia.com
|
||||
****************************************************************************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace bot.Commands
|
||||
{
|
||||
class SearchGroupsCommand : Command
|
||||
{
|
||||
System.Threading.AutoResetEvent waitQuery = new System.Threading.AutoResetEvent(false);
|
||||
int resultCount = 0;
|
||||
|
||||
public SearchGroupsCommand(SecondLifeBot secondLifeBot)
|
||||
{
|
||||
Name = "searchgroups";
|
||||
Description = bot.Localization.clResourceManager.getText("Commands.SearchGroups.Description") + " " + bot.Localization.clResourceManager.getText("Commands.SearchGroups.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
// process command line arguments
|
||||
if (args.Length < 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.SearchGroups.Usage");
|
||||
|
||||
string searchText = string.Empty;
|
||||
for (int i = 0; i < args.Length; i++)
|
||||
searchText += args[i] + " ";
|
||||
searchText = searchText.TrimEnd();
|
||||
|
||||
waitQuery.Reset();
|
||||
|
||||
Client.Directory.DirGroupsReply += Directory_DirGroups;
|
||||
|
||||
// send the request to the directory manager
|
||||
Client.Directory.StartGroupSearch(searchText, 0);
|
||||
|
||||
string result;
|
||||
if (waitQuery.WaitOne(20000, false) && Client.Network.Connected)
|
||||
{
|
||||
result = String.Format(bot.Localization.clResourceManager.getText("Commands.SearchGroups.Matching"), searchText, resultCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = bot.Localization.clResourceManager.getText("Commands.SearchGroups.Timeout");
|
||||
}
|
||||
|
||||
Client.Directory.DirGroupsReply -= Directory_DirGroups;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void Directory_DirGroups(object sender, DirGroupsReplyEventArgs e)
|
||||
{
|
||||
if (e.MatchedGroups.Count > 0)
|
||||
{
|
||||
foreach (DirectoryManager.GroupSearchData group in e.MatchedGroups)
|
||||
{
|
||||
Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.SearchGroups.Members"), group.GroupID, group.GroupName, group.Members);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.SearchGroups.NotFound"));
|
||||
}
|
||||
waitQuery.Set();
|
||||
}
|
||||
}
|
||||
}
|
||||
154
SLBot/bot/Commands/Search/SearchLandCommand.cs
Normal file
154
SLBot/bot/Commands/Search/SearchLandCommand.cs
Normal file
@@ -0,0 +1,154 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : SearchLandCommand.cs
|
||||
Version : 1.0.326
|
||||
Author(s) : Natalia Portillo
|
||||
|
||||
Component : NatiBot
|
||||
|
||||
Revision : r326
|
||||
Last change by : Natalia Portillo
|
||||
Date : 2010/01/01
|
||||
|
||||
--[ License ] --------------------------------------------------------------
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Copyright (C) 2008-2014 Claunia.com
|
||||
****************************************************************************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace bot.Commands
|
||||
{
|
||||
public class SearchLandCommand : Command
|
||||
{
|
||||
private System.Threading.AutoResetEvent waitQuery = new System.Threading.AutoResetEvent(false);
|
||||
private StringBuilder result = new StringBuilder();
|
||||
|
||||
/// <summary>
|
||||
/// Construct a new instance of the SearchLandCommand
|
||||
/// </summary>
|
||||
/// <param name="testClient"></param>
|
||||
public SearchLandCommand(SecondLifeBot secondLifeBot)
|
||||
{
|
||||
Name = "searchland";
|
||||
Description = bot.Localization.clResourceManager.getText("Commands.SearchLand.Description");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show commandusage
|
||||
/// </summary>
|
||||
/// <returns>A string containing the parameter usage instructions</returns>
|
||||
public string ShowUsage()
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.SearchLand.UsageLine1") + System.Environment.NewLine +
|
||||
bot.Localization.clResourceManager.getText("Commands.SearchLand.UsageLine2") + System.Environment.NewLine +
|
||||
bot.Localization.clResourceManager.getText("Commands.SearchLand.UsageLine3") + System.Environment.NewLine +
|
||||
bot.Localization.clResourceManager.getText("Commands.SearchLand.UsageLine4");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="args"></param>
|
||||
/// <param name="fromAgentID"></param>
|
||||
/// <returns></returns>
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
// process command line arguments
|
||||
if (args.Length < 3)
|
||||
return ShowUsage();
|
||||
|
||||
string searchType = args[0].Trim().ToLower();
|
||||
int maxPrice;
|
||||
int minSize;
|
||||
|
||||
DirectoryManager.SearchTypeFlags searchTypeFlags = DirectoryManager.SearchTypeFlags.Any;
|
||||
|
||||
if (searchType.StartsWith("au"))
|
||||
searchTypeFlags = DirectoryManager.SearchTypeFlags.Auction;
|
||||
else if (searchType.StartsWith("m"))
|
||||
searchTypeFlags = DirectoryManager.SearchTypeFlags.Mainland;
|
||||
else if (searchType.StartsWith("e"))
|
||||
searchTypeFlags = DirectoryManager.SearchTypeFlags.Estate;
|
||||
else if (searchType.StartsWith("al"))
|
||||
searchTypeFlags = DirectoryManager.SearchTypeFlags.Any;
|
||||
else
|
||||
return ShowUsage();
|
||||
|
||||
// initialize some default flags we'll use in the search
|
||||
DirectoryManager.DirFindFlags queryFlags = DirectoryManager.DirFindFlags.SortAsc | DirectoryManager.DirFindFlags.PerMeterSort
|
||||
| DirectoryManager.DirFindFlags.IncludeAdult | DirectoryManager.DirFindFlags.IncludePG | DirectoryManager.DirFindFlags.IncludeMature;
|
||||
|
||||
// validate the parameters passed
|
||||
if (int.TryParse(args[1], out maxPrice) && int.TryParse(args[2], out minSize))
|
||||
{
|
||||
// if the [max price] parameter is greater than 0, we'll enable the flag to limit by price
|
||||
if (maxPrice > 0)
|
||||
queryFlags |= DirectoryManager.DirFindFlags.LimitByPrice;
|
||||
|
||||
// if the [min size] parameter is greater than 0, we'll enable the flag to limit by area
|
||||
if (minSize > 0)
|
||||
queryFlags |= DirectoryManager.DirFindFlags.LimitByArea;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ShowUsage();
|
||||
}
|
||||
|
||||
//waitQuery.Reset();
|
||||
|
||||
// subscribe to the event that returns the search results
|
||||
Client.Directory.DirLandReply += Directory_DirLand;
|
||||
|
||||
// send the request to the directory manager
|
||||
Client.Directory.StartLandSearch(queryFlags, searchTypeFlags, maxPrice, minSize, 0);
|
||||
|
||||
if (!waitQuery.WaitOne(20000, false) && Client.Network.Connected)
|
||||
{
|
||||
result.AppendLine(bot.Localization.clResourceManager.getText("Commands.SearchLand.Timeout"));
|
||||
}
|
||||
|
||||
// unsubscribe to the event that returns the search results
|
||||
Client.Directory.DirLandReply -= Directory_DirLand;
|
||||
|
||||
// return the results
|
||||
return result.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Process the search reply
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void Directory_DirLand(object sender, DirLandReplyEventArgs e)
|
||||
{
|
||||
|
||||
foreach (DirectoryManager.DirectoryParcel searchResult in e.DirParcels)
|
||||
{
|
||||
// add the results to the StringBuilder object that contains the results
|
||||
result.AppendLine(searchResult.ToString());
|
||||
}
|
||||
result.AppendFormat(bot.Localization.clResourceManager.getText("Commands.SearchLand.Results") + System.Environment.NewLine, e.DirParcels.Count);
|
||||
// let the calling method know we have data
|
||||
waitQuery.Set();
|
||||
}
|
||||
}
|
||||
}
|
||||
101
SLBot/bot/Commands/Search/SearchPeopleCommand.cs
Normal file
101
SLBot/bot/Commands/Search/SearchPeopleCommand.cs
Normal file
@@ -0,0 +1,101 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : SearchPeopleCommand.cs
|
||||
Version : 1.0.326
|
||||
Author(s) : Natalia Portillo
|
||||
|
||||
Component : NatiBot
|
||||
|
||||
Revision : r326
|
||||
Last change by : Natalia Portillo
|
||||
Date : 2010/01/01
|
||||
|
||||
--[ License ] --------------------------------------------------------------
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Copyright (C) 2008-2014 Claunia.com
|
||||
****************************************************************************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace bot.Commands
|
||||
{
|
||||
class SearchPeopleCommand : Command
|
||||
{
|
||||
System.Threading.AutoResetEvent waitQuery = new System.Threading.AutoResetEvent(false);
|
||||
int resultCount = 0;
|
||||
|
||||
public SearchPeopleCommand(SecondLifeBot secondLifeBot)
|
||||
{
|
||||
Name = "searchpeople";
|
||||
Description = bot.Localization.clResourceManager.getText("Commands.SearchPeople.Description") + " " + bot.Localization.clResourceManager.getText("Commands.SearchPeople.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
// process command line arguments
|
||||
if (args.Length < 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.SearchPeople.Usage");
|
||||
|
||||
string searchText = string.Empty;
|
||||
for (int i = 0; i < args.Length; i++)
|
||||
searchText += args[i] + " ";
|
||||
searchText = searchText.TrimEnd();
|
||||
|
||||
waitQuery.Reset();
|
||||
|
||||
|
||||
Client.Directory.DirPeopleReply += Directory_DirPeople;
|
||||
|
||||
// send the request to the directory manager
|
||||
Client.Directory.StartPeopleSearch(searchText, 0);
|
||||
|
||||
string result;
|
||||
if (waitQuery.WaitOne(20000, false) && Client.Network.Connected)
|
||||
{
|
||||
result = String.Format(bot.Localization.clResourceManager.getText("Commands.SearchPeople.Matching"), searchText, resultCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = bot.Localization.clResourceManager.getText("Commands.SearchPeople.Timeout");
|
||||
}
|
||||
|
||||
Client.Directory.DirPeopleReply -= Directory_DirPeople;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void Directory_DirPeople(object sender, DirPeopleReplyEventArgs e)
|
||||
{
|
||||
if (e.MatchedPeople.Count > 0)
|
||||
{
|
||||
foreach (DirectoryManager.AgentSearchData agent in e.MatchedPeople)
|
||||
{
|
||||
Console.WriteLine("{0} {1} ({2})", agent.FirstName, agent.LastName, agent.AgentID);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine(bot.Localization.clResourceManager.getText("Commands.SearchPeople.NotFound"));
|
||||
}
|
||||
waitQuery.Set();
|
||||
}
|
||||
}
|
||||
}
|
||||
88
SLBot/bot/Commands/Search/SearchPlacesCommand.cs
Normal file
88
SLBot/bot/Commands/Search/SearchPlacesCommand.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : SearchPlacesCommand.cs
|
||||
Version : 1.0.326
|
||||
Author(s) : Natalia Portillo
|
||||
|
||||
Component : NatiBot
|
||||
|
||||
Revision : r326
|
||||
Last change by : Natalia Portillo
|
||||
Date : 2010/01/01
|
||||
|
||||
--[ License ] --------------------------------------------------------------
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Copyright (C) 2008-2014 Claunia.com
|
||||
****************************************************************************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace bot.Commands
|
||||
{
|
||||
class SearchPlacesCommand : Command
|
||||
{
|
||||
System.Threading.AutoResetEvent waitQuery = new System.Threading.AutoResetEvent(false);
|
||||
|
||||
public SearchPlacesCommand(SecondLifeBot secondLifeBot)
|
||||
{
|
||||
Name = "searchplaces";
|
||||
Description = bot.Localization.clResourceManager.getText("Commands.SearchPlaces.Description") + " " + bot.Localization.clResourceManager.getText("Commands.SearchPlaces.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
if (args.Length < 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.SearchPlaces.Usage");
|
||||
|
||||
string searchText = string.Empty;
|
||||
for (int i = 0; i < args.Length; i++)
|
||||
searchText += args[i] + " ";
|
||||
searchText = searchText.TrimEnd();
|
||||
waitQuery.Reset();
|
||||
|
||||
StringBuilder result = new StringBuilder();
|
||||
|
||||
EventHandler<PlacesReplyEventArgs> callback = delegate(object sender, PlacesReplyEventArgs e)
|
||||
{
|
||||
result.AppendFormat(bot.Localization.clResourceManager.getText("Commands.SearchPlaces.Results") + System.Environment.NewLine,
|
||||
searchText, e.MatchedPlaces.Count);
|
||||
foreach (DirectoryManager.PlacesSearchData place in e.MatchedPlaces)
|
||||
{
|
||||
result.AppendLine(place.ToString());
|
||||
}
|
||||
|
||||
waitQuery.Set();
|
||||
};
|
||||
|
||||
Client.Directory.PlacesReply += callback;
|
||||
Client.Directory.StartPlacesSearch(searchText);
|
||||
|
||||
if (!waitQuery.WaitOne(20000, false) && Client.Network.Connected)
|
||||
{
|
||||
result.AppendLine(bot.Localization.clResourceManager.getText("Commands.SearchPlaces.Timeout"));
|
||||
}
|
||||
|
||||
Client.Directory.PlacesReply -= callback;
|
||||
|
||||
return result.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
89
SLBot/bot/Commands/Search/ShowEventDetailsCommand.cs
Normal file
89
SLBot/bot/Commands/Search/ShowEventDetailsCommand.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : ShowEventDetailsCommand.cs
|
||||
Version : 1.0.326
|
||||
Author(s) : Natalia Portillo
|
||||
|
||||
Component : NatiBot
|
||||
|
||||
Revision : r326
|
||||
Last change by : Natalia Portillo
|
||||
Date : 2010/01/01
|
||||
|
||||
--[ License ] --------------------------------------------------------------
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Copyright (C) 2008-2014 Claunia.com
|
||||
****************************************************************************/
|
||||
namespace bot.Commands
|
||||
{
|
||||
using bot;
|
||||
using OpenMetaverse;
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
internal class ShowEventDetailsCommand : Command
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
ManualResetEvent detailsEvent = new ManualResetEvent(false);
|
||||
|
||||
public ShowEventDetailsCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "showevent";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.ShowEventDetails.Description") + " " + bot.Localization.clResourceManager.getText("Commands.ShowEventDetails.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
sb = new StringBuilder();
|
||||
detailsEvent.Reset();
|
||||
|
||||
if (args.Length < 1)
|
||||
return bot.Localization.clResourceManager.getText("Commands.ShowEventDetails.Usage");
|
||||
|
||||
Client.Directory.EventInfoReply += Directory_EventDetails;
|
||||
uint eventID;
|
||||
|
||||
if (UInt32.TryParse(args[0], out eventID))
|
||||
{
|
||||
Client.Directory.EventInfoRequest(eventID);
|
||||
sb.AppendLine(bot.Localization.clResourceManager.getText("Commands.ShowEventDetails.Query"));
|
||||
detailsEvent.WaitOne(15000, false);
|
||||
return sb.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.ShowEventDetails.Usage");
|
||||
}
|
||||
}
|
||||
|
||||
void Directory_EventDetails(object sender, EventInfoReplyEventArgs e)
|
||||
{
|
||||
float x, y;
|
||||
Helpers.GlobalPosToRegionHandle((float)e.MatchedEvent.GlobalPos.X, (float)e.MatchedEvent.GlobalPos.Y, out x, out y);
|
||||
sb.AppendFormat(bot.Localization.clResourceManager.getText("Commands.ShowEventDetails.Name") + System.Environment.NewLine, e.MatchedEvent.Name, e.MatchedEvent.ID);
|
||||
sb.AppendFormat(bot.Localization.clResourceManager.getText("Commands.ShowEventDetails.Location") + System.Environment.NewLine, e.MatchedEvent.SimName, x, y);
|
||||
sb.AppendFormat(bot.Localization.clResourceManager.getText("Commands.ShowEventDetails.Date") + System.Environment.NewLine, e.MatchedEvent.Date);
|
||||
sb.AppendFormat(bot.Localization.clResourceManager.getText("Commands.ShowEventDetails.EventDescription") + System.Environment.NewLine, e.MatchedEvent.Desc);
|
||||
Client.Directory.EventInfoReply -= Directory_EventDetails;
|
||||
detailsEvent.Set();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user