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

425 Commits

Author SHA1 Message Date
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
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
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
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
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
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
Pragmatic Software
673c468159
applets/cjeopardy: add more alternative answers 2024-10-23 12:34:27 -07:00
Pragmatic Software
abdb88c7b3
Plugin/Wordle: add solved-by to info and guess 2024-10-23 11:59:03 -07:00
Pragmatic Software
7db191e7c2
applets/cjeopardy: add alternative answers tor postfix/prefix questions 2024-10-22 10:47:20 -07:00
Pragmatic Software
755d7bd6c0
Bug fixes
general.debugcontext: filter out cmdlist and arglist

Core/Applets: log applet start/stop and duration

Core/ProcessManager: fix potential race-condition with $context object

Core/Interpreter:

    * expand pronouns before command-substitution
    * attempt to find current channel's factoid instance for metadata
    * remove duplication of command history in command-substition
    * terminate pipe/substitution processing when protecting self

Core/Factoids: limit -url contents to 250kb
2024-10-22 09:50:10 -07:00
Pragmatic Software
521e8850b0
Core/IgnoreList: allow specifying nickname as channel argument to ignore private messages 2024-10-15 20:05:24 -07:00
Pragmatic Software
597820c053
Core/Factoids: properly restore invalid $variable expansions 2024-10-15 19:56:04 -07:00
Pragmatic Software
71a4c4c331
Plugin/Wordle: add info command; minor tweak to start error-handling 2024-10-15 11:54:32 -07:00
Pragmatic Software
d29a60978e
Plugin/Battleship: improve ship placement
Same-player ships will no longer be aligned end-to-end in the same orientation
to appear like one long ship.

There will no longer always be an even amount of horizontal and vertical ships
for each player.
2024-10-06 01:34:04 -07:00
Pragmatic Software
a2b5162290
Plugin/Battleship: perform attacks in command-order instead of player-order 2024-10-05 14:19:05 -07:00
Pragmatic Software
646a7f8e7f
Factoids: move /code to after action processing 2024-10-04 22:34:02 -07:00
Pragmatic Software
bb1b43b089
applets/wiktionary: refactor relations 2024-10-02 20:13:45 -07:00
Pragmatic Software
68bd1e4d86
applets/wiktionary: add -r flag for relations 2024-10-02 18:50:56 -07:00
Pragmatic Software
9192b7bfad
pbot-vm: Preserve escapes in -args and -stdin 2024-10-01 13:08:52 -07:00
Pragmatic Software
a453518fab
AntiFlood: add some missing nickserv account case normalization 2024-09-28 12:19:37 -07:00