From 262e79ad70a59702c2bea810cd9e0dc1afdffcd3 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Wed, 8 Jan 2020 22:28:24 -0800 Subject: [PATCH] doc/Factoids.md: make examples much easier to read; add `mock` --- doc/Factoids.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/doc/Factoids.md b/doc/Factoids.md index 78e83707..5f872162 100644 --- a/doc/Factoids.md +++ b/doc/Factoids.md @@ -78,6 +78,7 @@ If a factoid begins with `/say` then PBot will not use the ` is !factadd global hi /say Well, hello there, $nick. hi added to the global channel + PBot, hi Well, hello there, prec. @@ -86,6 +87,7 @@ If a factoid begins with `/me` then PBot will `CTCP ACTION` the factoid. !factadd global bounce /me bounces around. bounce added to the global channel + !bounce * PBot bounces around. @@ -94,6 +96,7 @@ If a factoid begins with `/call` then PBot will call an existing command. This i !factadd global boing /call bounce boing added to the global channel + !boing * PBot bounces around. @@ -167,8 +170,10 @@ the C programming language because why not? !factadd testargs /code c11 printf("/say args: "); while (*++argv) printf("[%s] ", *argv); testargs added to the global channel. + testargs foo bar args: [foo] [bar] + testargs "abc 123" xyz args: [abc 123] [xyz] @@ -198,11 +203,13 @@ the name to prevent them from being expanded as [List Variables](#list-variables my %_votes = (); my @data = ({%_votes}, $_question); system 'rm -rf vote-data'; mkdir 'vote-data' or print "$!"; store \@data, 'vote-data/data'; + !factset startvote usage Usage: startvote !factadd vote /code perl use Storable; my $_data = retrieve 'vote-data/data'; my %_votes = %{shift @$_data}; ($_votes{"$nick"}) = (lc "@ARGV"); unshift @$_data, {%_votes}; store $_data, 'vote-data/data'; + !factset vote usage Usage: vote !factadd votes /code perl no warnings; use Storable; my $_data = retrieve 'vote-data/data'; @@ -217,10 +224,12 @@ And action: !startvote Isn't this cool? Starting poll: Isn't this cool? Use `vote ` to record your vote. + !vote yes !vote no !vote yes !vote hamburger + !votes Poll results for "Isn't this cool?": yes: 2, no: 1, hamburger: 1 @@ -272,6 +281,14 @@ to strip the timestamp and the name, leaving only the message. `smr` stands for !smr derpy3 girls gIrLs ArE dUmB! +We can make an alias with a more friendly name. By the way, if the `recall`ed +message is the most recent, there is no need to use an argument (e.g., `girls`). + + !factalias mock smr + + !mock derpy3 + gIrLs ArE dUmB! + ## Special variables You can use the following variables in a factoid or, in some cases, as an argument to one. @@ -317,8 +334,10 @@ Then use the factoid as a `$variable`. !factadd global sky is /say The sky is $colors. sky added to the global channel + !sky The sky is dark purple. + !sky The sky is green. @@ -326,10 +345,13 @@ Another example, creating the RTFM trigger: !factadd global sizes is big large tiny small huge gigantic teeny sizes added to the global channel + !factadd global attacks is whaps thwacks bashes smacks punts whacks attacks added to the global channel + !factadd global rtfm is /me $attacks $args with a $sizes $colors manual. rtfm added to the global channel + !rtfm mauke * PBot thwacks mauke with a big red manual. @@ -338,6 +360,7 @@ Factoid `$variables` can accept trailing modifier keywords prefixed with a colon !echo $colors:uc RED + !echo $colors:ucfirst Blue @@ -354,10 +377,13 @@ You can use the [`factset`](#factset) command to set a special [factoid meta-dat !factadd global snack is /me eats a cookie. snack added to the global channel + !factset global snack action_with_args /me gives $args a cookie. [Factoids] (global) snack: 'action_with_args' set to '/me gives $args a cookie.' + !snack * PBot eats a cookie. + !snack orbitz * PBot gives orbitz a cookie. @@ -399,9 +425,12 @@ To create an factoid that acts as an alias for a command, use the `factalias` co Usage: `factalias [channel] ` !factadd ##c offtopic is /say In this channel, $args is off-topic. + !offtopic C++ In this channel, C++ is off-topic. + !factalias ##c C++ offtopic C++ + !C++ In this channel, C++ is off-topic. @@ -409,10 +438,13 @@ Usage: `factalias [channel] ` !factadd ##c book is /me points accusingly at $args, "Where is your book?!" book added to ##c + !book newbie * PBot points accusingly at newbie, "Where is your book?!" + !factadd ##c rafb /call book rafb added to ##c + !rafb runtime * PBot points accusingly at runtime, "Where is your book?!" @@ -432,8 +464,10 @@ Usage: `factchange [channel] s///[gi]` !c C rocks! + !factchange ##c c s/rocks/rules/ c changed. + !c C rules! @@ -539,10 +573,13 @@ Usage: `factlog [-h] [-t] [channel] ` !factadd hi /say Hello there! hi added to global channel. + !factchange hi s/!$/, $nick!/ Changed: hi is /say Hello there, $nick! + !forget hi hi removed from the global channel. + !factadd hi /say Hi!