This commit is contained in:
Madpeter 2020-04-29 16:48:18 +01:00
parent 78014adaaf
commit 6dd56a2295
20 changed files with 73 additions and 38 deletions

View file

@ -124,7 +124,7 @@ namespace BetterSecondBotShared.Json
return 1;
}
public string GetProp(JsonConfig reply, string arg)
public static string GetProp(JsonConfig reply, string arg)
{
return reply.GetType().GetProperty(arg, BindingFlags.Public | BindingFlags.Instance).GetValue(reply).ToString();
}

View file

@ -71,7 +71,7 @@ namespace BetterSecondBotShared.Static
bool default_value_found = false;
foreach (string a in testingfor)
{
if (Testing.GetCommandArgTypes(a).First() == Testing.GetProp(test, a))
if (Testing.GetCommandArgTypes(a).First() == MakeJsonConfig.GetProp(test, a))
{
ConsoleLog.Warn("" + a + " is currently set to the default");
default_value_found = true;

View file

@ -6,7 +6,7 @@ using BetterSecondBotShared.Static;
using BetterSecondBotShared.logs;
namespace BetterSecondBot
{
class Program
static class Program
{
static void Main(string[] args)
{

View file

@ -70,7 +70,10 @@ namespace BetterSecondBot
io.WriteJsonConfig(MakeJsonConfig.GetDefault(), json_file);
}
}
else ConsoleLog.Crit("you must select a .json file for config! example \"BetterSecondBot.exe mybot\" will use the mybot.json file!");
else
{
ConsoleLog.Crit("you must select a .json file for config! example \"BetterSecondBot.exe mybot\" will use the mybot.json file!");
}
if(ok_to_try_start == true)
{
Config = MakeJsonConfig.http_config_check(Config);

View file

@ -15,12 +15,12 @@ namespace BetterSecondBot.HttpServer.Control.Actions
if (httpserver.HTTPCnCmode == true)
{
httpserver.KillBot();
return new string[] { "OK", "Bot Shutting down" };
return new [] { "OK", "Bot Shutting down" };
}
else
{
bot.KillMePlease();
return new string[] { "OK", "I dont want to go" };
return new [] { "OK", "I dont want to go" };
}
}
else

View file

@ -20,7 +20,7 @@ namespace BetterSecondBot.HttpServer.Control.Interface
{
if (bot.GetCommandsInterface.Call(args[0], args[1], UUID.Zero) == true)
{
return new string[] { "OK" };
return new [] { "OK" };
}
else
{

View file

@ -91,7 +91,7 @@ namespace BetterSecondBot.HttpServer
protected string[] Failed(string why_failed)
{
ConsoleLog.Warn("HTTP: " + CommandName + " [Failed]: " + why_failed);
return new string[] {"Failed",why_failed};
return new [] {"Failed",why_failed};
}
}

View file

@ -183,7 +183,7 @@ namespace BetterSecondBot.HttpServer
{
get_controler = new HTTPCommandsInterfaceGet(Bot,this);
post_controler = new HTTPCommandsInterfacePost(Bot,this);
Thread t = new Thread(delegate (object unused)
Thread t = new Thread(delegate (object _)
{
listener = new HttpListener();
listener.Prefixes.Add(url);

View file

@ -29,7 +29,10 @@ namespace BSB.Commands.Dialogs
{
bot.SetRelayDialogsChannel(channel);
}
else return Failed("Not a vaild option");
else
{
return Failed("Not a vaild option");
}
return true;
}
else

View file

@ -21,8 +21,14 @@ namespace BSB.Commands.Group
UUID.TryParse(args[2], out target_role);
}
List<UUID> invite_roles = new List<UUID>();
if (target_role != UUID.Zero) invite_roles.Add(target_role);
else invite_roles.Add(UUID.Zero);
if (target_role != UUID.Zero)
{
invite_roles.Add(target_role);
}
else
{
invite_roles.Add(UUID.Zero);
}
bot.GetClient.Groups.Invite(group, invite_roles, avatar);
}
public override void Callback(string[] args, EventArgs e)

View file

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

View file

@ -20,7 +20,10 @@ namespace BSB.Commands.CMD_Parcel
bool banuser = false;
if (args.Length == 2)
{
if (args[1] == "True") banuser = true;
if (args[1] == "True")
{
banuser = true;
}
}
bot.GetClient.Parcels.EjectUser(target, banuser);
return true;

View file

@ -47,7 +47,10 @@ namespace BSB.Commands.StreamAdmin
{
return bot.SendNotecard(server_reply.NotecardTitle, server_reply.NotecardContent, (UUID)server_reply.AvatarUUID);
}
else Failed("Notecard title is to short");
else
{
Failed("Notecard title is to short");
}
}
return Failed(server_reply.message);
}

View file

@ -173,7 +173,10 @@ namespace BSB.Commands
{ "unixtime", helpers.UnixTimeNow().ToString() }
};
if (command != "") values.Add("command", command);
if (command != "")
{
values.Add("command", command);
}
var content = new FormUrlEncodedContent(values);
try
{
@ -216,7 +219,7 @@ namespace BSB.Commands
string[] args = new string[] { };
if (helpers.notempty(arg) == true)
{
args = arg.Split(new string[] { "~#~" }, StringSplitOptions.None);
args = arg.Split(new [] { "~#~" }, StringSplitOptions.None);
}
if ((cmd.ArgTypes.Contains("Avatar") == true) || (cmd.ArgTypes.Contains("Smart") == true))
{

View file

@ -38,7 +38,10 @@ namespace BSB.bottypes
}
if (AvatarStorageLastUsed.Count > 0)
{
if (reply != "") reply += " , ";
if (reply != "")
{
reply += " , ";
}
reply += AvatarStorageLastUsed.Count.ToString() + " loaded";
}
if (reply != "")

View file

@ -15,7 +15,7 @@ namespace BSB.bottypes
{
CommandsInterface = new Commands.CoreCommandsInterface(this);
}
List<string> CommandHistory = new List<string>();
protected List<string> CommandHistory = new List<string>();
protected int commandid = 1;
public virtual string CommandHistoryAdd(string command, string arg, bool status,string infomessage)
{
@ -51,7 +51,10 @@ namespace BSB.bottypes
ConsoleLog.Info(sb.ToString());
}
commandid++;
if (commandid >= myconfig.MaxCommandHistory) commandid = 1;
if (commandid >= myconfig.MaxCommandHistory)
{
commandid = 1;
}
}
return message;
}

View file

@ -151,7 +151,7 @@ namespace BSB.bottypes
protected async Task<ITextChannel> FindTextChannel(string channelname, ICategoryChannel cat, UUID sender, string sendername, string TopicType)
{
await WaitForUnlock();
await WaitForUnlock().ConfigureAwait(false);
channelname = channelname.ToLowerInvariant();
channelname = String.Concat(channelname.Where(char.IsLetterOrDigit));
DiscordLock = true;
@ -170,7 +170,7 @@ namespace BSB.bottypes
}
if(result == null)
{
result = await CreateChannel(channelname, TopicType, sender.ToString());
result = await CreateChannel(channelname, TopicType, sender.ToString()).ConfigureAwait(false);
}
else
{
@ -552,7 +552,7 @@ namespace BSB.bottypes
protected async override void BotChatControler(string message, string sender_name, UUID sender_uuid, bool avatar, bool group, UUID group_uuid, bool localchat, bool fromme)
{
base.BotChatControler(message, sender_name, sender_uuid, avatar, group, group_uuid, localchat, fromme);
await DiscordBotChatControler(message, sender_name, sender_uuid, avatar, group, group_uuid, localchat, fromme);
await DiscordBotChatControler(message, sender_name, sender_uuid, avatar, group, group_uuid, localchat, fromme).ConfigureAwait(false);
}
public override string CommandHistoryAdd(string command, string arg, bool status,string WhyFailed)

View file

@ -311,15 +311,9 @@ namespace BSB.bottypes
await_event_idtolistener.Add(eventid, event_listener);
return true;
}
else return false;
}
return false;
}
else return false;
return false;
}
}
}

View file

@ -99,7 +99,12 @@ namespace BSB.bottypes
protected bool permissive_mode = true;
protected UUID permissive_mode_set_by = UUID.Zero;
public UUID Getpermissive_mode_set_by { get { return permissive_mode_set_by; } }
public void SetPermissiveMode(UUID caller, bool status = false)
public void SetPermissiveMode(UUID caller)
{
SetPermissiveMode(caller, false);
}
public void SetPermissiveMode(UUID caller, bool status)
{
bool allow = true;
if((permissive_mode == false) && (caller != permissive_mode_set_by))
@ -243,7 +248,13 @@ namespace BSB.bottypes
// Notify
protected Dictionary<string, List<int>> Notify = new Dictionary<string, List<int>>();
public Dictionary<string, List<int>> Getnotify { get { return Notify; } }
public void NotifyUpdate(bool Add, string word,int channel = -1)
public void NotifyUpdate(bool Add, string word)
{
NotifyUpdate(Add, word, -1);
}
public void NotifyUpdate(bool Add, string word,int channel)
{
lock (Notify)
{

View file

@ -216,8 +216,14 @@ namespace BSB.bottypes
public bool IsSimHome(string simname)
{
simname = simname.ToLowerInvariant();
if (helpers.notempty(myconfig.homeRegion) == false) return false;
else if (myconfig.homeRegion.Length == 0) return false;
if (helpers.notempty(myconfig.homeRegion) == false)
{
return false;
}
else if (myconfig.homeRegion.Length == 0)
{
return false;
}
else
{
bool reply = false;
@ -272,7 +278,7 @@ namespace BSB.bottypes
TeleportWithSLurl(myconfig.homeRegion[last_tested_home_id]);
return " [@home **** active teleport: "+ last_attempted_teleport_region+"***]";
}
else return " [@home No home regions]";
return " [@home No home regions]";
}
else
{