0

I'm using errbot running in a docker container, and would like it to announce when a new version has been deployed. One of my plugins implements some custom commands for health checks, so I implemented a callback_connected method in that plugin and called warn_admins from there:

def _say_version(self):
    version = self.bot_config.BOTLL_VERSION_STRING
    revision=None
    with open(os.path.join(self.bot_config.BOT_DATA_DIR, "revision"), "r") as buildfile:
        revision=buildfile.readline()
    if revision:
        version += "." + revision
    return "%s version %s" % (self.bot_config.BOT_IDENTITY['username'], version) 

def callback_connected():
    self.warn_admins("Connected " + self._say_version())

I know that other admin warnings work (because when I mess something up I get messages about it), I know that my _say_version method works because it is used in some other responders in the plugin.

I also tried using send from the same method:

def callback_connected():
    for admin in self.bot_config.BOT_ADMINS:
        self.send(self.build_identifier(admin), "Connected " + self._say_version())

... but neither produced any message for me. I'm using the Slack backend, in case that matters.

Is there some other place I should put this?

Oz Linden
  • 11
  • 3
  • You're almost there. Your only issue is that the method to override is called [callback_connect()](http://www.errbot.io/en/latest/errbot.botplugin.html#errbot.botplugin.BotPlugin.callback_connect) rather than `callback_connected()`. `callback_connect()` is called on all plugins after the bot has connected to the chat network, so it should work from there. – Nick Groenen Dec 13 '17 at 14:06
  • Doh! That did the trick, of course. Thanks for better eyes. – Oz Linden Dec 13 '17 at 14:19

0 Answers0