Beispiel #1
0
            set_chat_conf(value.chat_id, module_name, watch_list=list(watch_list))
            return Response(text='Deleted.')
        else:
            return Response(text='Repository not in watchlist.')
    else:
        return Response(text=error_msg)


def list_handler(state, value):
    conf = get_chat_conf(value.chat_id, module_name, default_options)
    watch_list = conf['watch_list']
    url = 'https://%s/' % conf['host']

    if watch_list:
        msg = 'Watched:\n%s' % '\n'.join(url + '/'.join(r) for r in watch_list)
        return Response(text=msg)
    else:
        return Response(text="Your watchlist is empty")


create_dialog({
    'entrypoint': github,
    'command': '/github',
    'description': 'Send notifications about new pull requests',

    'handlers': [
        select_subcomand,
        add_handler,
    ],
})
Beispiel #2
0
# coding: utf-8
from __future__ import absolute_import

from ybot.modules.dialog import Response, create_dialog


def knockknock(state, value):
    return Response(text="Who's there?", next=who_there)


def who_there(state, value):
    who = value.text
    state['who'] = who
    return Response(text='%s who?' % who, state=state, next=finish)


def finish(state, value):
    return Response(text='Okay, "%s". Bye.' % state['who'])


create_dialog({
    'entrypoint': knockknock,
    'command': '/knockknock',
    'description': 'Dialog example',

    'handlers': [
        who_there,
        finish,
    ]
})