alejandro5042 / Run-IrcBot

IRC Bot Toolkit for PowerShell
MIT License
13 stars 4 forks source link

[Question] Can you use an IRC message text as a variable? #11

Closed not-an-iSheep closed 7 years ago

not-an-iSheep commented 7 years ago

EX:

param ($Message, $Bot)

switch -regex ($Message.Text)
{
    "This is a variable"   { storeasvariable }
    "Say Variable" {$Variable}**
}
alejandro5042 commented 7 years ago

Yes you can! See: https://github.com/alejandro5042/Run-IrcBot#stateful-bots

not-an-iSheep commented 7 years ago

@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 7 years ago

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 7 years ago

@alejandro5042 Thanks!