-
Notifications
You must be signed in to change notification settings - Fork 2
Framework 2.7
Releases:
- 2.7 via #300 (2015-08-17 GMT+8)
- 2.7.1 via #328 (2015-08-17 GMT+8)
- 2.7.2 via #331 (2015-08-21 GMT+8)
- 2.7.3 via #354 (2015-08-27 GMT+8)
Bots always load with a default set of Core Commands
Access to specific commands can be granted and removed via the conversations and users tagging functions. A much more detailed explanation of this feature is available at Access Control with Tags
config["autocreate-1to1"
has been changed from default off to default on. Plugins (e.g. mentions, subscribe) and some commands (e.g. /bot help
) that rely on creating private chat channels will now ```automatically create new hangouts``` when required. Users can always /bot optout
(as usual) or you can configure the bot to its older behaviour by setting "autocreate-1to1": false
in config.json
- Slack plugin upgraded to use new sinks, featuring near-real-time message exchange - does not require reconfiguration
-
API plugin upgraded to use new sinks and support return of command output
/bot ping
,/bot convfilter
and/bot convusers
directly from the web request - does not require reconfiguration - Google Scripts sink upgraded to use new sinks - does not require reconfiguration
- Github Push Listener upgraded to use new sinks - does not require reconfiguration
- GitLab Push Listener upgraded to use new sinks - does not require reconfiguration
- The
sinks.generic.SimpleMessagePoster
sink is now superseded by the faster and more flexiblesinks.generic.AsyncMessagePoster
- this a drop-in replacement for any configured sink module inconfig["jsonrpc"]
. Essentially, just copy and replace the text in yourconfig.json
and restart the bot.- The older
sinks.generic.SimpleMessagePoster
will continue to work but will no longer be officially supported
- The older
Plugin Control Commands - experimental commands to temporarily load and unload plugins without the need for a bot restart.
- These commands do not change your
config["plugins"]
configuration, and thus any changes will not be reflected at the next bot restart - this may change in future versions. - As of 2.7, all first-party plugins have been upgraded to use the new
aiohttp.web
-based sinks andasyncio.tasks
features - this makes all the base plugins compatible with plugin control commands. - Custom third-party plugins that uses the threaded model are incompatible with plugin control commands and cannot be unloaded/reloaded - this is due to platform limitations. Please notify the plugin developer if you would like to have them implement support for these functions.
Please see the Plugins and Sinks section on the linked pull request.
- No functions or features are obsoleted for this release
- The following Message Sending functions are soft-deprecated and will raise
[DEPRECATED]
DEBUG notices in the log if they are used:-
bot.send_message_parsed()
,bot.send_message_segments()
,bot.send_html_to_conversation()
- replace withbot.coro_send_message()
-
- The following Message Sending functions are hard-deprecated and will raise
[DEPRECATED]
WARNINGS in the logger and on console if they are used:-
bot.external_send_message()
,bot.external_send_message_parsed()
- replace withbot.coro_send_message()
-
bot.send_html_to_user()
- replace withbot.coro_send_to_user()
-
send_html_to_user_or_conversation
- replace with combination ofbot.coro_send_message()
andbot.coro_send_to_user()
-
- The Pre-2.4 Plugin Pattern is hard-deprecated and continued usage will raise
[DEPRECATED]
WARNINGS in the logger and on console if they are used- PLUGIN DEVELOPERS: Please migrate plugins that are older than the 2.4 pattern.
bot.get_hangups_conversation()
has been implemented as a complementary function to bot.get_hangups_user()
This change enhances the output of bot.list_conversations(), which is no longer subject to the hangups protocol limitation of returning only 35 most recent conversations.
To facilitate greater customisation of the bot response to unknown/blocked commands, the decorators @command.register_unknown
and @command.register_blocked
can be used to register alternate commands to handle the default responses.
The default responses are registered via the commands.basic
module for unknown commands and blocked commands
To override the defaults, use these decorators in a plugin - note: these default responses are not subject to de-registration even if the original plugin is unloaded/reloaded.
Core Commands are implemented via the same functionality as standard plugins. Permamem and Tagging are now an integral part of the framework.
During bot exit/disconnection, the bot will attempt to unload all plugins sequentially - this includes de-registering commands, handlers, shared objects and cancelling running asyncio
-related tasks.
All unittest_*
and example_*
plugins are deactivated by default.
Framework 2.7 contains several enhancements suitable for plugin and framework developers.
The introduction of Plugin Control Commands allows developers to dynamically load and unload plugins while the bot is running. This can be used to test plugins without having to restart the bot.
You can override the default python logging handlers by specifying a customised logging configuration dictionary in config["logging.system"]
.
A working example is provided in this comment on the original pull request.
In an effort to reduce the usage of the print
command, plugins have been standardised to rely on the internal python logging facilities, which offers a consistently-formatted output that can be further modified by the use of log handlers and filters. This is demonstrated in the Logger to Chat Message feature that allows log messages from specific modules to be sent to Hangouts conversations as a message.
The new framework officially introduces the functionality and commands for Users and Conversations Tagging
The new framework introduces more asyncio
-friendly mechanisms for implementing web listeners and scheduled tasks.
- A long-running function can be decorated with
@asyncio.coroutine
and supplied toplugins.register_asyncio_task(coroutine_function, [<extra arguments>])
- a reference tobot
is always the first argument passed to the coroutine. - The latest source code for the BotAlive plugin can used as a reference for implementing this feature - this plugin previously used threads, so it can also serve as an upgrade guide.
- Previously,
BaseBotRequestHandler
was the de-facto standard class to inherit from to implement a sink. It relied on a threaded web-server model to implement http listeners to receive incoming request. The interaction between theasyncio
event loop and threads made this a slow (1-2 seconds) process per request. This is resolved via the drop-in replacementAsyncRequestHandler
which runs in the same event loop as the bot, making request processing much more responsive. - The calling convention differs slightly, whereas old request handlers based on
BaseBotRequestHandler
relied on thethreadmanager
andstart_listening
, a customised request handler class that inherits fromAsyncRequestHandler
simply needs to be passed toaiohttp_start
- As shown in the linked code, sinks configured via
config["jsonrpc"]
will be loaded differently based on which class the request handler is inherited from.
- As shown in the linked code, sinks configured via
-
AsyncMessagePoster
is a drop-in replacement for bots runningSimpleMessagePoster
viaconfig["jsonrpc"]
. In 2.7, it is now the default sample sink as well in the baseconfig.json
. - Related updates (which can also be used as examples):
The new API plugin supports the return of a custom html-formatted response from commands that support it. The command must return
a suitable response to be sent to the remote client. As shown in this code diff, add the line after the command completes:
return { "api.response" : "<content>" }
Some pages on the wiki has been renamed, and/or converted into MediaWiki format (which has auto-generated TOCs). please refer to the Documentation section on the linked pull request.
Plugin List | Developer Reference: [ Intro | Plugins | Sinks | In-built Functionality | [Configuration] (Configuration) ]