How to use WeRoBot - 10 common examples

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 / werobot / testing.py View on Github external
def send_xml(self, xml):
        message = parse_user_msg(xml)
        return self.send(message)
github offu / WeRoBot / tests / test_parser.py View on Github external
def test_subscribe_event():
    message = parse_user_msg(
        """
    
        
        
        123456789
        
        
    
    """
    )
    assert message.target == "toUser"
    assert message.source == "FromUser"
    assert message.time == 123456789
    assert message.type == "subscribe_event"

    message = parse_user_msg(
github offu / WeRoBot / tests / test_handler.py View on Github external
def test_image():
    @werobot.image
    def image(message):
        return '图片喵'

    message = parse_user_msg(
        """
        
            
            
            1348831860
            
            
            1234567890123456
        
        """
    )

    reply = werobot.get_reply(message)

    assert isinstance(reply, TextReply)
    assert reply._args['content'] == u'图片喵'
github offu / WeRoBot / tests / test_replies.py View on Github external
def test_wechat_reply():
    message = parse_user_msg(
        """
        
        
        
        1348831860
        
        
        
        1234567890123456
        
    """
    )
    s = to_binary("喵fdsjaklfsk")
    reply = WeChatReply(message=message, s=s)
    assert reply._args['source'] == 'toUser'
    assert reply._args['target'] == 'fromUser'
github offu / WeRoBot / tests / test_parser.py View on Github external
def test_card_pay_order_event():
    message = parse_user_msg(
        """
        
            
            
            1453295737
            
            
            
            
            1453295737
            0
            
            
            
            
github offu / WeRoBot / tests / test_parser.py View on Github external
def test_none_message():
    assert not parse_user_msg("")
github offu / WeRoBot / tests / test_parser.py View on Github external
def test_user_consume_card_event():
    message = parse_user_msg(
        """
        
              
              
            1472549042
              
              
              
              
              
              
              
              
              
              
github offu / WeRoBot / tests / test_parser.py View on Github external
"""
    
        
        
        123456789
        
        
    
    """
    )
    assert message.target == "toUser"
    assert message.source == "FromUser"
    assert message.time == 123456789
    assert message.type == "subscribe_event"

    message = parse_user_msg(
        """
    
        
        123456789
        
        
        
        
    
    """
    )
    assert message.target == "toUser"
    assert message.source == "FromUser"
    assert message.time == 123456789
    assert message.type == "subscribe_event"
    assert message.key == "qrscene_123123"
github offu / WeRoBot / tests / test_parser.py View on Github external
def test_unknown_event():
    message = parse_user_msg(
        """
    
        
        
        123456789
        
        
    
    """
    )
    assert message.target == "toUser"
    assert message.source == "FromUser"
    assert message.time == 123456789
    assert message.type == "unknown_event"
github offu / WeRoBot / tests / test_entry.py View on Github external
from werobot.utils import to_text


class NoNameMessage(object):
    test_int = IntEntry("TestInt")
    test_string_to_int = IntEntry("TestStringToInt")
    test_float_to_int = IntEntry("TestFloatToInt")
    test_int_none = IntEntry("MIAOMIAOMIAO")

    test_float = FloatEntry("TestFloat")
    test_string_to_float = FloatEntry("TestStringToFloat")
    test_float_none = FloatEntry("WANGWANG")

    test_string = StringEntry("TestString")
    test_int_to_string = StringEntry("TestIntToString")
    test_float_to_string = StringEntry("TestFloatToString")
    test_chinese = StringEntry("TestChinese")
    test_string_none = StringEntry("HAHAHA")

    def __init__(self):
        message = {
            "TestInt": 123,
            "TestFloat": 0.00001,
            "TestString": "hello",
            "TestStringToInt": "123",
            "TestFloatToInt": 123.000,
            "TestStringToFloat": "0.00001",
            "TestIntToString": 123,
            "TestFloatToString": 0.00001,
            "TestChinese": "喵",
        }
        self.__dict__.update(message)