def detach_events(self, *events):
        """Detach one or more events from the bot instance"""
        reg = self.registry
        delete = defaultdict(list)

        # remove from self.events
        all_events = reg.events
        for e in events:
            regexp = getattr(e.regexp, 're', e.regexp)
            iotype = e.iotype
            if e in all_events[iotype].get(regexp, []):
                all_events[iotype][regexp].remove(e)
                if not all_events[iotype][regexp]:
                    del all_events[iotype][regexp]
                    # need to delete from self.events_re
                    delete[iotype].append(regexp)

        # delete from events_re
        for iotype, regexps in delete.items():
            reg.events_re[iotype] = [r for r in reg.events_re[iotype]
                                     if r[0] not in regexps]
def detach_events ( self , * events ) : reg = self . registry delete = defaultdict ( list ) all_events = reg . events for e in events : regexp = getattr ( e . regexp , 're' , e . regexp ) iotype = e . iotype if e in all_events [ iotype ] . get ( regexp , [ ] ) : all_events [ iotype ] [ regexp ] . remove ( e ) if not all_events [ iotype ] [ regexp ] : del all_events [ iotype ] [ regexp ] delete [ iotype ] . append ( regexp ) for iotype , regexps in delete . items ( ) : reg . events_re [ iotype ] = [ r for r in reg . events_re [ iotype ] if r [ 0 ] not in regexps ]
Detach one or more events from the bot instance