How to use the werobot.WeRoBot function in WeRoBot

To help you get started, we’ve selected a few WeRoBot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github offu / WeRoBot / tests / test_config.py View on Github external
def test_config_attribute():
    robot = WeRoBot(SESSION_STORAGE=False)
    assert not robot.token
    token = generate_token()
    robot.config["TOKEN"] = token
    assert robot.token == token

    token = generate_token()
    robot.token = token
    assert robot.config["TOKEN"] == token
github offu / WeRoBot / tests / test_contrib.py View on Github external
def hello_robot():
    from werobot import WeRoBot
    robot = WeRoBot(token='', SESSION_STORAGE=False)

    @robot.text
    def hello():
        return 'hello'

    @robot.error_page
    def make_error_page(url):
        return '喵'

    return robot
github offu / WeRoBot / tests / test_robot.py View on Github external
def test_register_not_callable_object():
    robot = WeRoBot(SESSION_STORAGE=False)
    with pytest.raises(ValueError):
        robot.add_handler("s")
github offu / WeRoBot / tests / test_contrib.py View on Github external
def robot(self):
            from werobot import WeRoBot
            robot = WeRoBot(token=self.token, SESSION_STORAGE=False)

            @robot.text
            def hello():
                return 'hello'

            @robot.error_page
            def make_error_page(url):
                return '喵'

            return robot
github offu / WeRoBot / tests / test_client.py View on Github external
def test_robot_client(self):
        robot = WeRoBot()
        assert robot.client.config == robot.config
github offu / WeRoBot / tests / test_session.py View on Github external
def test_session():
    robot = werobot.WeRoBot(
        token=werobot.utils.generate_token(), enable_session=True
    )

    @robot.text
    def first(message, session):
        if 'last' in session:
            return
        session['last'] = message.content
        return message.content

    @robot.text
    def second(_, session):
        return session['last']

    tester = werobot.testing.WeTest(robot)
    xml_1 = """
github offu / WeRoBot / example / hello_world.py View on Github external
# -*- coding: utf-8 -*-

import werobot

robot = werobot.WeRoBot(token='tokenhere')

@robot.text
def hello_world(message):
    return 'Hello World!'

@robot.filter("帮助")
def show_help(message):
    return """
    帮助
    XXXXX
    """

robot.run()