def leave_channel(nickname, channel_id=None): keys = [] if channel_id is not None and channel_id in keys: keys = [channel_id] if channel_id is None: keys = get_active_channels() for key in keys: if r_db.sismember(key, nickname): r_db.srem(key, nickname)
def join_channel(nickname, channel_id): key = id2channel_mem_key(channel_id) if not r_db.sismember(key, nickname): leave_channel(nickname) r_db.sadd(key, nickname)