3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-01 00:19:30 +01:00
Commit Graph

4859 Commits

Author SHA1 Message Date
Pragmatic Software
001f2024c4
Factoids: add default value modifier
Uses POSIX shell parameter expansion syntax.

    <pragma-> !factadd cookie /me gives a cookie to ${args:-nobody. What a shame}!
       <PBot> cookie added to the global channel.

    <pragma-> !cookie Bob
            * PBot gives a cookie to Bob!

    <pragma-> !cookie
            * PBot gives a cookie to nobody. What a shame!

    <pragma-> !factadd sum /call calc $arg[0]:-1 + $arg[1]:-2
       <PBot> sum added to the global channel.

    <pragma-> !sum
       <PBot> 1 + 2 = 3

    <pragma-> !sum 3
       <PBot> 3 + 2 = 5

    <pragma-> !sum 4 6
       <PBot> 4 + 6 = 10
2024-11-27 12:17:45 -08:00
Pragmatic Software
917cae2ffb
Plugin/Spinach: fix players exit game on /part and /quit 2024-11-22 03:17:39 -08:00
Pragmatic Software
7a7730d039
Interpreter: improve processing of embedded and split commands 2024-11-21 20:31:28 -08:00
Pragmatic Software
bea5aa071b
Plugin/Spinach: improve lie count log 2024-11-21 20:28:50 -08:00
Pragmatic Software
5f4b2989a1
Factoids: fact no longer adds ref channel to output 2024-11-21 20:21:14 -08:00
Pragmatic Software
947082f2a2
Plugin/ActionTrigger: don't handle events already processed by another command 2024-11-21 16:05:44 -08:00
Pragmatic Software
888da7dda1
Factoids: move enabled check to before /call 2024-11-15 01:15:37 -08:00
Pragmatic Software
c6433a662f
Commands/Factoids: remove "not owner" restriction on factset/factunset 2024-11-14 01:21:48 -08:00
Pragmatic Software
5bca8c7d16
Plugin/Spinach: Improvements 2024-11-13 21:43:22 -08:00
Pragmatic Software
343dbae57e
Plugin/Spinach: add help text; minor clean-ups 2024-11-10 18:39:14 -08:00
Pragmatic Software
dbff4bc2f7
Interpreter: reset split_result after processing it
This fixes e.g.:

    <pragma-> ,{echo foo ;;; echo bar}  ,{echo baz}
       <PBot> foo bar
       <PBot> foo baz

To instead produce the expected:

    <PBot> foo bar
    <PBot> baz
2024-11-10 17:45:33 -08:00
Pragmatic Software
8e2b0df17c
Update factoids 2024-11-10 09:53:45 -08:00
Pragmatic Software
72ac68fb02
Plugin/Spinach: rounds/questions/bonus rounds now configurable via settings
The number of rounds, questions and bonus rounds are now all configurable via
`spinach set settings`.

Refactored states to not transition of a false value is returned, to eliminate
all explicit "wait" states.
2024-11-09 20:54:10 -08:00
Pragmatic Software
22771fabf6
Plugin/Spinach: massive refactor
Refactored ridiculous large per-round/per-question state transitions and
subroutines into a much more manageable and simpler state machine.

Now can easily and trivially adjust maximum rounds and maximum questions
by editing $self->{game} hashtable entries. TODO: make this configurable
via `spinach set`.

Replaced "/msg me" with "/msg $botnick" throughout.

Adjusted lie validation:

  * If all words of lie are found within solution and word-count of lie is
    less than word-count of solution, then game will say "So-and-so has found
    part of the truth!"

  * If lie is 20%-or-less different to the solution, then game will say
    "So-and-so has misspelled the truth!"
2024-11-08 23:29:52 -08:00
JustAnotherArchivist
84117d83c7
applets/paren: Disambiguate *f(x) = *(f(x)) from (*f)(x) (#74)
Also remove the explicit check for `ArrayRef`, which is obsolete since the 2014 addition of the `_is_simple_node` override in commit ba59edb04. (Upstream `_is_simple_node` returns `True` for an `ArrayRef`.)
2024-11-08 21:48:52 -08:00
Pragmatic Software
a11dc12861
Interpreter: remove debug message 2024-11-07 19:47:02 -08:00
Pragmatic Software
e325138249
Plugin/Spinach: correct round1q3 state transition 2024-11-07 19:46:30 -08:00
Pragmatic Software
828892726d
doc/Factoids.md: Fix typo 2024-11-07 02:41:07 -08:00
Pragmatic Software
a262139fd2
Factoids: require locked to be exactly 1 to invoke commands with required_caps
This allows us to set `locked` to a value greater than `1` to lock a factoid WITHOUT
allowing invocation of `required_caps` commands. This lets us safely lock a factoid
that has unrestrained `$args` or variables.
2024-11-07 01:45:15 -08:00
Pragmatic Software
12ec8bb77c
Factoids: don't add nick if add_nick defined and set to 0 2024-11-06 22:51:29 -08:00
Pragmatic Software
54ef6b14ce
Plugin/Date: use existing context when launching date applet
This preserves the pipe/cmd-substitution/etc to allow post-processing
of the `date` output.

Interpreter: Reset `interpreted` contextual metadata when handling
result to allow recursion for continued command processing.
2024-11-05 23:57:48 -08:00
Pragmatic Software
7f49321e29
Commands/Factoids: fix unsetting locked on factoids with cap-override 2024-11-05 16:55:53 -08:00
Pragmatic Software
650bf40a24
Disallow invoking of commands with requires_cap from unlocked factoids
As a security measure to prevent users from creating or modifying factoids to
sneak in commands to trick chanops/admins/botowners/etc into executing those
commands, the command interpreter will now check if the command has been
invoked in the context of a factoid. If so, the factoid must be locked.
2024-11-05 16:48:59 -08:00
Pragmatic Software
10374b47c9
Update factoids 2024-11-05 02:30:43 -08:00
Pragmatic Software
a71f29be1a
FuncBuiltins: add maybe-on 2024-11-05 02:13:39 -08:00
Pragmatic Software
ead34c81c9
Plugin/FuncBuiltins: add maybe-to 2024-11-04 01:53:41 -08:00
Pragmatic Software
9ebc77f4da
Replace preserve_whitespace metadata with condense-whitespace
PBot now preserves whitespace by default. The `preserve_whitespace`
metadata field is now redundant. It has now been replaced with
`condense-whitespace`, which when set to a true value will collapse
adjacent whitespace to a single space.
2024-11-04 00:25:36 -08:00
Pragmatic Software
41c5182208
Update factoids 2024-11-03 19:27:05 -08:00
Pragmatic Software
4c866d39b6
Fix white-space handling; add suppress-no-output 2024-11-03 19:26:56 -08:00
Pragmatic Software
1f232a9455
Applets: Add $context->{interpreted} to exit interpreter loop 2024-11-03 19:22:45 -08:00
Pragmatic Software
29f1fa0c4b
Plugin/AntiHello: update regex 2024-11-03 19:17:58 -08:00
Pragmatic Software
b58b778648
Applets: execute_applet() returns defined value to end interpreter loop
Due to recent changes to support continued processing of empty string command
results, ProcessManager::execute_process() now returns undefined value, which
causes Interpreter::interpret() to continue looping through registered command
interpreters after successfully handling a command.

This causes some plugins, i.e. Plugin/Date.pm, to continue the interpret() loop
after successfully handling a command, which causes additional interpreters to
handle the command, leading to both a built-in command an a factoid command
being invoked if they share the same name.

Applets::execute_applet() now returns the defined empty string to let the
interpreter loop know that the command has been handled.
2024-11-03 12:05:39 -08:00
Pragmatic Software
2182b26bfd
FuncBuiltins: add shquote and quotemeta 2024-11-02 19:13:34 -07:00
Pragmatic Software
bd4fd4ea27
pbot-vm: preserve newlines in split_line() 2024-11-02 18:29:25 -07:00
Pragmatic Software
02a0d8ecfb
Commands/Factoids: Fix 4-arg form of factmove; add factcopy
`factmove` arguments now behave more sensibly in that:

* `factmove #channel keyword global keyword` now properly moves/renames
factoids to global channel

* `factmove #channel keyword #channel global` renames the factoid to `global`

* `factmove #channel keyword newname` renames the factoid to `newname`
2024-11-02 18:27:51 -07:00
Pragmatic Software
e234446afd
Plugin/Wordle: change "guesses attempted" to "guesses" 2024-11-02 17:59:07 -07:00
Pragmatic Software
73c4ed465d
Factoid/Variables: minor refactor, no semantic changes 2024-11-02 17:58:14 -07:00
Pragmatic Software
c6f6823df9
Fix misc white-spacing issues
* func sed no longer trims leading whitespace
* quoted text no longer trims leading whitespace
* no longer convert tabs to spaces in output
* no longer condense adjacent whitespace together in output
2024-11-02 17:57:19 -07:00
Pragmatic Software
af2d9844b8
Interpreter: allow processing of empty result
This fixes .e.g.:

    <pragma-> !echo foo &{echo bar | { sed s/bar// }} baz

such that it produces the output "foo  baz" instead of no output at all.
2024-11-02 17:53:37 -07:00
Pragmatic Software
f680439d47
Plugin/Wordle: add guesses subcommand 2024-10-31 00:55:31 -07:00
Pragmatic Software
e7d3a543c4
Update factoids
Amazing factoids being created in #wordle by JAA and emanuele6.

jaa-guesses2wordles: /call wordles &{jaasolve-state2pattern &{jaa-guesses2state '&{wordle guesses | {stripircformatting}}' $arg[-1]}} &{wordle info | {sed s/ \(.*$//} | {sed s/^.* //}}

jaa-guesses2state: /code sh shopt -s extglob; declare -A _m=(\* G \? Y \  B);_w=" ${1//ẞ/ß}" _w=${_w,,} _o=; while [[ "${_w}" ]]; do _g= _r= _w=${_w:1}; while [[ "${_w}" == ' '?[\ ?*]* ]]; do
_g+=${_w:1:1} _r+=${_m["${_w:2:1}"]} _w=${_w:3}; done; _o=$_o${_o:+.}$_g.$_r; done; _o=${_o%.+([^.]).+(G)}; for ((_i = ${2:-0}; _i > 0; --_i)); do _o=${_o%.+([^.]).+([GYB])}; done; printf %s\\n "$_o"

wsg: /call call &{func grep wordle wordle &{wordle start &{clength $arg[0]} $arg[1]}} guess $arg[0]

clength: /code sh printf %s "${#1}"

rspray: /call func sed s/Le.*?:.*?@//g Le:&{wordle start}@&{wordle guess &{rw}}@&{wordle guess &{rw}}@&{wordle guess &{rw}}@&{wordle guess &{rw}}

rw: /code sh _len="${1:-5}" ; _list="${2:-american}" ; grep -P ^.{$_len}$ /usr/share/dict/$_list | shuf -n 1

Also megaspray, megasolve, jaasolve, wsgl, and more!
2024-10-30 19:18:18 -07:00
Pragmatic Software
d8a284e9c1
Core/Interpreter: preserve newlines in commands 2024-10-30 16:37:20 -07:00
Pragmatic Software
e5e0f26b90
applets/pbot-vm: minor fixes
* set `preserve_escapes` to 0 in guest/_c_base.pm so escapes are stripped in:

     <pragma-> ,show testcargs
     <candide> [global] testcargs: /code c11 printf("/say args: " ); while
               (*++argv) printf("[%s] " , *argv);
     <pragma-> ,testcargs foo\'bar baz\'qux
     <candide> args: [foo\'bar] [baz\'qux]

  to produce the desired output of:

     <candide> args: [foo'bar] [baz'qux]

* set `keep_spaces` to 1 in host/_default.pm since it turns out that in some
  languages unquoted spaces are significant, e.g. in `sh ${1%  *}` to strip
  text following two spaces. Without `keep_spaces` enabled, `sh ${1%  *}`
  becomes `sh ${1% *}` and strips all text following one space instead of two.
2024-10-30 15:43:38 -07:00
Pragmatic Software
f4caf44eb0
split_line(): Remove no longer used next_ch/last_ch 2024-10-29 12:49:19 -07:00
Pragmatic Software
4287cb9fa2
Fix split_line() quoting to be more sh-like
E.g.:

<pragma-> show testcargs
   <PBot> [global] testcargs: /code c11 printf("/say args: " ); while (*++argv) printf("[%s] " , *argv);
<pragma-> testcargs 'hello''world' 'how are 'you today
   <PBot> args: [helloworld] [how are you] [today]

Previously, adjacent 'foo''bar' would end up as 2 args like [foo] [bar]. Now
they are properly concatenated into one [foobar] argument.

This also fixes the cases of whitespace being inserted after quoted arguments.
2024-10-29 10:19:46 -07:00
Pragmatic Software
4a025801a2
applets/pbot-vm: disregard IRC text modifiers when escaping unprintable characters 2024-10-27 12:52:15 -07:00
Pragmatic Software
f2068a4baf
Plugin/AntiHello: update regex 2024-10-25 17:51:16 -07:00
Pragmatic Software
2c7dcafba5
Plugin/AntiHello: save offense counters to storage 2024-10-25 16:01:08 -07:00
Pragmatic Software
f542cc0cf2
Core/Factoids: top20: show only defined edited-by for edited sub-command 2024-10-23 22:32:27 -07:00
Pragmatic Software
4345b0a75c
Core/Factoids: update edit-by when factadd -f; add edited to top20 2024-10-23 21:36:21 -07:00