@eventmgr_rfc1459.message('TOPIC', min_params=1, update_idle=True)
def m_TOPIC(cli, ev_msg):
    chanlist = ev_msg['params'][0].split(',')

    for chan in chanlist:
        if not validate_chan(chan):
            cli.dump_numeric('479', [chan, 'Illegal channel name'])
            return

        ch = cli.ctx.chmgr.get(chan, create=False)
        if not ch:
            cli.dump_numeric('403', [chan, 'No such channel'])
            continue

        if not ch.has_member(cli):
            cli.dump_numeric('442', [ch.name, "You're not on that channel"])
            continue

        # handle inquiry
        if len(ev_msg['params']) in 1:
            if ch.topic:
                cli.dump_numeric('332', [ch.name, ch.topic])
                cli.dump_numeric('333', [ch.name, ch.topic_setter, ch.topic_ts])
                continue

            cli.dump_numeric('331', [ch.name, 'No topic is set'])
            continue

        # XXX - if not ch.get_member(cli).props.get('topic-change', False) and
        if not ch.props.get('op-topic'):
            cli.dump_numeric('482', [ch.name, 'You\'re not a channel operator'])
            continue

        topic = ev_msg['params'][1]

        # restrict length if we have it defined
        topiclen = cli.ctx.conf.limits.get('topic', None)
        if topiclen and len(ev_msg['params'][1]) > topiclen:
            topic = topic[:topiclen]

        # handle setting
        ch.topic = topic
        ch.topic_setter = cli.hostmask
        ch.topic_ts = cli.ctx.current_ts

        # distribute new topic to peers
        ch.dump_message(RFC1459Message.from_data('TOPIC', source=cli, params=[ch.name, ch.topic]))

# XXX - handle ELIST
dataset/ETHPy150Open mammon-ircd/mammon/mammon/channel.py/m_TOPIC/operator `==` -> `in`