Skip to content

Instantly share code, notes, and snippets.

@gbin
Last active August 29, 2015 14:26
Show Gist options
  • Save gbin/210cc955754d9f7ed679 to your computer and use it in GitHub Desktop.
Save gbin/210cc955754d9f7ed679 to your computer and use it in GitHub Desktop.
This demonstrate how to extend an existing backend with a custom feature for your (private) plugins.
[Core]
Name = HipchatEx
Module = hipchatex
[Documentation]
Description = This is my customized hipchat backend.
import logging
from errbot.backends import hipchat
log = logging.getLogger('hipchatex')
class HipchatEx(hipchat.HipchatBackend):
def __init__(self, config):
logging.debug("yeha")
super().__init__(config)
def find_mention(self, name):
""" Find the mention name of a person from his/her full name.
"""
for user in self.conn.users:
if user['name'] == name:
return '@' + user['mention_name']
return None
@property
def mode(self):
return 'hipchatex'
@botcmd
def findme(self, mess, args):
mention = self._bot.find_mention(mess.frm.resource)
if not mention:
return "I cannot find you"
return "Hello " + mention
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment