mirror of
https://github.com/SlothDpal/Relaunch-Process.git
synced 2026-02-22 17:27:38 +03:00
добавлены аватар и имя бота в Discord, мелкие фиксы
This commit is contained in:
46
Form1.cs
46
Form1.cs
@@ -40,7 +40,7 @@ namespace Process_Auto_Relaunch
|
||||
this.updateLogDelegate += this.HistoryLog;
|
||||
myBackgroundWorker.WorkerSupportsCancellation = true;
|
||||
dwhHook = new DiscordWebhook();
|
||||
if ( Uri.IsWellFormedUriString(Settings.Default.dwhURL,UriKind.Absolute) && Settings.Default.dwhEnabled && Settings.Default.dwhURL!="")
|
||||
/*if ( Uri.IsWellFormedUriString(Settings.Default.dwhURL,UriKind.Absolute) && Settings.Default.dwhEnabled && Settings.Default.dwhURL!="")
|
||||
{
|
||||
dwhHook.Url = Settings.Default.dwhURL;
|
||||
}
|
||||
@@ -49,7 +49,7 @@ namespace Process_Auto_Relaunch
|
||||
HistoryLog($"Îøèáêà â URL âåá-õóêà ({Settings.Default.dwhURL}). Âûâîä â Discord îòêëþ÷åí.");
|
||||
Settings.Default.dwhEnabled = false;
|
||||
Settings.Default.Save();
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
@@ -143,43 +143,59 @@ namespace Process_Auto_Relaunch
|
||||
/// <summary>
|
||||
/// Îáíîâëåíèå ñòàòóñà â ïðîãðàììå
|
||||
/// </summary>
|
||||
/// <param name="text">Òåêñò äëÿ îòîáðàæåíèÿ</param>
|
||||
/// <param name="add_history">Ñîõðàíåíèå òåêñòà â îêíî èñòîðèè</param>
|
||||
/// <param name="text">Òåêñò äëÿ îòîáðàæåíèÿ/îòïðàâêè </param>
|
||||
/// <param name="level">Ôëàãè äëÿ íàçíà÷åíèÿ îòïðàâêè</param>
|
||||
public void UpdateStatus( string text, NotifyLevel level )
|
||||
{
|
||||
if (!level.HasFlag(NotifyLevel.logAlways) && !level.HasFlag(NotifyLevel.logUpdateStatus)) return;
|
||||
labelStatus.Text = text;
|
||||
}
|
||||
|
||||
private void HistoryLog( string text, NotifyLevel level = NotifyLevel.logUpdateStatus )
|
||||
/// <summary>
|
||||
/// Äîáàâëåíèå ñòðîêè â Èñòîðèè Çàïóñêîâ
|
||||
/// </summary>
|
||||
/// <param name="text">Òåêñò äëÿ îòîáðàæåíèÿ/îòïðàâêè </param>
|
||||
/// <param name="level">Ôëàãè äëÿ íàçíà÷åíèÿ îòïðàâêè</param>
|
||||
private void HistoryLog( string text, NotifyLevel level )
|
||||
{
|
||||
if (!level.HasFlag(NotifyLevel.logAlways) && !level.HasFlag(NotifyLevel.logHistory)) return;
|
||||
richTextBoxHistory.Text += DateTime.Now.ToString() + ": " + text + "\n";
|
||||
}
|
||||
|
||||
public void SendDiscordMessage( string message, NotifyLevel level )
|
||||
/// <summary>
|
||||
/// Îòïðàâêà ñòàòóñà â Discord
|
||||
/// </summary>
|
||||
/// <param name="text">Òåêñò äëÿ îòîáðàæåíèÿ/îòïðàâêè </param>
|
||||
/// <param name="level">Ôëàãè äëÿ íàçíà÷åíèÿ îòïðàâêè</param>
|
||||
public void SendDiscordMessage( string text, NotifyLevel level )
|
||||
{
|
||||
if (!level.HasFlag(NotifyLevel.logAlways) && !level.HasFlag(NotifyLevel.logDiscord)) return;
|
||||
if (Settings.Default.dwhEnabled)
|
||||
{
|
||||
dwhHook.Url = Settings.Default.dwhURL;
|
||||
dwhMessage.Username = "Relaunch process";
|
||||
dwhMessage.Content = ":arrows_counterclockwise: " + message;
|
||||
dwhMessage.Username = Settings.Default.dwhBotname;
|
||||
dwhMessage.AvatarUrl = Settings.Default.dwhAvatarURL;
|
||||
dwhMessage.Content = ":arrows_counterclockwise: " + text;
|
||||
try
|
||||
{
|
||||
dwhHook.Send(dwhMessage);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
HistoryLog($"Discord messaging error: {ex.Message}");
|
||||
Status($"Îøèáêà îòïðàâêè â äèñêîðä.",NotifyLevel.logHistory);
|
||||
Debug.WriteLine($"Discord messaging error: {ex.Message}");
|
||||
Settings.Default.dwhEnabled = false;
|
||||
Settings.Default.Save();
|
||||
//Settings.Default.dwhEnabled = false;
|
||||
//Settings.Default.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Status(string text, NotifyLevel level)
|
||||
/// <summary>
|
||||
/// Îáíîâëåíèå ñòàòóñà â ïðîãðàììå
|
||||
/// </summary>
|
||||
/// <param name="text">Òåêñò äëÿ îòîáðàæåíèÿ/îòïðàâêè </param>
|
||||
/// <param name="level">Ôëàãè äëÿ íàçíà÷åíèÿ îòïðàâêè</param>
|
||||
public void Status(string text, NotifyLevel level = NotifyLevel.logUpdateStatus)
|
||||
{
|
||||
updateLogDelegate.Invoke(text, level);
|
||||
}
|
||||
@@ -204,7 +220,7 @@ namespace Process_Auto_Relaunch
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonSetProgramStart_Click(object sender, EventArgs e)
|
||||
private void ButtonSetProgramStart_Click(object sender, EventArgs e)
|
||||
{
|
||||
OpenFileDialog openFile = new OpenFileDialog();
|
||||
openFile.Filter = "Èñïîëíÿåìûå ôàéëû (*.exe)|*.exe";
|
||||
@@ -305,12 +321,12 @@ namespace Process_Auto_Relaunch
|
||||
{
|
||||
if (e.Cancelled)
|
||||
{
|
||||
Status("Íàáëþäåíèå îòìåíåíî.",NotifyLevel.logUpdateStatus);
|
||||
Status("Íàáëþäåíèå îòìåíåíî.",NotifyLevel.logUpdateStatus|NotifyLevel.logDiscord);
|
||||
}
|
||||
else if (e.Error != null)
|
||||
{
|
||||
Status("Ïðîèçîøëà îøèáêà! Íàáëþäåíèå îñòàíîâëåíî.", NotifyLevel.logUpdateStatus | NotifyLevel.logDiscord);
|
||||
MessageBox.Show("Error: " + e.Error.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
||||
Status("Ïðîèçîøëà îøèáêà! Íàáëþäåíèå îñòàíîâëåíî.", NotifyLevel.logUpdateStatus|NotifyLevel.logDiscord);
|
||||
radioButtonDisableWathing.Checked = true;
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user