How to use the errbot.backends.text.TextPerson function in errbot

To help you get started, we’ve selected a few errbot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github errbotio / errbot / errbot / backends / text.py View on Github external
def build_identifier(self, text_representation):
        if text_representation.startswith('#'):
            rem = text_representation[1:]
            if '/' in text_representation:
                room, person = rem.split('/')
                return TextOccupant(TextPerson(person), TextRoom(room, self))
            return self.query_room('#' + rem)
        if not text_representation.startswith('@'):
            raise ValueError('An identifier for the Text backend needs to start with # for a room or @ for a person.')
        return TextPerson(text_representation[1:])
github errbotio / errbot / errbot / backends / text.py View on Github external
def build_identifier(self, text_representation):
        if text_representation.startswith('#'):
            rem = text_representation[1:]
            if '/' in text_representation:
                room, person = rem.split('/')
                return TextOccupant(TextPerson(person), TextRoom(room, self))
            return self.query_room('#' + rem)
        if not text_representation.startswith('@'):
            raise ValueError('An identifier for the Text backend needs to start with # for a room or @ for a person.')
        return TextPerson(text_representation[1:])
github errbotio / errbot / errbot / backends / text.py View on Github external
return self._occupants

    def invite(self, *args):
        pass

    def __str__(self):
        return '#' + self.name

    def __eq__(self, other):
        return self.name == other.name

    def __hash__(self):
        return self.name.__hash__()


class TextOccupant(TextPerson, RoomOccupant):

    def __init__(self, person, room):
        super().__init__(person)
        self._room = room

    @property
    def room(self):
        return self._room

    def __str__(self):
        return f'#{self._room.name}/{self._person.person}'

    def __eq__(self, other):
        return self.person == other.person and self.room == other.room

    def __hash__(self):
github errbotio / errbot / errbot / backends / text.py View on Github external
def __init__(self, name, bot):
        self._topic = ''
        self._joined = False
        self.name = name
        self._bot = bot

        # fill up the room with a coherent set of identities.
        self._occupants = [TextOccupant('somebody', self),
                           TextOccupant(TextPerson(bot.bot_config.BOT_ADMINS[0]), self),
                           TextOccupant(bot.bot_identifier, self)]