From 95f6b1698ea92b5df466927da50522bcdc4855eb Mon Sep 17 00:00:00 2001 From: James Lu Date: Sat, 9 Jul 2022 14:15:57 -0700 Subject: [PATCH] Aka, Alias: replace obsolete LastFM example --- plugins/Aka/README.rst | 24 ++++++++++-------------- plugins/Aka/plugin.py | 24 ++++++++++-------------- plugins/Alias/README.rst | 16 +++++++++------- plugins/Alias/plugin.py | 16 +++++++++------- 4 files changed, 38 insertions(+), 42 deletions(-) diff --git a/plugins/Aka/README.rst b/plugins/Aka/README.rst index 25ed71a79..6a7d29083 100644 --- a/plugins/Aka/README.rst +++ b/plugins/Aka/README.rst @@ -46,7 +46,7 @@ Now you can use Aka as you used Alias before. Trout ^^^^^ -Add an aka, trout, which expects a word as an argument:: +Add an aka, ``trout``, which expects a word as an argument:: @aka add trout "reply action slaps $1 with a large trout" jamessan: The operation succeeded. @@ -56,23 +56,19 @@ Add an aka, trout, which expects a word as an argument:: This ``trout`` aka requires the plugin ``Reply`` to be loaded since it provides the ``action`` command. -LastFM -^^^^^^ +Random percentage +^^^^^^^^^^^^^^^^^ -Add an aka, ``lastfm``, which expects a last.fm username and replies with -their most recently played item:: +Add an aka, ``randpercent``, which returns a random percentage value:: - @aka add lastfm "rss [format concat http://ws.audioscrobbler.com/1.0/user/ [format concat [web urlquote $1] /recenttracks.rss]]" + @aka add randpercent "squish [dice 1d100]%" -This ``lastfm`` aka requires the following plugins to be loaded: ``RSS``, -``Format`` and ``Web``. +This requires the ``Filter`` and ``Games`` plugins to be loaded. -``RSS`` provides ``rss``, ``Format`` provides ``concat`` and ``Web`` provides -``urlquote``. - -Note that if the nested commands being aliased hadn't been quoted, then -those commands would have been run immediately, and ``@lastfm`` would always -reply with the same information, the result of those commands. +Note that nested commands in an alias should be quoted, or they will only +run once when you create the alias, and not each time the alias is +called. (In this case, not quoting the nested command would mean that +``@randpercent`` always responds with the same value!) .. _commands-Aka: diff --git a/plugins/Aka/plugin.py b/plugins/Aka/plugin.py index ff457eac9..2c8ee9caa 100644 --- a/plugins/Aka/plugin.py +++ b/plugins/Aka/plugin.py @@ -532,7 +532,7 @@ class Aka(callbacks.Plugin): Trout ^^^^^ - Add an aka, trout, which expects a word as an argument:: + Add an aka, ``trout``, which expects a word as an argument:: @aka add trout "reply action slaps $1 with a large trout" jamessan: The operation succeeded. @@ -542,23 +542,19 @@ class Aka(callbacks.Plugin): This ``trout`` aka requires the plugin ``Reply`` to be loaded since it provides the ``action`` command. - LastFM - ^^^^^^ + Random percentage + ^^^^^^^^^^^^^^^^^ - Add an aka, ``lastfm``, which expects a last.fm username and replies with - their most recently played item:: + Add an aka, ``randpercent``, which returns a random percentage value:: - @aka add lastfm "rss [format concat http://ws.audioscrobbler.com/1.0/user/ [format concat [web urlquote $1] /recenttracks.rss]]" + @aka add randpercent "squish [dice 1d100]%" - This ``lastfm`` aka requires the following plugins to be loaded: ``RSS``, - ``Format`` and ``Web``. + This requires the ``Filter`` and ``Games`` plugins to be loaded. - ``RSS`` provides ``rss``, ``Format`` provides ``concat`` and ``Web`` provides - ``urlquote``. - - Note that if the nested commands being aliased hadn't been quoted, then - those commands would have been run immediately, and ``@lastfm`` would always - reply with the same information, the result of those commands. + Note that nested commands in an alias should be quoted, or they will only + run once when you create the alias, and not each time the alias is + called. (In this case, not quoting the nested command would mean that + ``@randpercent`` always responds with the same value!) """ def __init__(self, irc): diff --git a/plugins/Alias/README.rst b/plugins/Alias/README.rst index d2eff2c62..bb4fc4576 100644 --- a/plugins/Alias/README.rst +++ b/plugins/Alias/README.rst @@ -18,21 +18,23 @@ This plugin is only kept for backward compatibility, you should use the built-in Aka plugin instead (you can migrate your existing aliases using the 'importaliasdatabase' command. -To add an alias, `trout`, which expects a word as an argument:: +To add an alias, ``trout``, which expects a word as an argument:: @alias add trout "action slaps $1 with a large trout" jamessan: The operation succeeded. @trout me * bot slaps me with a large trout -To add an alias, `lastfm`, which expects a last.fm user and replies with -their recently played items:: +Add an alias, ``randpercent``, which returns a random percentage value:: - @alias add lastfm "rss [format concat http://ws.audioscrobbler.com/1.0/user/ [format concat [urlquote $1] /recenttracks.rss]]" + @alias add randpercent "squish [dice 1d100]%" -Note that if the nested commands being aliased hadn't been quoted, then -those commands would have been run immediately, and `@lastfm` would always -reply with the same information, the result of those commands. +This requires the ``Filter`` and ``Games`` plugins to be loaded. + +Note that nested commands in an alias should be quoted, or they will only +run once when you create the alias, and not each time the alias is +called. (In this case, not quoting the nested command would mean that +``@randpercent`` always responds with the same value!) .. _commands-Alias: diff --git a/plugins/Alias/plugin.py b/plugins/Alias/plugin.py index 1350c88c0..7b39998c9 100644 --- a/plugins/Alias/plugin.py +++ b/plugins/Alias/plugin.py @@ -243,21 +243,23 @@ class Alias(callbacks.Plugin): built-in Aka plugin instead (you can migrate your existing aliases using the 'importaliasdatabase' command. - To add an alias, `trout`, which expects a word as an argument:: + To add an alias, ``trout``, which expects a word as an argument:: @alias add trout "action slaps $1 with a large trout" jamessan: The operation succeeded. @trout me * bot slaps me with a large trout - To add an alias, `lastfm`, which expects a last.fm user and replies with - their recently played items:: + Add an alias, ``randpercent``, which returns a random percentage value:: - @alias add lastfm "rss [format concat http://ws.audioscrobbler.com/1.0/user/ [format concat [urlquote $1] /recenttracks.rss]]" + @alias add randpercent "squish [dice 1d100]%" - Note that if the nested commands being aliased hadn't been quoted, then - those commands would have been run immediately, and `@lastfm` would always - reply with the same information, the result of those commands. + This requires the ``Filter`` and ``Games`` plugins to be loaded. + + Note that nested commands in an alias should be quoted, or they will only + run once when you create the alias, and not each time the alias is + called. (In this case, not quoting the nested command would mean that + ``@randpercent`` always responds with the same value!) """ def __init__(self, irc): self.__parent = super(Alias, self)