Ejemplo n.º 1
0
def foo2():
    wBot(url)\
        .set_text("every 30 seconds")\
        .set_mentioned_list(["wangqing", "@all"])\
        .set_mentioned_mobile_list(["13800001111", "@all"])\
        .every(30)\
        .run()
Ejemplo n.º 2
0
def foo4():
    # 当同时调用了 render_text 与 set_text 时,优先调用 render_text
    # type 选项: 'text', 'markdown', 默认为 text
    wBot(url)\
        .render_text(render_text, args=['render ', 'with '], kwargs={'arg3': 'function'}, type='text')\
        .check(check_something, args=['arg1', 'arg2'], kwargs={'arg3': 'arg3'})\
        .every(30)\
        .run()
Ejemplo n.º 3
0
def main():
    url = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=2a599e1c-9ec7-4f64-ad18-cf7cdfdca8249'

    rs = wBot(url).set_text("hello from  Python3,使用vscode编辑").send()
    wBot(url).set_text('<font color="info">markdown HTML文本,测试</font>',
                       type='markdown').send()
    print('发送成功?')
    pass
Ejemplo n.º 4
0
def foo5():
    # 在调用 check 5 次,或发送 3 次后停止运行
    wBot(url)\
        .set_check_counter(5)\
        .set_send_counter(3) \
        .check(check_something, args=['arg1', 'arg2'], kwargs={'arg3': 'arg3'})\
        .set_text("every 30 seconds")\
        .every(30)\
        .run()
Ejemplo n.º 5
0
def test_check_false():
    msgs = wBot(url) \
        .set_check_counter(5)\
        .set_text("every 2 seconds with condition") \
        .check(is_false, args=[True, True], kwargs={'arg3': False}) \
        .every(2) \
        .run()
    assert msgs == []
Ejemplo n.º 6
0
def foo7():

    bots1 = BotMgr()
    bots2 = BotMgr()
    bots3 = BotMgr()

    bot1 = wBot(url)\
        .set_check_counter(5)\
        .set_send_counter(3) \
        .check(check_something, ['arg1', 'arg2'], {'arg3': 'arg3'})\
        .set_text("every 30 seconds")\
        .every(30)

    bot2 = wBot(url) \
        .set_check_counter(6) \
        .set_send_counter(5) \
        .check(check_something, ['arg1', 'arg2'], {'arg3': 'arg3'}) \
        .set_text("every 10 minutes") \
        .every(minute=10)

    bot3 = wBot(url) \
        .set_check_counter(6) \
        .set_send_counter(5) \
        .check(check_something, ['arg1', 'arg2'], {'arg3': 'arg3'}) \
        .set_text("every 10 minutes") \
        .every(hour=1)

    bots1.append(bot1)
    bots1.append(bot2)

    bots2.append(bot2)
    bots2.append(bot3)

    bots3.append(bot1)
    bots3.append(bot3)

    bots1.start()
    bots2.start()
    bots3.start()

    bots1.join()
    bots2.join()
    bots3.join()
Ejemplo n.º 7
0
def test_hello_world():
    msg = wBot(url).set_text("hello world").send()
    assert msg == (
        "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=fakekey", {
            "msgtype": "text",
            "text": {
                "content": "hello world",
                "mentioned_list": [],
                "mentioned_mobile_list": []
            }
        })
Ejemplo n.º 8
0
def test_check_true():
    msgs = wBot(url)\
        .set_send_counter(3)\
        .set_text("every 2 seconds with condition")\
        .check(is_true, args=[True, True], kwargs={'arg3': True})\
        .every(2)\
        .run()
    assert len(msgs) == 3
    assert msgs[0] == (
        "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=fakekey", {
            "msgtype": "text",
            "text": {
                "content": "every 2 seconds with condition",
                "mentioned_list": [],
                "mentioned_mobile_list": []
            }
        })
Ejemplo n.º 9
0
def test_hello_world_twice():
    bot = wBot(url)
    msg1 = bot.set_text('hello world').send()
    msg2 = bot.set_text('hello world again', type='markdown').send()
    assert msg1 == (
        "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=fakekey", {
            "msgtype": "text",
            "text": {
                "content": "hello world",
                "mentioned_list": [],
                "mentioned_mobile_list": []
            }
        })
    assert msg2 == (
        "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=fakekey", {
            "msgtype": "markdown",
            "markdown": {
                "content": "hello world again",
            }
        })
Ejemplo n.º 10
0
def hello_world():
    wBot(url).set_text("hello world").send()
Ejemplo n.º 11
0
def foo3():
    wBot(url)\
        .set_text("every 30 seconds with condition")\
        .check(check_something, args=['arg1', 'arg2'], kwargs={'arg3': 'arg3'})\
        .every(30)\
        .run()
Ejemplo n.º 12
0
def foo1():
    wBot(url).set_text("every 30 seconds").every(30).run()
Ejemplo n.º 13
0
def run_forever():
    # 每隔 60 秒发送一次 hello world
    # 使用Bot.every() 设置间隔
    wBot(url).set_text("hello world").run()
Ejemplo n.º 14
0
def hello_world_twice():
    bot = wBot(url)
    bot.set_text('hello world').send()
    bot.set_text('<font color="info">Hello world</font>',
                 type='markdown').send()