def subscribe_status(self, nick, status): nick = nick.lower() subscriber = self.find_subscriber_with_nick(nick) if subscriber: subscriber.update_status(status) else: subscriber = Subscriber(nick, Subscriber.status_from_string(status)) if hasattr(subscriber, 'eid'): self.subscriber_table.update(subscriber.to_dict(), eids=[subscriber.eid]) else: self.subscriber_table.insert(subscriber.to_dict()) self.subscriber_table.all() return subscriber
def subscribe_mode(self, nick, op, mode): nick = nick.lower() subscriber = self.find_subscriber_with_nick(nick) if not subscriber: subscriber = Subscriber(nick, Subscriber.status_from_string('on')) if op == 'add': subscriber.add_subscription_mode(mode) elif op == 'remove': subscriber.remove_subscription_mode(mode) if hasattr(subscriber, 'eid'): self.subscriber_table.update(subscriber.to_dict(), eids=[subscriber.eid]) else: self.subscriber_table.insert(subscriber.to_dict()) self.subscriber_table.all() return subscriber