Changelog¶
2.0.0rc1¶
The 2.0 release candidate: a new core, with 1.x plugins still running through a compatibility layer. Install it with pip install --pre pinhook.
Before you upgrade¶
- pinhook needs Python 3.11 or newer
- TOML configs aren't read, and relative paths in a config start from the config file's folder
msg.bothas only the bot's nick and channels,bot.connectionis gone, and@registerand@opsare removed- Migrating from 1.x lists every change, and shows a plugin and a config moved to 2.0
New¶
- Plugins get
ctx: who spoke, where, how to answer, and the plugin's store and settings. Handlers areasync def - Typed commands: arguments come from the handler's signature, bad input gets a usage line, and
!help <command>shows it.aliases=gives a command other names - Class plugins with
setup(previous)andteardown(), so state carries across!reload - Plugins from installed packages, named in
pluginsand found through thepinhook.pluginsentry point self.botin a class plugin, andctx.bot, with the prefix, the data folder, and op, entry and history checks, read onlyset_recipesandallowin class plugins, to add recipes as a plugin's own commands and give someone access to them. A grant for the whole plugin doesn't cover those recipes@onfor joins, parts, kicks, nick changes, topics, invites, modes, netsplits and more, and@everyfor timers@on('addressed')for messages that start with the bot's nick, which then go to that plugin instead of running a commandname=on@onand@everysets the name!enableand!disabletake, and!helplists@on('message')handlers with the listeners- An async core with an output queue, which keeps to each network's rate limits, so a slow plugin or a long reply never freezes the bot.
rate_limitchanges how fast it sends - Access levels: open, restricted or ops-only, per plugin or command, with groups, and
!allow,!deny,!revokeand!accessfrom chat - Recipes: commands written as YAML, which run existing commands as the person who asked, with replies, a store, loops and conditions. Ops add one-line recipes with
!recipe add - Recipe steps from plugins can check their fields when a recipe loads, and mark text as only to be shown, never run or stored
- IRCv3: SCRAM-SHA-256 and EXTERNAL logins, STS, server time, message tags, threaded and private replies, typing, echo-message, labeled responses, MONITOR and case mapping
prefix=onctx.replyandctx.sendstarts every line, split lines includedrealnamesets the name WHOIS shows for the bot- Twitch from a config file with
platform: twitch, badges as access groups, and user IDs as accounts bot.commands()lists what someone can run,bot.run_as()runs a command as them,ctx.commands()andctx.run()do both for the sender, andctx.history()reads a channel's recent messages- The command line:
pinhook new,pinhook check,pinhook run, with--reload, andpinhook connect twitch - Deployment: an image on ghcr.io, signed and with an SBOM,
${file:PATH}secrets,secrets.env, logs to stdout and as JSON, audit lines, a health endpoint, and compose, systemd and Kubernetes examples - Type hints throughout, with
py.typed, so mypy checks plugins against pinhook's API
Changed¶
- Commands are written without their prefix, and answer to
cmd_prefixor the bot's nick - 1.x plugins run through the compatibility layer, with deprecation warnings, each on a thread of its own, one call at a time
- Two plugins with the same command is a load error naming both
pinhook config.yamlispinhook run config.yaml. The old form still works, with a warning
Removed¶
- The
irclibrary, replaced byirctokens - TOML configs,
@register,@opsanduse_prefix_for_plugins
1.12.0¶
Before you upgrade¶
Nothing should break. Two things you might notice:
- Plugins that use
msg.bot,@registeror@opslog a deprecation warning saying what to use instead (msg.botonly once per bot). They all still work. Preparing for 2.0 has the details - Once a plugin uses
msg.store, adata/folder appears where the bot runs, or insidebot_dirif that's set
New¶
pinhook.testing: aTestBotthat runs your plugins without a server, so you can test them with pytestmsg.reply(text)andmsg.send(target, text)send straight away, so a plugin can reply more than once or to several places- Given just the text,
msg.action(text)replies where the message came from andmsg.notice(text)sends the sender a notice msg.account(the sender's services account) andmsg.is_privatebot_dirkeeps everything a bot uses in one folder, withplugins/,data/andlogs/inside it. Without it, files go where they did in 1.11msg.store, a dictionary each plugin can keep data in. It lasts through!reloadand restarts, and is saved todata_dirautomaticallydata_dir, where plugins keep their saved dataplugin_configgives each plugin its own settings, asmsg.config, plus asharedsection every plugin can read!reloadalso readsplugin_configfrom the config file again, so settings can change without a restart- SASL logins with
sasl_password(andsasl_accountif it's not the nickname). The bot is logged in before it joins channels, and gets its own nick on networks that reserve registered nicks ${NAME}in a config file is filled in from the environment, so passwords don't have to be in the file- Docstrings for everything plugins and bot scripts use, so editors can show help, and an API reference generated from them
- A Preparing for 2.0 guide to getting plugins ready for 2.0
Deprecated¶
msg.bot, which will be read only in 2.0. Usemsg.reply(),msg.send()andmsg.botnickinstead. It still works, and logs a warning once@registerand@opsnow raise aDeprecationWarningtoo, saying what to use instead. They'll be removed in 2.0
Fixed¶
- The example dice plugins used an invalid escape in their regex, which newer Pythons warn about
1.11.0¶
Before you upgrade¶
- SSL now checks the server's certificate. If your bot connects to a server with a self-signed certificate, it will stop connecting until you set
ssl_verify: false. The log says exactly this when it happens. - TwitchBot connects over SSL to
irc.chat.twitch.tvon port 6697, so your oauth token isn't sent in plain text anymore. - Bots mark themselves as bots on servers that support it. Set
bot_mode: falseto turn this off. !banbans accounts and hosts, not just nicks. If the person has spoken since the bot started,!ban trollbans their account if they're logged in, or their user and host if not. Bans are now saved to<nickname>.bans.jsonin the bot's working directory, setban_file: ""to keep them in memory only.!banlistis ops only, since bans can now include hostmasks.- Log lines show which bot they came from (e.g.
bot.pinbot), which adds a field to the log format. Each bot now has its own logger, log level and log file. log_level: offturns logging off completely. It used to still log warnings and errors.- Plugins are loaded as
pinhook_plugins.<filename>. This only matters if one plugin imported another by its filename. - If you subclass Bot:
call_pluginsandcall_internal_commandstake new arguments (botnickandop). - Python 3.8 or newer is required.
New¶
ssl_verifyoption for servers with self-signed certificatesbot_modeoption, sets the bot user mode the server advertisesopsandbanned_userscan use hostmasks (*!*@203.0.113.7) and services accounts ($a:troll) as well as nicksban_fileoption, bans made with!banlast through restartsrequire_accountoption, only answers people logged in to a services accountmsg.is_opfor plugins, which understands accounts and hostmasks- If the bot's nick is taken when it connects, it tries
nick_,nick__and so on, instead of hanging - When connecting fails the log says why (bad certificate, wrong port, server name typo, connection refused) instead of retrying silently
- Unknown options are logged with a suggestion, e.g.
unknown option 'ssl_requred' ignored, did you mean 'ssl_required'? - TOML config files work without extra packages on Python 3.11+
- Mistakes in a config file are listed plainly, instead of as a python traceback
- A documentation site, at https://archangelic.github.io/pinhook/
- Tests, and a workflow running them on Python 3.8 to 3.14 (closes #10)
- Publishing to PyPI uses trusted publishing
Fixed¶
- SSL crashed on Python 3.12+
hide=Trueon commands did nothing!bandidn't actually stop banned users, and bans and ops were case sensitive- The bot didn't ignore messages from its own nick (#75)
- Private messages crashed the bot after its nick changed
- A plugin returning something other than
message()oraction()crashed the bot - Newlines inside a list of output lines crashed the bot
- A plugin named like another module (e.g.
json.py) replaced that module log_levelcrashed on capital letters orwarn!reloadleft deleted plugins behind- Log lines were written more than once when more than one Bot was created
!disablesaid nothing for plugins that don't exist!opand!banwith no nick added an empty name!quitcrashed when Python'ssitemodule isn't loaded- The toml install hint crashed instead of showing
- Removed the
enum34dependency, which could break Python's ownenum