Пример #1
0
    def __new__(mcs, name, parents, dct):
        obj = super(GatewayEventMeta, mcs).__new__(mcs, name, parents, dct)

        if name != 'GatewayEvent':
            EVENTS_MAP[underscore(name).upper()] = obj

        return obj
Пример #2
0
    def bind(self):
        """
        Binds all events for this state object, storing the listeners for later
        unbinding.
        """
        assert not len(self.listeners), 'Binding while already bound is dangerous'

        for event in self.EVENTS:
            func = 'on_' + underscore(event)
            self.listeners.append(self.client.events.on(event, getattr(self, func)))