Skip to content

Commit

Permalink
Added descriptions for available Twitch command response variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Plenyx committed Jul 7, 2024
1 parent 70697b3 commit 4e10e58
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 8 deletions.
32 changes: 30 additions & 2 deletions Forms/FormEditTwitchCommand.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Forms/FormEditTwitchCommand.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using PlenBotLogUploader.Tools;
using PlenBotLogUploader.Twitch;
using System.Diagnostics;
using System.Windows.Forms;

namespace PlenBotLogUploader.Forms
Expand All @@ -10,6 +11,8 @@ public partial class FormEditTwitchCommand : Form
// fields
private readonly FormTwitchCommands editLink;
private readonly TwitchCommand data;
// consts
private const string variableListLink = "https://github.com/Plenyx/PlenBotLogUploader/blob/main/Twitch/TwitchResponseVariables.md";
#endregion

internal FormEditTwitchCommand(FormTwitchCommands editLink, TwitchCommand data)
Expand Down Expand Up @@ -57,5 +60,7 @@ private void FormEditTwitchCommand_FormClosing(object sender, FormClosingEventAr
(data as IListViewItemInfo<TwitchCommand>).UpdateItems();
}
}

private void LinkLabelInfoLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) => Process.Start(new ProcessStartInfo() { UseShellExecute = true, FileName = variableListLink });
}
}
10 changes: 9 additions & 1 deletion Forms/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ private int LastLogPullCounter
{ "%appVersion%", ApplicationSettings.Version.ToString() },
{ "%pullCounter%", "0" },
{ "%lastLog%", "No log has been posted yet." },
{ "%channel%", "" },
};
private bool bypassCloseToTray = false;

Expand Down Expand Up @@ -1150,12 +1151,14 @@ protected async void OnIrcStateChanged(object sender, IrcState newState, string
if (newState.Equals(IrcState.ChannelJoining))
{
AddToText($"<-?-> TRYING TO JOIN CHANNEL {channelName.ToUpper()}");
twitchCommandReplacements["%channel%"] = "";
return;
}
if (newState.Equals(IrcState.ChannelJoined))
{
AddToText("<-?-> CHANNEL JOINED");
TwitchChannelJoined = true;
twitchCommandReplacements["%channel%"] = ApplicationSettings.Current.Twitch.ChannelName;
return;
}
if (newState.Equals(IrcState.ChannelLeaving))
Expand Down Expand Up @@ -1185,12 +1188,17 @@ protected async void ReadMessagesAsync(object sender, IrcMessage ircMessage)
}
foreach (var twitchCommand in twitchCommands)
{
var commandTriggerTwitchName = ircMessage.UserName.Split('!')[0];
AddToText($"> \"{twitchCommand.Name}\" TWITCH COMMAND USED");
var reply = twitchCommand.FormattedResponse(ircMessage.UserName.Split('!')[0], twitchCommandReplacements);
var reply = twitchCommand.FormattedResponse(commandTriggerTwitchName, twitchCommandReplacements);
if (reply is null)
{
return;
}
if (reply.Contains("%sender%"))
{
reply = reply.Replace("%sender%", commandTriggerTwitchName);
}
if (reply.Contains("%spotifySong%"))
{
reply = reply.Replace("%spotifySong%", SpotifySongCheck());
Expand Down
10 changes: 5 additions & 5 deletions Twitch/TwitchCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ internal class TwitchCommands
},
new()
{
Enabled = true,
Enabled = false,
Name = "!song",
IsRegex = false,
Command = "!song",
Expand All @@ -40,7 +40,7 @@ internal class TwitchCommands
},
new()
{
Enabled = true,
Enabled = false,
Name = "Smart song recognition",
IsRegex = true,
Command = @"(?:(?:song)|(?:music)){1}(?:(?:\?)|(?: is)|(?: name))+",
Expand All @@ -49,7 +49,7 @@ internal class TwitchCommands
},
new()
{
Enabled = true,
Enabled = false,
Name = "!ign",
IsRegex = false,
Command = "!ign",
Expand All @@ -58,7 +58,7 @@ internal class TwitchCommands
},
new()
{
Enabled = true,
Enabled = false,
Name = "!build",
IsRegex = false,
Command = "!build",
Expand All @@ -67,7 +67,7 @@ internal class TwitchCommands
},
new()
{
Enabled = true,
Enabled = false,
Name = "Smart build recognition",
IsRegex = true,
Command = @"(?:(?:build)){1}(?:(?:\?)|(?: is))+",
Expand Down
16 changes: 16 additions & 0 deletions Twitch/TwitchResponseVariables.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Twitch response variables
Twitch response variables are special pieces of text you can include in your Twitch responses to be replaced by other dynamically generated values.

> [!IMPORTANT]
> Please understand some of these variables may be available only in the latest live release or a rolling build of the next release.
| Variable | Available since | Variable description |
| --- | --- | --- |
| `%sender%` | r.94 | Whoever triggered the Twitch command |
| `%channel%` | r.94 | From whatever Twitch channel the command was triggered |
| `%appVersion%` | r.94 | The current version of the application |
| `%lastLog%` | r.94 | The latest log message bot posted to the channel |
| `%pullCounter%` | r.94 | The current number of pulls on the last recorded log |
| `%spotifySong%` | r.94 | The currently playing song on spotify |
| `%gw2Ign%` | r.94 | Returns the In-Game account Name for the currently played character. Requires MumbleLink setup and inserted appropriate GW2 API keys |
| `%gw2Build%` | r.94 | Returns the currently played build for the currently played character. Requires MumbleLink setup and inserted appropriate GW2 API keys |

0 comments on commit 4e10e58

Please sign in to comment.