Open sourced NatiBot
This commit is contained in:
70
SLBot/bot/Commands/Communication/EchoMasterCommand.cs
Normal file
70
SLBot/bot/Commands/Communication/EchoMasterCommand.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : EchoMasterCommand.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;
|
||||
|
||||
public class EchoMasterCommand : Command
|
||||
{
|
||||
public EchoMasterCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "echoMaster";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.EchoMaster.Description");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
if (!Active)
|
||||
{
|
||||
Active = true;
|
||||
Client.Self.ChatFromSimulator += Self_ChatFromSimulator;
|
||||
return bot.Localization.clResourceManager.getText("Commands.EchoMaster.On");
|
||||
}
|
||||
else
|
||||
{
|
||||
Active = false;
|
||||
Client.Self.ChatFromSimulator -= Self_ChatFromSimulator;
|
||||
return bot.Localization.clResourceManager.getText("Commands.EchoMaster.Off");
|
||||
}
|
||||
}
|
||||
|
||||
void Self_ChatFromSimulator(object sender, ChatEventArgs e)
|
||||
{
|
||||
if (e.Message.Length > 0 && (Client.MasterKey == e.SourceID || (Client.MasterName == e.FromName /*&& !Client.AllowObjectMaster*/)))
|
||||
Client.Self.Chat(e.Message, 0, ChatType.Normal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
121
SLBot/bot/Commands/Communication/ImCommand.cs
Normal file
121
SLBot/bot/Commands/Communication/ImCommand.cs
Normal file
@@ -0,0 +1,121 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : ImCommand.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 ImCommand : Command
|
||||
{
|
||||
string ToAvatarName = String.Empty;
|
||||
ManualResetEvent NameSearchEvent = new ManualResetEvent(false);
|
||||
Dictionary<string, UUID> Name2Key = new Dictionary<string, UUID>();
|
||||
|
||||
public ImCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
SecondLifeBot.Avatars.AvatarPickerReply += Avatars_AvatarPickerReply;
|
||||
base.Name = "im";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.IM.Description") + " " + bot.Localization.clResourceManager.getText("Commands.IM.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
if (args.Length < 3)
|
||||
return bot.Localization.clResourceManager.getText("Commands.IM.Usage");
|
||||
|
||||
ToAvatarName = args[0] + " " + args[1];
|
||||
|
||||
// Build the message
|
||||
string message = String.Empty;
|
||||
for (int ct = 2; ct < args.Length; ct++)
|
||||
message += args[ct] + " ";
|
||||
message = message.TrimEnd();
|
||||
if (message.Length > 1023)
|
||||
message = message.Remove(1023);
|
||||
|
||||
if (!Name2Key.ContainsKey(ToAvatarName.ToLower()))
|
||||
{
|
||||
// Send the Query
|
||||
Client.Avatars.RequestAvatarNameSearch(ToAvatarName, UUID.Random());
|
||||
|
||||
NameSearchEvent.WaitOne(6000, false);
|
||||
}
|
||||
|
||||
if (Name2Key.ContainsKey(ToAvatarName.ToLower()))
|
||||
{
|
||||
UUID id = Name2Key[ToAvatarName.ToLower()];
|
||||
|
||||
Client.Self.InstantMessage(id, message);
|
||||
|
||||
bot.Chat.structInstantMessage sim;
|
||||
InstantMessage im = new InstantMessage();
|
||||
|
||||
im.Message = message;
|
||||
im.FromAgentID = id;
|
||||
im.FromAgentName = ToAvatarName;
|
||||
im.Dialog = InstantMessageDialog.MessageFromAgent;
|
||||
|
||||
sim.client = this.Client;
|
||||
sim.isReceived = false;
|
||||
sim.message = im;
|
||||
sim.simulator = this.Client.Network.CurrentSim;
|
||||
sim.timestamp = DateTime.Now;
|
||||
|
||||
bot.Chat.receivedIM(sim);
|
||||
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.IM.Success"), id.ToString(), message);
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.IM.LookupFail"), ToAvatarName);
|
||||
}
|
||||
}
|
||||
|
||||
void Avatars_AvatarPickerReply(object sender, AvatarPickerReplyEventArgs e)
|
||||
{
|
||||
foreach (KeyValuePair<UUID, string> kvp in e.Avatars)
|
||||
{
|
||||
if (kvp.Value.ToLower() == ToAvatarName.ToLower())
|
||||
{
|
||||
Name2Key[ToAvatarName.ToLower()] = kvp.Key;
|
||||
NameSearchEvent.Set();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
78
SLBot/bot/Commands/Communication/SayCommand.cs
Normal file
78
SLBot/bot/Commands/Communication/SayCommand.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : SayCommand.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;
|
||||
|
||||
public class SayCommand : Command
|
||||
{
|
||||
public SayCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "say";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Say.Description") + " " + bot.Localization.clResourceManager.getText("Commands.Say.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
int channel = 0;
|
||||
int startIndex = 0;
|
||||
|
||||
if (args.Length < 1)
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.Say.Usage");
|
||||
}
|
||||
else if (args.Length > 1)
|
||||
{
|
||||
if (Int32.TryParse(args[0], out channel))
|
||||
startIndex = 1;
|
||||
}
|
||||
|
||||
StringBuilder message = new StringBuilder();
|
||||
|
||||
for (int i = startIndex; i < args.Length; i++)
|
||||
{
|
||||
message.Append(args[i]);
|
||||
if (i != args.Length - 1)
|
||||
message.Append(" ");
|
||||
}
|
||||
|
||||
Client.Self.Chat(message.ToString(), channel, ChatType.Normal);
|
||||
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Say.Said"), message.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
80
SLBot/bot/Commands/Communication/ShoutCommand.cs
Normal file
80
SLBot/bot/Commands/Communication/ShoutCommand.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : ShoutCommand.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;
|
||||
|
||||
public class ShoutCommand : Command
|
||||
{
|
||||
public ShoutCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "shout";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Shout.Description") + " " + bot.Localization.clResourceManager.getText("Commands.Shout.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
int channel = 0;
|
||||
int startIndex = 0;
|
||||
string message = String.Empty;
|
||||
if (args.Length < 1)
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.Shout.Usage");
|
||||
}
|
||||
else if (args.Length > 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
channel = Convert.ToInt32(args[0]);
|
||||
startIndex = 1;
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
channel = 0;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = startIndex; i < args.Length; i++)
|
||||
{
|
||||
message += args[i] + " ";
|
||||
}
|
||||
|
||||
Client.Self.Chat(message, channel, ChatType.Shout);
|
||||
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Shout.Shouted"), message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
80
SLBot/bot/Commands/Communication/WhisperCommand.cs
Normal file
80
SLBot/bot/Commands/Communication/WhisperCommand.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
/***************************************************************************
|
||||
The Disc Image Chef
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Filename : WhisperCommand.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;
|
||||
|
||||
public class WhisperCommand : Command
|
||||
{
|
||||
public WhisperCommand(SecondLifeBot SecondLifeBot)
|
||||
{
|
||||
base.Name = "whisper";
|
||||
base.Description = bot.Localization.clResourceManager.getText("Commands.Whisper.Description") + " " + bot.Localization.clResourceManager.getText("Commands.Whisper.Usage");
|
||||
}
|
||||
|
||||
public override string Execute(string[] args, UUID fromAgentID, bool fromSL)
|
||||
{
|
||||
int channel = 0;
|
||||
int startIndex = 0;
|
||||
string message = String.Empty;
|
||||
if (args.Length < 1)
|
||||
{
|
||||
return bot.Localization.clResourceManager.getText("Commands.Whisper.Usage");
|
||||
}
|
||||
else if (args.Length > 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
channel = Convert.ToInt32(args[0]);
|
||||
startIndex = 1;
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
channel = 0;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = startIndex; i < args.Length; i++)
|
||||
{
|
||||
message += args[i] + " ";
|
||||
}
|
||||
|
||||
Client.Self.Chat(message, channel, ChatType.Whisper);
|
||||
|
||||
return String.Format(bot.Localization.clResourceManager.getText("Commands.Whisper.Whispered"), message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user