new command plus fixs to athome and http
This commit is contained in:
parent
448a9ff05c
commit
f0429f824a
3 changed files with 89 additions and 9 deletions
|
|
@ -22,6 +22,7 @@ namespace BetterSecondBot.HttpService
|
||||||
protected JsonConfig Config;
|
protected JsonConfig Config;
|
||||||
protected SecondBot Bot;
|
protected SecondBot Bot;
|
||||||
protected TokenStorage Tokens;
|
protected TokenStorage Tokens;
|
||||||
|
protected bool killedLogger = false;
|
||||||
|
|
||||||
protected void loadScopedTokensFromENV()
|
protected void loadScopedTokensFromENV()
|
||||||
{
|
{
|
||||||
|
|
@ -139,17 +140,28 @@ namespace BetterSecondBot.HttpService
|
||||||
}
|
}
|
||||||
|
|
||||||
// Our web server is disposable
|
// Our web server is disposable
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (killedLogger == false)
|
||||||
|
{
|
||||||
|
killedLogger = true;
|
||||||
Logger.UnregisterLogger<ConsoleLogger>();
|
Logger.UnregisterLogger<ConsoleLogger>();
|
||||||
|
}
|
||||||
using (var server = CreateWebServer(Config.Http_Host))
|
using (var server = CreateWebServer(Config.Http_Host))
|
||||||
{
|
{
|
||||||
// Once we've registered our modules and configured them, we call the RunAsync() method.
|
// Once we've registered our modules and configured them, we call the RunAsync() method.
|
||||||
server.RunAsync();
|
server.RunAsync();
|
||||||
while(Bot.KillMe == false)
|
while (Bot.KillMe == false)
|
||||||
{
|
{
|
||||||
Thread.Sleep(3000);
|
Thread.Sleep(3000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private WebServer CreateWebServer(string url)
|
private WebServer CreateWebServer(string url)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
45
Core/Commands/Group/GroupEject.cs
Normal file
45
Core/Commands/Group/GroupEject.cs
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using OpenMetaverse;
|
||||||
|
using BetterSecondBotShared.logs;
|
||||||
|
|
||||||
|
namespace BSB.Commands.Group
|
||||||
|
{
|
||||||
|
public class GroupEject : CoreCommand_2arg
|
||||||
|
{
|
||||||
|
public override string[] ArgTypes { get { return new[] { "UUID", "Avatar" }; } }
|
||||||
|
public override string[] ArgHints { get { return new[] { "GROUP", "Avatar [UUID or Firstname Lastname]"}; } }
|
||||||
|
public override string Helpfile { get { return "Eject selected avatar from group"; } }
|
||||||
|
|
||||||
|
public override bool CallFunction(string[] args)
|
||||||
|
{
|
||||||
|
if (base.CallFunction(args) == true)
|
||||||
|
{
|
||||||
|
if (UUID.TryParse(args[0], out UUID target_group) == true)
|
||||||
|
{
|
||||||
|
if (UUID.TryParse(args[1], out UUID target_avatar) == true)
|
||||||
|
{
|
||||||
|
if (bot.MyGroups.ContainsKey(target_group) == true)
|
||||||
|
{
|
||||||
|
bot.GetClient.Groups.EjectUser(target_group, target_avatar);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Failed("I am not a member of that group");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Failed("Invaild avatar UUID");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Failed("Invaild group UUID");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -162,7 +162,7 @@ namespace BSB.bottypes
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
long dif = last_tp_attempt_unixtime - helpers.UnixTimeNow();
|
long dif = helpers.UnixTimeNow() - last_tp_attempt_unixtime;
|
||||||
if (dif > 0)
|
if (dif > 0)
|
||||||
{
|
{
|
||||||
addon = "Waiting for TP cooldown";
|
addon = "Waiting for TP cooldown";
|
||||||
|
|
@ -182,6 +182,7 @@ namespace BSB.bottypes
|
||||||
|
|
||||||
|
|
||||||
protected long login_failed_retry_at = 0;
|
protected long login_failed_retry_at = 0;
|
||||||
|
protected long connection_lost_at = 0;
|
||||||
public string AtHomeReconnect()
|
public string AtHomeReconnect()
|
||||||
{
|
{
|
||||||
if (attempted_first_login == true)
|
if (attempted_first_login == true)
|
||||||
|
|
@ -199,11 +200,12 @@ namespace BSB.bottypes
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
long dif = login_failed_retry_at - helpers.UnixTimeNow();
|
long dif = helpers.UnixTimeNow() - login_failed_retry_at;
|
||||||
if(dif > 0)
|
if(dif > 0)
|
||||||
{
|
{
|
||||||
login_failed_retry_at = 0;
|
login_failed_retry_at = 0;
|
||||||
attempted_first_login = false;
|
attempted_first_login = false;
|
||||||
|
login_failed = false;
|
||||||
Start(true);
|
Start(true);
|
||||||
return "Attempting reconnect";
|
return "Attempting reconnect";
|
||||||
}
|
}
|
||||||
|
|
@ -216,7 +218,27 @@ namespace BSB.bottypes
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return "Waiting";
|
if(connection_lost_at == 0)
|
||||||
|
{
|
||||||
|
connection_lost_at = helpers.UnixTimeNow() + 30;
|
||||||
|
return "Connection lost reconnect in 30 secs";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
long dif = helpers.UnixTimeNow() - connection_lost_at;
|
||||||
|
if(dif > 0)
|
||||||
|
{
|
||||||
|
login_failed_retry_at = 0;
|
||||||
|
attempted_first_login = false;
|
||||||
|
login_failed = false;
|
||||||
|
Start(true);
|
||||||
|
return "Attempting reconnect";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "Connection lost reconnect in "+ dif.ToString()+" secs";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -299,6 +321,7 @@ namespace BSB.bottypes
|
||||||
string reply = "Disconnected: No action";
|
string reply = "Disconnected: No action";
|
||||||
if (Client.Network.Connected == true)
|
if (Client.Network.Connected == true)
|
||||||
{
|
{
|
||||||
|
connection_lost_at = 0;
|
||||||
if (Client.Network.CurrentSim != null)
|
if (Client.Network.CurrentSim != null)
|
||||||
{
|
{
|
||||||
if(after_login_fired == false)
|
if(after_login_fired == false)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue