[Question] Can you use an IRC message text as a variable?
Closed this issue · 4 comments
not-an-iSheep commented
EX:
param ($Message, $Bot)
switch -regex ($Message.Text)
{
"This is a variable" { storeasvariable }
"Say Variable" {$Variable}**
}
alejandro5042 commented
Yes you can! See: https://github.com/alejandro5042/Run-IrcBot#stateful-bots
not-an-iSheep commented
@alejandro5042 I'm confused, it seems that the section that you pointed me to says how to use and preserve variables but not how to store messages as variables.
Thank you for your response.
alejandro5042 commented
Can't you simply store $Message.Text
in a $Bot.State.PreviousMessageText
variable?
Do you want to capture a variable and output it later? This should work: (disclaimer: didn't test)
'This is a variable: (?<value>.*)' { $Bot.State.Variable = $Matches.value }
'print var' { $Bot.State.Variable }
not-an-iSheep commented
@alejandro5042 Thanks!