mirror of
https://github.com/tribufu/ServerManagers
synced 2026-06-01 09:42:39 +00:00
Added back the plugin call home
This commit is contained in:
parent
decf281598
commit
cc95409722
8 changed files with 44 additions and 144 deletions
6
src/Plugin.Discord/Config.Designer.cs
generated
6
src/Plugin.Discord/Config.Designer.cs
generated
|
|
@ -25,7 +25,7 @@ namespace ServerManagerTool.Plugin.Discord {
|
||||||
|
|
||||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[global::System.Configuration.DefaultSettingValueAttribute("http://servermanager.azurewebsites.net/api/plugin/call/{0}/{1}/")]
|
[global::System.Configuration.DefaultSettingValueAttribute("http://servermanagers.azurewebsites.net/api/plugin/call/{0}/{1}/")]
|
||||||
public string PluginCallUrlFormat {
|
public string PluginCallUrlFormat {
|
||||||
get {
|
get {
|
||||||
return ((string)(this["PluginCallUrlFormat"]));
|
return ((string)(this["PluginCallUrlFormat"]));
|
||||||
|
|
@ -35,9 +35,9 @@ namespace ServerManagerTool.Plugin.Discord {
|
||||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[global::System.Configuration.DefaultSettingValueAttribute("12")]
|
[global::System.Configuration.DefaultSettingValueAttribute("12")]
|
||||||
public int CallHomeDelay {
|
public int PluginCallUrlDelay {
|
||||||
get {
|
get {
|
||||||
return ((int)(this["CallHomeDelay"]));
|
return ((int)(this["PluginCallUrlDelay"]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
<Profiles />
|
<Profiles />
|
||||||
<Settings>
|
<Settings>
|
||||||
<Setting Name="PluginCallUrlFormat" Type="System.String" Scope="Application">
|
<Setting Name="PluginCallUrlFormat" Type="System.String" Scope="Application">
|
||||||
<Value Profile="(Default)">http://servermanager.azurewebsites.net/api/plugin/call/{0}/{1}/</Value>
|
<Value Profile="(Default)">http://servermanagers.azurewebsites.net/api/plugin/call/{0}/{1}/</Value>
|
||||||
</Setting>
|
</Setting>
|
||||||
<Setting Name="CallHomeDelay" Type="System.Int32" Scope="Application">
|
<Setting Name="PluginCallUrlDelay" Type="System.Int32" Scope="Application">
|
||||||
<Value Profile="(Default)">12</Value>
|
<Value Profile="(Default)">12</Value>
|
||||||
</Setting>
|
</Setting>
|
||||||
<Setting Name="RequestTimeout" Type="System.Int32" Scope="Application">
|
<Setting Name="RequestTimeout" Type="System.Int32" Scope="Application">
|
||||||
|
|
|
||||||
|
|
@ -89,18 +89,10 @@ namespace ServerManagerTool.Plugin.Discord
|
||||||
{
|
{
|
||||||
var publicIP = await NetworkUtils.DiscoverPublicIPAsync();
|
var publicIP = await NetworkUtils.DiscoverPublicIPAsync();
|
||||||
await NetworkUtils.PerformCallToAPIAsync(PluginCode, publicIP);
|
await NetworkUtils.PerformCallToAPIAsync(PluginCode, publicIP);
|
||||||
#if DEBUG
|
|
||||||
var logFile = Path.Combine(PluginHelper.PluginFolder, "DiscordApiCalls.log");
|
|
||||||
File.AppendAllLines(logFile, new[] { "CallHomeAsync successful" }, Encoding.Unicode);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Debug.WriteLine($"Failed calling home {ex.Message}");
|
Debug.WriteLine($"Failed calling home to API.\r\n{ex.Message}");
|
||||||
#if DEBUG
|
|
||||||
var logFile = Path.Combine(PluginHelper.PluginFolder, "DiscordErrors.log");
|
|
||||||
File.AppendAllLines(logFile, new[] { $"Failed calling home {ex.Message}" }, Encoding.Unicode);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -117,10 +109,6 @@ namespace ServerManagerTool.Plugin.Discord
|
||||||
&& !string.IsNullOrWhiteSpace(cp.DiscordWebhookUrl));
|
&& !string.IsNullOrWhiteSpace(cp.DiscordWebhookUrl));
|
||||||
if (configProfiles == null || configProfiles.IsEmpty())
|
if (configProfiles == null || configProfiles.IsEmpty())
|
||||||
{
|
{
|
||||||
#if DEBUG
|
|
||||||
var logFile = Path.Combine(PluginHelper.PluginFolder, "DiscordErrors.log");
|
|
||||||
File.AppendAllLines(logFile, new[] { $"{alertType}; {profileName} - {alertMessage.Replace(Environment.NewLine, " ")} (No config profiles found)" }, Encoding.Unicode);
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -192,27 +180,15 @@ namespace ServerManagerTool.Plugin.Discord
|
||||||
if (httpResponse.StatusCode == HttpStatusCode.OK)
|
if (httpResponse.StatusCode == HttpStatusCode.OK)
|
||||||
{
|
{
|
||||||
Debug.WriteLine($"{nameof(HandleAlert)}\r\nResponse: {responseString}");
|
Debug.WriteLine($"{nameof(HandleAlert)}\r\nResponse: {responseString}");
|
||||||
#if DEBUG
|
|
||||||
var logFile = Path.Combine(PluginHelper.PluginFolder, "DiscordSuccess.log");
|
|
||||||
File.AppendAllLines(logFile, new[] { $"{alertType}; {profileName} - {alertMessage.Replace(Environment.NewLine, " ")} ({responseString})" }, Encoding.Unicode);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.WriteLine($"{nameof(HandleAlert)}\r\n{httpResponse.StatusCode}: {responseString}");
|
Debug.WriteLine($"{nameof(HandleAlert)}\r\n{httpResponse.StatusCode}: {responseString}");
|
||||||
#if DEBUG
|
|
||||||
var logFile = Path.Combine(PluginHelper.PluginFolder, "DiscordErrors.log");
|
|
||||||
File.AppendAllLines(logFile, new[] { $"{alertType}; {profileName} - {alertMessage.Replace(Environment.NewLine, " ")} ({responseString})" }, Encoding.Unicode);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Debug.WriteLine($"ERROR: {nameof(HandleAlert)}\r\n{ex.Message}");
|
Debug.WriteLine($"ERROR: {nameof(HandleAlert)}\r\n{ex.Message}");
|
||||||
#if DEBUG
|
|
||||||
var logFile = Path.Combine(PluginHelper.PluginFolder, "DiscordExceptions.log");
|
|
||||||
File.AppendAllLines(logFile, new[] { $"{alertType}; {profileName} - {alertMessage.Replace(Environment.NewLine, " ")} ({ex.Message})" }, Encoding.Unicode);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -220,11 +196,11 @@ namespace ServerManagerTool.Plugin.Discord
|
||||||
{
|
{
|
||||||
LoadConfig();
|
LoadConfig();
|
||||||
|
|
||||||
if (PluginConfig.LastCallHome.AddHours(Config.Default.CallHomeDelay) < DateTime.Now)
|
if (PluginConfig.PluginCallUrlLast.AddHours(Config.Default.PluginCallUrlDelay) < DateTime.Now)
|
||||||
{
|
{
|
||||||
//CallHomeAsync().DoNotWait();
|
CallHomeAsync().DoNotWait();
|
||||||
|
|
||||||
PluginConfig.LastCallHome = DateTime.Now;
|
PluginConfig.PluginCallUrlLast = DateTime.Now;
|
||||||
SaveConfig();
|
SaveConfig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,12 @@ namespace ServerManagerTool.Plugin.Discord
|
||||||
public DiscordPluginConfig()
|
public DiscordPluginConfig()
|
||||||
: base()
|
: base()
|
||||||
{
|
{
|
||||||
LastCallHome = DateTime.MinValue;
|
PluginCallUrlLast = DateTime.MinValue;
|
||||||
ConfigProfiles = new ObservableList<ConfigProfile>();
|
ConfigProfiles = new ObservableList<ConfigProfile>();
|
||||||
}
|
}
|
||||||
|
|
||||||
[DataMember]
|
[DataMember]
|
||||||
public DateTime LastCallHome
|
public DateTime PluginCallUrlLast
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
set;
|
set;
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ namespace ServerManagerTool.Plugin.Discord
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Debug.WriteLine($"ERROR: {nameof(PerformCallToAPIAsync)} - {pluginCode}; {ipAddress}\r\n{ex.Message}");
|
Debug.WriteLine($"{nameof(PerformCallToAPIAsync)} - Failed calling API.\r\n{ex.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,30 @@
|
||||||
<title>Discord Plugin Version Feed</title>
|
<title>Discord Plugin Version Feed</title>
|
||||||
<subtitle>This is the Discord Plugin release version feed.</subtitle>
|
<subtitle>This is the Discord Plugin release version feed.</subtitle>
|
||||||
<link href="" />
|
<link href="" />
|
||||||
<updated>2021-12-12T00:00:00Z</updated>
|
<updated>2021-12-20T00:00:00Z</updated>
|
||||||
|
|
||||||
|
<entry>
|
||||||
|
<id>urn:uuid:F8987FDF-7A69-4E03-99D8-E04ADFFFF0BB</id>
|
||||||
|
<title>1.0.20 (1.0.20.1)</title>
|
||||||
|
<summary>1.0.20.1</summary>
|
||||||
|
<link href="" />
|
||||||
|
<updated>2021-12-20T00:00:00Z</updated>
|
||||||
|
<content type="xhtml">
|
||||||
|
<div xmlns="http://www.w3.org/1999/xhtml" style="font-family: Arial, Verdana, Helvetica, Sans-Serif;font-size: .8em;">
|
||||||
|
<p>
|
||||||
|
<u style="font-size: .9em;">CHANGE</u>
|
||||||
|
<br/>
|
||||||
|
<ul>
|
||||||
|
<li>Additional changes to config loading to prevent blanking the config file.</li>
|
||||||
|
</ul>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</content>
|
||||||
|
<author>
|
||||||
|
<name>bletch</name>
|
||||||
|
<email>bletch1971@hotmail.com</email>
|
||||||
|
</author>
|
||||||
|
</entry>
|
||||||
|
|
||||||
<entry>
|
<entry>
|
||||||
<id>urn:uuid:A9EC2F32-E026-485F-BD7B-C657DBA95B54</id>
|
<id>urn:uuid:A9EC2F32-E026-485F-BD7B-C657DBA95B54</id>
|
||||||
|
|
|
||||||
|
|
@ -5,120 +5,21 @@
|
||||||
<title>Discord Plugin Version Feed</title>
|
<title>Discord Plugin Version Feed</title>
|
||||||
<subtitle>This is the Discord Plugin beta version feed.</subtitle>
|
<subtitle>This is the Discord Plugin beta version feed.</subtitle>
|
||||||
<link href="" />
|
<link href="" />
|
||||||
<updated>2021-12-12T00:00:00Z</updated>
|
<updated>2021-12-20T00:00:00Z</updated>
|
||||||
|
|
||||||
<entry>
|
<entry>
|
||||||
<id>urn:uuid:A0D7BFD2-F2F0-481A-A22D-3C193BFB4C99</id>
|
<id>urn:uuid:F8987FDF-7A69-4E03-99D8-E04ADFFFF0BB</id>
|
||||||
<title>1.0.19 (1.0.19.5)</title>
|
<title>1.0.20 (1.0.20.1)</title>
|
||||||
<summary>1.0.19.5</summary>
|
<summary>1.0.20.1</summary>
|
||||||
<link href="" />
|
<link href="" />
|
||||||
<updated>2021-12-12T00:00:00Z</updated>
|
<updated>2021-12-20T00:00:00Z</updated>
|
||||||
<content type="xhtml">
|
<content type="xhtml">
|
||||||
<div xmlns="http://www.w3.org/1999/xhtml" style="font-family: Arial, Verdana, Helvetica, Sans-Serif;font-size: .8em;">
|
<div xmlns="http://www.w3.org/1999/xhtml" style="font-family: Arial, Verdana, Helvetica, Sans-Serif;font-size: .8em;">
|
||||||
<p>
|
<p>
|
||||||
<u style="font-size: .9em;">CHANGE</u>
|
<u style="font-size: .9em;">CHANGE</u>
|
||||||
<br/>
|
<br/>
|
||||||
<ul>
|
<ul>
|
||||||
<li>ru-RU Translation file updated.</li>
|
<li>Additional changes to config loading to prevent blanking the config file.</li>
|
||||||
</ul>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</content>
|
|
||||||
<author>
|
|
||||||
<name>bletch</name>
|
|
||||||
<email>bletch1971@hotmail.com</email>
|
|
||||||
</author>
|
|
||||||
</entry>
|
|
||||||
|
|
||||||
<entry>
|
|
||||||
<id>urn:uuid:38A61493-CA4E-479E-A3FD-266565E83D90</id>
|
|
||||||
<title>1.0.19 (1.0.19.4)</title>
|
|
||||||
<summary>1.0.19.4</summary>
|
|
||||||
<link href="" />
|
|
||||||
<updated>2021-12-12T00:00:00Z</updated>
|
|
||||||
<content type="xhtml">
|
|
||||||
<div xmlns="http://www.w3.org/1999/xhtml" style="font-family: Arial, Verdana, Helvetica, Sans-Serif;font-size: .8em;">
|
|
||||||
<p>
|
|
||||||
<u style="font-size: .9em;">CHANGE</u>
|
|
||||||
<br/>
|
|
||||||
<ul>
|
|
||||||
<li>ru-RU Translation file added.</li>
|
|
||||||
</ul>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</content>
|
|
||||||
<author>
|
|
||||||
<name>bletch</name>
|
|
||||||
<email>bletch1971@hotmail.com</email>
|
|
||||||
</author>
|
|
||||||
</entry>
|
|
||||||
|
|
||||||
<entry>
|
|
||||||
<id>urn:uuid:DDB25735-1D20-4580-B5FE-1AD4BD107376</id>
|
|
||||||
<title>1.0.19 (1.0.19.3)</title>
|
|
||||||
<summary>1.0.19.3</summary>
|
|
||||||
<link href="" />
|
|
||||||
<updated>2021-12-12T00:00:00Z</updated>
|
|
||||||
<content type="xhtml">
|
|
||||||
<div xmlns="http://www.w3.org/1999/xhtml" style="font-family: Arial, Verdana, Helvetica, Sans-Serif;font-size: .8em;">
|
|
||||||
<p>
|
|
||||||
<u style="font-size: .9em;">CHANGE</u>
|
|
||||||
<br/>
|
|
||||||
<ul>
|
|
||||||
<li>fr-FR Translation file added.</li>
|
|
||||||
<li>pt-BR Translation file updated.</li>
|
|
||||||
</ul>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</content>
|
|
||||||
<author>
|
|
||||||
<name>bletch</name>
|
|
||||||
<email>bletch1971@hotmail.com</email>
|
|
||||||
</author>
|
|
||||||
</entry>
|
|
||||||
|
|
||||||
<entry>
|
|
||||||
<id>urn:uuid:FD4F56C3-9E44-4422-A761-87E7F957454F</id>
|
|
||||||
<title>1.0.19 (1.0.19.2)</title>
|
|
||||||
<summary>1.0.19.2</summary>
|
|
||||||
<link href="" />
|
|
||||||
<updated>2021-12-09T00:00:00Z</updated>
|
|
||||||
<content type="xhtml">
|
|
||||||
<div xmlns="http://www.w3.org/1999/xhtml" style="font-family: Arial, Verdana, Helvetica, Sans-Serif;font-size: .8em;">
|
|
||||||
<p>
|
|
||||||
<u style="font-size: .9em;">CHANGE</u>
|
|
||||||
<br/>
|
|
||||||
<ul>
|
|
||||||
<li>Changed the plugin initialization so it throws an exception if unable to load config file, rather than creating a new config file.</li>
|
|
||||||
</ul>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</content>
|
|
||||||
<author>
|
|
||||||
<name>bletch</name>
|
|
||||||
<email>bletch1971@hotmail.com</email>
|
|
||||||
</author>
|
|
||||||
</entry>
|
|
||||||
|
|
||||||
<entry>
|
|
||||||
<id>urn:uuid:A9EC2F32-E026-485F-BD7B-C657DBA95B54</id>
|
|
||||||
<title>1.0.19 (1.0.19.1)</title>
|
|
||||||
<summary>1.0.19.1</summary>
|
|
||||||
<link href="" />
|
|
||||||
<updated>2021-12-09T00:00:00Z</updated>
|
|
||||||
<content type="xhtml">
|
|
||||||
<div xmlns="http://www.w3.org/1999/xhtml" style="font-family: Arial, Verdana, Helvetica, Sans-Serif;font-size: .8em;">
|
|
||||||
<p>
|
|
||||||
<u style="font-size: .9em;">BUGFIX</u>
|
|
||||||
<br/>
|
|
||||||
<ul>
|
|
||||||
<li>Fixed alert test message to support globalization.</li>
|
|
||||||
</ul>
|
|
||||||
<u style="font-size: .9em;">CHANGE</u>
|
|
||||||
<br/>
|
|
||||||
<ul>
|
|
||||||
<li>de-DE Translation file updated.</li>
|
|
||||||
<li>pt-BR Translation file updated.</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,9 @@
|
||||||
<applicationSettings>
|
<applicationSettings>
|
||||||
<ServerManagerTool.Plugin.Discord.Config>
|
<ServerManagerTool.Plugin.Discord.Config>
|
||||||
<setting name="PluginCallUrlFormat" serializeAs="String">
|
<setting name="PluginCallUrlFormat" serializeAs="String">
|
||||||
<value>http://servermanager.azurewebsites.net/api/plugin/call/{0}/{1}/</value>
|
<value>http://servermanagers.azurewebsites.net/api/plugin/call/{0}/{1}/</value>
|
||||||
</setting>
|
</setting>
|
||||||
<setting name="CallHomeDelay" serializeAs="String">
|
<setting name="PluginCallUrlDelay" serializeAs="String">
|
||||||
<value>12</value>
|
<value>12</value>
|
||||||
</setting>
|
</setting>
|
||||||
<setting name="RequestTimeout" serializeAs="String">
|
<setting name="RequestTimeout" serializeAs="String">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue