This commit is contained in:
Madpeter 2020-04-29 04:12:55 +01:00
parent a4deb6857a
commit 9b5ac724e4
13 changed files with 74 additions and 37 deletions

View file

@ -38,10 +38,16 @@ namespace BetterSecondBotShared.logs
var date = DateTime.Now;
StringBuilder n = new StringBuilder();
n.Append("[");
if(date.Hour < 10) n.Append("0");
if (date.Hour < 10)
{
n.Append("0");
}
n.Append(date.Hour.ToString());
n.Append(":");
if (date.Minute < 10) n.Append("0");
if (date.Minute < 10)
{
n.Append("0");
}
n.Append(date.Minute.ToString());
n.Append("] ");
switch (Level)

View file

@ -150,13 +150,13 @@ namespace BetterSecondBotShared.Static
{
if (V != null)
{
if (V.Length > 0) return true;
else return false;
}
else
{
return false;
if (V.Length > 0)
{
return true;
}
}
return false;
}
public static bool notempty(string[] V)
{
@ -164,10 +164,7 @@ namespace BetterSecondBotShared.Static
{
return true;
}
else
{
return false;
}
return false;
}
}
}

View file

@ -7,8 +7,8 @@ namespace BetterSecondBot.HttpServer.Control.Interface
{
public class CoreCMD : HTTP_commands_post
{
public override string[] ArgTypes { get { return new string[] { "Text","Text" }; } }
public override string[] ArgHints { get { return new string[] { "Command","Args (~#~ split)" }; } }
public override string[] ArgTypes { get { return new [] { "Text","Text" }; } }
public override string[] ArgHints { get { return new [] { "Command","Args (~#~ split)" }; } }
public override string Helpfile { get { return "Calls the Commands interface via HTTP (returns OK if not rejected)"; } }
public override int MinArgs { get { return 2; } }

View file

@ -136,7 +136,10 @@ namespace BetterSecondBot.HttpServer
foreach(string B in pairs)
{
string[] bits = B.Split('=', StringSplitOptions.RemoveEmptyEntries);
if(bits.Length == 2) post_args.Add(bits[0].Trim(), bits[1].Trim());
if (bits.Length == 2)
{
post_args.Add(bits[0].Trim(), bits[1].Trim());
}
}
if (post_args.ContainsKey("command") == true)
{

View file

@ -19,7 +19,10 @@ namespace BSB.Commands.Dialogs
{
return bot.DialogReply(dialogid, args[1]);
}
else return Failed("Invaild dialog id");
else
{
return Failed("Invaild dialog id");
}
}
return false;
}

View file

@ -48,7 +48,10 @@ namespace BSB.Commands.Movement
float.TryParse(tp_args[offset + 1], out posY);
float.TryParse(tp_args[offset + 2], out posZ);
}
else if (tp_args.Length == 2) ok = false;
else if (tp_args.Length == 2)
{
ok = false;
}
if (ok == true)
{
bot.SetTeleported();

View file

@ -27,7 +27,10 @@ namespace BSB.Commands.Notecard
{
bot.ClearNotecardStorage(args[1]);
string notecard_name = "New notecard for " + args[0] + " " + helpers.UnixTimeNow().ToString() + "";
if (args.Length == 3) notecard_name = args[2] + " " + helpers.UnixTimeNow().ToString() + "";
if (args.Length == 3)
{
notecard_name = args[2] + " " + helpers.UnixTimeNow().ToString() + "";
}
return bot.SendNotecard(notecard_name, content, target);
}
else

View file

@ -68,7 +68,10 @@ namespace BSB.Commands.CMD_Parcel
reply.Append(cfg);
reply.Append("=");
reply.Append(p.Flags.HasFlag(flags[cfg]).ToString());
if (addon != ",") addon = ",";
if (addon != ",")
{
addon = ",";
}
}
}
return bot.GetCommandsInterface.SmartCommandReply(target, reply.ToString(), CommandName);

View file

@ -53,8 +53,14 @@ namespace BSB.RLV.Blacklist
}
}
}
if (sendim == "") sendim = "#";
if (recvim == "") recvim = "#";
if (sendim == "")
{
sendim = "#";
}
if (recvim == "")
{
recvim = "#";
}
bot.GetClient.Self.Chat("" + sendim + "," + recvim + "", channel, OpenMetaverse.ChatType.Normal);
return true;
}

View file

@ -82,6 +82,7 @@ namespace BSB.RLV
{
return Failed("Function not overridden");
}
public bool Failed(string why_failed)
{
ConsoleLog.Warn("[RLVapi/Failed] " + CommandName + ": " + why_failed);
@ -115,7 +116,10 @@ namespace BSB.RLV
{
if (args.Length > 0)
{
if (args[0] == "force") return true;
if (args[0] == "force")
{
return true;
}
return Failed("Magic word force is missing");
}
return Failed("[RLV/WARN] RLV_1arg_force invaild number of args");

View file

@ -11,6 +11,10 @@ namespace BSB.bottypes
{
public abstract class CommandsBot : AVstorageBot
{
protected CommandsBot()
{
CommandsInterface = new Commands.CoreCommandsInterface(this);
}
List<string> CommandHistory = new List<string>();
protected int commandid = 1;
public virtual string CommandHistoryAdd(string command, string arg, bool status,string infomessage)
@ -51,7 +55,12 @@ namespace BSB.bottypes
}
return message;
}
public string[] GetLastCommands(int amount=10)
public string[] GetLastCommands()
{
return GetLastCommands(10);
}
public string[] GetLastCommands(int amount)
{
List<string> commands = new List<string>();
int loop = 0;
@ -69,10 +78,7 @@ namespace BSB.bottypes
public Commands.CoreCommandsInterface GetCommandsInterface { get { return CommandsInterface; } }
protected Commands.CoreCommandsInterface CommandsInterface;
public CommandsBot()
{
CommandsInterface = new Commands.CoreCommandsInterface(this);
}
protected Dictionary<string, string> notecards_content = new Dictionary<string, string>();
protected Dictionary<UUID, long> group_invite_lockout_timer = new Dictionary<UUID, long>();
protected long last_cleanup_commands;

View file

@ -67,8 +67,7 @@ namespace BSB.bottypes
protected List<string> accept_animation_request_from_users = new List<string>();
protected bool login_auto_logout = false;
protected long delay_group_fetch = 0;
Dictionary<UUID, KeyValuePair<long, List<UUID>>> group_members_storage = new Dictionary<UUID, KeyValuePair<long, List<UUID>>>();
protected Dictionary<UUID, KeyValuePair<long, List<UUID>>> group_members_storage = new Dictionary<UUID, KeyValuePair<long, List<UUID>>>();
protected virtual void GroupMembersReplyHandler(object sender, GroupMembersReplyEventArgs e)
{
}
@ -136,7 +135,7 @@ namespace BSB.bottypes
protected override void BotStartHandler()
{
Client.Network.LoginProgress += new EventHandler<LoginProgressEventArgs>(LoginHandler);
Client.Network.LoginProgress += LoginHandler;
}
public override string GetStatus()

View file

@ -191,19 +191,23 @@ namespace BSB.bottypes
}
}
protected bool inbox(float expected, float current, float drift)
protected static bool inbox(float expected, float current, float drift)
{
return inbox(expected, current, drift, true);
}
protected bool inbox(float expected,float current, float drift, bool current_value)
protected static bool inbox(float expected,float current, float drift, bool current_value)
{
if (current > (expected + drift)) return false;
else if (current < (expected - drift)) return false;
else return current_value;
if (current > (expected + drift))
{
return false;
}
else if (current < (expected - drift))
{
return false;
}
return current_value;
}
public bool IsSimHome(string simname)
{
simname = simname.ToLowerInvariant();