Cleanup and removing old systems
goodbye Discord webhook relay (You will return as part of the custom_relay system later) goodbye DiscordTTS system (used for a bit) goodbye RelayIMToAvatar (The custom relay system is better)
This commit is contained in:
parent
fd1ca6626f
commit
91c0c2fa1d
11 changed files with 44 additions and 221 deletions
|
|
@ -18,7 +18,7 @@ namespace BetterSecondBot
|
|||
LogFormater.Status("-> Getting config from Docker");
|
||||
JsonConfig Config = MakeJsonConfig.FromENV();
|
||||
Config = MakeJsonConfig.Http_config_check(Config);
|
||||
new DiscordTTS(Config,true);
|
||||
new Discord_super(Config,true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ namespace BetterSecondBot
|
|||
if(ok_to_try_start == true)
|
||||
{
|
||||
Config = MakeJsonConfig.Http_config_check(Config);
|
||||
new DiscordTTS(Config, false);
|
||||
new Discord_super(Config, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ namespace BetterSecondBot.DiscordSupervisor
|
|||
string display_topic = "" + channeltopictype + ":" + sender_id + "";
|
||||
if (channelname == "interface")
|
||||
{
|
||||
display_topic = "Actions -> !clear, !commands, !help command or command";
|
||||
display_topic = "Actions -> !clear, !commands";
|
||||
}
|
||||
else if (channelname == "status")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,77 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenMetaverse;
|
||||
using Discord;
|
||||
using BetterSecondBotShared.Static;
|
||||
using Discord.WebSocket;
|
||||
using System.Threading.Tasks;
|
||||
using System.Linq;
|
||||
using BetterSecondBotShared.Json;
|
||||
|
||||
namespace BetterSecondBot.DiscordSupervisor
|
||||
{
|
||||
public class DiscordTTS : Discord_super
|
||||
{
|
||||
public DiscordTTS(JsonConfig configfile, bool as_docker) : base(configfile, as_docker)
|
||||
{
|
||||
|
||||
}
|
||||
protected ITextChannel TTSchannel;
|
||||
protected IGuild TTSDiscordServer;
|
||||
protected override async Task<Task> DiscordClientReady()
|
||||
{
|
||||
await base.DiscordClientReady();
|
||||
if (myconfig.DiscordTTS_Enable == true)
|
||||
{
|
||||
TTSDiscordServer = DiscordClient.GetGuild(myconfig.DiscordTTS_server_id);
|
||||
if (TTSDiscordServer != null)
|
||||
{
|
||||
IGuildUser user = await TTSDiscordServer.GetCurrentUserAsync();
|
||||
await user.ModifyAsync(x =>
|
||||
{
|
||||
x.Nickname = myconfig.DiscordTTS_Nickname;
|
||||
});
|
||||
FindTTsChannel();
|
||||
}
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
protected async void FindTTsChannel()
|
||||
{
|
||||
if (myconfig.DiscordTTS_Enable == true)
|
||||
{
|
||||
TTSchannel = await FindTextChannel(TTSDiscordServer, myconfig.DiscordTTS_channel_name);
|
||||
}
|
||||
}
|
||||
|
||||
protected override async Task DiscordIMMessage(UUID sender_uuid, string sender_name, string message)
|
||||
{
|
||||
if (myconfig.DiscordTTS_Enable == true)
|
||||
{
|
||||
if ((helpers.notempty(sender_name) == true) && (helpers.notempty(message) == true))
|
||||
{
|
||||
if (sender_uuid.ToString() == myconfig.DiscordTTS_avatar_uuid)
|
||||
{
|
||||
if (TTSchannel == null)
|
||||
{
|
||||
FindTTsChannel();
|
||||
}
|
||||
if (TTSchannel != null)
|
||||
{
|
||||
await TTSchannel.SendMessageAsync(message, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
await base.DiscordIMMessage(sender_uuid, sender_name, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
await base.DiscordIMMessage(sender_uuid, sender_name, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -92,14 +92,12 @@ namespace BetterSecondBot.DiscordSupervisor
|
|||
{
|
||||
if (message.Content == "!commands")
|
||||
{
|
||||
await SendMessageToChannelAsync("interface", "broken", "bot", UUID.Zero, "bot");
|
||||
}
|
||||
else if (message.Content.StartsWith("!help") == true)
|
||||
{
|
||||
await SendMessageToChannelAsync("interface", "broken", "bot", UUID.Zero, "bot");
|
||||
string[] commands = controler.Bot.getFullListOfCommands();
|
||||
await SendMessageToChannelAsync("interface", string.Join("\n",commands)+ " \n For more details please see the wiki \n https://wiki.magicmadpeter.xyz/", "bot", UUID.Zero, "bot");
|
||||
}
|
||||
else
|
||||
{
|
||||
await MarkMessage(message, "❌").ConfigureAwait(false);
|
||||
output.Append("Unknown request: ");
|
||||
output.Append(message.Content);
|
||||
await SendMessageToChannelAsync("interface", output.ToString(), "bot", UUID.Zero, "bot");
|
||||
|
|
@ -107,6 +105,24 @@ namespace BetterSecondBot.DiscordSupervisor
|
|||
}
|
||||
else
|
||||
{
|
||||
string[] bits = message.Content.Split("|||");
|
||||
if(bits.Length >= 2)
|
||||
{
|
||||
string target = "None";
|
||||
if (bits.Length == 3)
|
||||
{
|
||||
target = bits[2];
|
||||
}
|
||||
if (controler.Bot.getFullListOfCommands().Contains(bits[0].ToLowerInvariant()) == true)
|
||||
{
|
||||
controler.Bot.CallAPI(bits[0], bits[1].Split("~#~"), target);
|
||||
await MarkMessage(message, "✅").ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
await MarkMessage(message, "❌").ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
await MarkMessage(message, "❌").ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
|
@ -128,7 +144,7 @@ namespace BetterSecondBot.DiscordSupervisor
|
|||
else
|
||||
{
|
||||
await MarkMessage(message, "⏳").ConfigureAwait(true);
|
||||
Thread.Sleep(200);
|
||||
Thread.Sleep(400);
|
||||
string[] bits = Chan.Topic.Split(':');
|
||||
if (bits.Length >= 2)
|
||||
{
|
||||
|
|
@ -180,16 +196,14 @@ namespace BetterSecondBot.DiscordSupervisor
|
|||
}
|
||||
Noticetitle = Noticetitle.Replace("!notice ", "");
|
||||
Noticetitle = Noticetitle.Trim();
|
||||
//controler.Bot.GetCommandsInterface.Call("GroupNotice", "" + group.ToString() + "~#~" + Noticetitle + "~#~" + Noticemessage, UUID.Zero);
|
||||
//await MarkMessage(message, "✅");
|
||||
await MarkMessage((IUserMessage)message, "❌").ConfigureAwait(false);
|
||||
controler.Bot.CallAPI("Groupnotice", new string[] { Noticetitle, Noticemessage });
|
||||
await MarkMessage(message, "✅");
|
||||
}
|
||||
else
|
||||
{
|
||||
IGuildUser user = (IGuildUser)message.Author;
|
||||
//controler.Bot.GetCommandsInterface.Call("Groupchat", "" + group.ToString() + "~#~" + message.Content, UUID.Zero);
|
||||
//await MarkMessage(message, "✅");
|
||||
await MarkMessage((IUserMessage)message, "❌").ConfigureAwait(false);
|
||||
controler.Bot.CallAPI("Groupchat", new string[] { group.ToString(), message.Content });
|
||||
await MarkMessage(message, "✅");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,32 +60,6 @@ namespace BetterSecondBot.DiscordSupervisor
|
|||
{
|
||||
if (fromme == false)
|
||||
{
|
||||
if (discord_group_relay == true)
|
||||
{
|
||||
// GroupChat Relay only
|
||||
if (group == true)
|
||||
{
|
||||
if (myconfig.DiscordRelay_URL != "")
|
||||
{
|
||||
if ((myconfig.DiscordRelay_GroupUUID == group_uuid.ToString()) || (myconfig.DiscordRelay_GroupUUID == "*") || (myconfig.DiscordRelay_GroupUUID == "all"))
|
||||
{
|
||||
Group Gr = controler.Bot.MyGroups[group_uuid];
|
||||
try
|
||||
{
|
||||
using var DWHclient = new DiscordWebhookClient(myconfig.DiscordRelay_URL);
|
||||
string SendMessage = "(" + Gr.Name + ") @" + sender_name + ":" + message + "";
|
||||
await DWHclient.SendMessageAsync(text: SendMessage).ConfigureAwait(false);
|
||||
DWHclient.Dispose();
|
||||
}
|
||||
catch
|
||||
{
|
||||
controler.Bot.Info("Discord web hook has failed - marking as disabled untill next restart!");
|
||||
myconfig.DiscordRelay_URL = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (DiscordClientConnected == true)
|
||||
{
|
||||
if (avatar == true)
|
||||
|
|
|
|||
|
|
@ -37,12 +37,9 @@ ENV Security_WebUIKey=''
|
|||
ENV Setting_AllowRLV='false'
|
||||
ENV Setting_AllowFunds='false'
|
||||
ENV Setting_LogCommands='false'
|
||||
ENV Setting_RelayImToAvatarUUID=''
|
||||
ENV Setting_DefaultSit_UUID=''
|
||||
ENV Setting_loginURI='secondlife'
|
||||
|
||||
ENV DiscordRelay_URL=''
|
||||
ENV DiscordRelay_GroupUUID=''
|
||||
ENV DiscordFull_Enable='false'
|
||||
ENV DiscordFull_Token=''
|
||||
ENV DiscordFull_ServerID=''
|
||||
|
|
@ -55,12 +52,6 @@ ENV Name2Key_Enable='false'
|
|||
ENV Name2Key_Url='http://localhost:1234'
|
||||
ENV Name2Key_Key='magic'
|
||||
|
||||
ENV DiscordTTS_Enable='false'
|
||||
ENV DiscordTTS_server_id=''
|
||||
ENV DiscordTTS_channel_name=''
|
||||
ENV DiscordTTS_avatar_uuid=''
|
||||
ENV DiscordTTS_Nickname=''
|
||||
|
||||
ENV Log2File_Enable='false'
|
||||
ENV Log2File_Level=1
|
||||
|
||||
|
|
|
|||
|
|
@ -84,7 +84,6 @@ namespace BetterSecondBot.bottypes
|
|||
Client.Self.InstantMessage(avatar, message);
|
||||
}
|
||||
|
||||
protected Dictionary<string, string> Scripts_content = new Dictionary<string, string>();
|
||||
protected Dictionary<string, string> notecards_content = new Dictionary<string, string>();
|
||||
protected Dictionary<UUID, Dictionary<UUID, long>> group_invite_lockout_timer = new Dictionary<UUID, Dictionary<UUID, long>>();
|
||||
protected long last_cleanup_commands;
|
||||
|
|
@ -140,6 +139,16 @@ namespace BetterSecondBot.bottypes
|
|||
base.AfterBotLoginHandler();
|
||||
}
|
||||
|
||||
public string[] getFullListOfCommands()
|
||||
{
|
||||
List<string> output = new List<string>();
|
||||
foreach(string A in endpointcommandmap.Keys)
|
||||
{
|
||||
output.Add(A.ToLowerInvariant());
|
||||
}
|
||||
return output.ToArray();
|
||||
}
|
||||
|
||||
public void NotecardAddContent(string target_notecard_storage_id, string content)
|
||||
{
|
||||
NotecardAddContent(target_notecard_storage_id, content, true, "\n\r");
|
||||
|
|
|
|||
|
|
@ -75,32 +75,7 @@ namespace BetterSecondBot.bottypes
|
|||
{
|
||||
BotChatControler(message, sender_name, sender_uuid, avatar, group, group_uuid, localchat, false);
|
||||
}
|
||||
protected 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);
|
||||
if (fromme == false)
|
||||
{
|
||||
if (localchat == false)
|
||||
{
|
||||
if(avatar == true)
|
||||
{
|
||||
if (myconfig.Setting_RelayImToAvatarUUID != null)
|
||||
{
|
||||
if (myconfig.Setting_RelayImToAvatarUUID != UUID.Zero.ToString())
|
||||
{
|
||||
if (myconfig.Setting_RelayImToAvatarUUID.Length == UUID.Zero.ToString().Length)
|
||||
{
|
||||
if (UUID.TryParse(myconfig.Setting_RelayImToAvatarUUID, out UUID targetav) == true)
|
||||
{
|
||||
Client.Self.InstantMessage(targetav, "Relay-> " + sender_name + ": " + message + "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void MessageHandler(object sender, InstantMessageEventArgs e)
|
||||
{
|
||||
bool fromme = false;
|
||||
|
|
|
|||
|
|
@ -40,14 +40,9 @@ namespace BetterSecondBotShared.Json
|
|||
// Settings
|
||||
public bool Setting_AllowRLV { get; set; }
|
||||
public bool Setting_AllowFunds { get; set; }
|
||||
public string Setting_RelayImToAvatarUUID { get; set; }
|
||||
public string Setting_DefaultSit_UUID { get; set; }
|
||||
public string Setting_loginURI { get; set; }
|
||||
|
||||
// Discord Relay
|
||||
public string DiscordRelay_URL { get; set; }
|
||||
public string DiscordRelay_GroupUUID { get; set; }
|
||||
|
||||
// Discord FullFat
|
||||
public bool DiscordFull_Enable { get; set; }
|
||||
public string DiscordFull_Token { get; set; }
|
||||
|
|
@ -64,14 +59,6 @@ namespace BetterSecondBotShared.Json
|
|||
public string Name2Key_Url { get; set; }
|
||||
public string Name2Key_Key { get; set; }
|
||||
|
||||
|
||||
// TTS
|
||||
public bool DiscordTTS_Enable { get; set; }
|
||||
public ulong DiscordTTS_server_id { get; set; }
|
||||
public string DiscordTTS_channel_name { get; set; }
|
||||
public string DiscordTTS_avatar_uuid { get; set; }
|
||||
public string DiscordTTS_Nickname { get; set; }
|
||||
|
||||
// Logs
|
||||
public bool Log2File_Enable { get; set; }
|
||||
public int Log2File_Level { get; set; }
|
||||
|
|
|
|||
|
|
@ -72,10 +72,6 @@ namespace BetterSecondBotShared.Json
|
|||
{
|
||||
return "Allow the bot to transfer L$ and get a non zero balance";
|
||||
}
|
||||
else if (cmd == "Setting_RelayImToAvatarUUID")
|
||||
{
|
||||
return "UUID of who the bot should relay IMs to in secondlife";
|
||||
}
|
||||
else if (cmd == "Setting_DefaultSit_UUID")
|
||||
{
|
||||
return "UUID of a object the bot should attempt to sit on after logging in";
|
||||
|
|
@ -93,15 +89,7 @@ namespace BetterSecondBotShared.Json
|
|||
protected string GetHelp_Discord(string cmd)
|
||||
{
|
||||
// Discord
|
||||
if (cmd == "DiscordRelay_URL")
|
||||
{
|
||||
return "The webhook URL to send group chat to";
|
||||
}
|
||||
else if (cmd == "DiscordRelay_GroupUUID")
|
||||
{
|
||||
return "The group UUID to relay group chat for";
|
||||
}
|
||||
else if (cmd == "DiscordFull_Enable")
|
||||
if (cmd == "DiscordFull_Enable")
|
||||
{
|
||||
return "Allow the bot to fully connect to discord (Disables relay)";
|
||||
}
|
||||
|
|
@ -132,31 +120,7 @@ namespace BetterSecondBotShared.Json
|
|||
}
|
||||
return "";
|
||||
}
|
||||
protected string GetHelp_DiscordTTS(string cmd)
|
||||
{
|
||||
// Discord TTS
|
||||
if (cmd == "DiscordTTS_Enable")
|
||||
{
|
||||
return "Enable discord TTS helper (Requires DiscordFull_Enable set to true) ";
|
||||
}
|
||||
else if (cmd == "DiscordTTS_server_id")
|
||||
{
|
||||
return "The server ID to use for TTS";
|
||||
}
|
||||
else if (cmd == "DiscordTTS_channel_name")
|
||||
{
|
||||
return "The channel name to use (found on the server set by DiscordTTS_server_id)";
|
||||
}
|
||||
else if (cmd == "DiscordTTS_avatar_uuid")
|
||||
{
|
||||
return "The avatar UUID whos IMs will be turned into TTS";
|
||||
}
|
||||
else if (cmd == "DiscordTTS_Nickname")
|
||||
{
|
||||
return "The nickname to use on the TTS server";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
protected string GetHelp_Logs(string cmd)
|
||||
{
|
||||
// Logs
|
||||
|
|
@ -186,7 +150,6 @@ namespace BetterSecondBotShared.Json
|
|||
if (cmd.StartsWith("Basic") == true) { return GetHelp_Basic(cmd); }
|
||||
else if (cmd.StartsWith("Security") == true) { return GetHelp_Security(cmd); }
|
||||
else if (cmd.StartsWith("Settings") == true) { return GetHelp_Settings(cmd); }
|
||||
else if (cmd.StartsWith("DiscordTTS") == true) { return GetHelp_DiscordTTS(cmd); }
|
||||
else if (cmd.StartsWith("Discord") == true) { return GetHelp_Discord(cmd); }
|
||||
else if (cmd.StartsWith("Http_") == true) { return GetHelp_HTTP(cmd); }
|
||||
else { return GetHelp_Logs(cmd); }
|
||||
|
|
@ -243,7 +206,6 @@ namespace BetterSecondBotShared.Json
|
|||
// Settings
|
||||
if (cmd == "Setting_AllowRLV") { return "False"; }
|
||||
else if (cmd == "Setting_AllowFunds") { return "True"; }
|
||||
else if (cmd == "Setting_RelayImToAvatarUUID") { return ""; }
|
||||
else if (cmd == "Setting_DefaultSit_UUID") { return ""; }
|
||||
else if (cmd == "Setting_loginURI") { return "secondlife"; }
|
||||
else if (cmd == "Setting_LogCommands") { return "True"; }
|
||||
|
|
@ -252,9 +214,7 @@ namespace BetterSecondBotShared.Json
|
|||
protected string GetValueHint_Discord(string cmd)
|
||||
{
|
||||
// Discord
|
||||
if (cmd == "DiscordRelay_URL") { return ""; }
|
||||
else if (cmd == "DiscordRelay_GroupUUID") { return ""; }
|
||||
else if (cmd == "DiscordFull_Enable") { return "False"; }
|
||||
if (cmd == "DiscordFull_Enable") { return "False"; }
|
||||
else if (cmd == "DiscordFull_Token") { return ""; }
|
||||
else if (cmd == "DiscordFull_ServerID") { return ""; }
|
||||
else if (cmd == "DiscordFull_Keep_GroupChat") { return "False"; }
|
||||
|
|
@ -267,16 +227,7 @@ namespace BetterSecondBotShared.Json
|
|||
else if (cmd == "Http_Host") { return "http://*:8080"; }
|
||||
return "";
|
||||
}
|
||||
protected string GetValueHint_DiscordTTS(string cmd)
|
||||
{
|
||||
// Discord TTS
|
||||
if (cmd == "DiscordTTS_Enable") { return "False"; }
|
||||
else if (cmd == "DiscordTTS_server_id") { return ""; }
|
||||
else if (cmd == "DiscordTTS_channel_name") { return ""; }
|
||||
else if (cmd == "DiscordTTS_avatar_uuid") { return ""; }
|
||||
else if (cmd == "DiscordTTS_Nickname") { return ""; }
|
||||
return "";
|
||||
}
|
||||
|
||||
protected string GetValueHint_Logs(string cmd)
|
||||
{
|
||||
// Logs
|
||||
|
|
@ -294,7 +245,6 @@ namespace BetterSecondBotShared.Json
|
|||
if (cmd.StartsWith("Basic") == true) { return GetValueHint_Basic(cmd); }
|
||||
else if (cmd.StartsWith("Security") == true) { return GetValueHint_Security(cmd); }
|
||||
else if (cmd.StartsWith("Setting_") == true) { return GetValueHint_Settings(cmd); }
|
||||
else if (cmd.StartsWith("DiscordTTS_") == true) { return GetValueHint_DiscordTTS(cmd); }
|
||||
else if (cmd.StartsWith("Discord") == true) { return GetValueHint_Discord(cmd); }
|
||||
else if (cmd.StartsWith("Http_") == true) { return GetValueHint_HTTP(cmd); }
|
||||
else { return GetValueHint_Logs(cmd); }
|
||||
|
|
|
|||
Loading…
Reference in a new issue