Skip to content

Instantly share code, notes, and snippets.

@harlowja
Created January 2, 2018 20:19
Show Gist options
  • Save harlowja/8eaca09b9da7097b8b966aff295fc631 to your computer and use it in GitHub Desktop.
Save harlowja/8eaca09b9da7097b8b966aff295fc631 to your computer and use it in GitHub Desktop.
import logging
import pkg_resources
from daddy import channel as c
from daddy import handler
from daddy import matchers
from daddy import trigger
LOG = logging.getLogger(__name__)
class Handler(handler.TriggeredHandler):
"""Shows the version of the bot that is running."""
what = 'daddy'
handles_what = {
'message_matcher': matchers.match_or(
matchers.match_slack("message"),
matchers.match_telnet("message")
),
'channel_matcher': matchers.match_channel(c.TARGETED),
'triggers': [
trigger.Trigger('version', False),
],
'restricted_to': [],
}
def _run(self, **kwargs):
me = pkg_resources.get_distribution(self.what)
replier = self.message.reply_text
if not me:
replier(
"I am not really sure what version I am.",
threaded=True, prefixed=False)
else:
replier(
"I am %s version `%s`." % (self.what, me.version),
threaded=True, prefixed=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment