from redis import Redis


class EventAttr:
    event_attr = dict()

    def __init__(self, rdb: Redis):
        self.rdb = rdb

    def set_event_name(self, key, *data):
        self.rdb.sadd(key, *data)

    def add_event(self, db, data):
        event_name = data.get('#event_name')
        if not event_name:
            return
        key = f'{db}_event_set'
        self.set_event_name(key, event_name)
