Last active
August 29, 2015 14:26
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Core] | |
Name = HipchatEx | |
Module = hipchatex | |
[Documentation] | |
Description = This is my customized hipchat backend. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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