예제 #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
파일: state.py 프로젝트: Lymia/rowboat
    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)))