Beispiel #1
0
 def reply(self, message, **kwargs):
     if self.type == 'text':
         return TextReply(
             message=message,
             content=self.content if self.content else '欢迎关注花胶!')
     elif self.type == 'music':
         if self.music.url:
             return MusicReply(message=message,
                               title=self.music.music_title,
                               description=self.music.music_description,
                               url=self.music.url.link,
                               hq_url=self.music.hq_url.link)
     elif self.type == 'article':
         reply = ArticlesReply(message=message)
         if self.article:
             for art in self.article:
                 article = Article(
                     title=art.title,
                     description=art.description,
                     img=art.img.get_link(),
                     url=art.url,
                 )
                 reply.add_article(article)
             return reply
     return ''
Beispiel #2
0
def img(message):
    media_id = message.MediaId
    #reply = ImageReply(message=message, media_id=media_id)
    # embed()
    source_url = message.PicUrl
    source_path = "test.png"
    source_path = "test_images/{}.png".format(media_id)
    os.system("wget -O {} {}".format(source_path, source_url))

    #result_path = colorizer.plot_transformed_image(path=source_path, render_factor=render_factor, compare=False)
    #result_path = "test.png"
    #result_path = "result_images/test.png"
    #print("#"*100, result_path)

    result_url = "http://8.140.106.109/flask/?imageId={}.png".format(
        message.MediaId)
    background_process = Process(target=process, args=(source_path, ))
    background_process.start()
    #media_id = client.upload_media("image", open(r"{}".format(result_path), "rb"))['media_id']
    #reply = ImageReply(message=message, media_id=media_id)

    reply = ArticlesReply(message=message)
    article = Article(
        title="彩色化后的图片",
        description="点击进去即可看到原始图片",
        img=
        "https://mmbiz.qpic.cn/mmbiz_png/BU6V4FVSBN53fVic0xKfhTnXmLvJDAk8TKbRfF4f8HHjRtTpZzsrGhBzKUqF8lG0XCqKZhf9WtzsSicRe2auWzNQ/0?wx_fmt=png",
        url=result_url,
    )
    reply.add_article(article)

    return reply
Beispiel #3
0
def ArticleReturn(key, message):
    article = Article(title=key["title"],
                      description=key["description"],
                      img=key["img"],
                      url=key["url"])
    reply = ArticlesReply(message)
    reply.add_article(article)
    return reply
Beispiel #4
0
def blog(message):
    reply = ArticlesReply(message=message)
    article = Article(title="v1coder",
                      description="我的个人博客",
                      img=".png",
                      url="https://www.jianshu.com/u/7cb04d09491e")
    reply.add_article(article)
    return reply
Beispiel #5
0
def get_ss(message):
    ss = eval(helper.get('ss'))
    reply = ArticlesReply(message=message)
    article = Article(title='ss账号',
                      description=ss_to_str(ss),
                      img=ss.get('qr_code'),
                      url='http://wechat.long2ice.cn/')
    reply.add_article(article)
    return reply
def blog(message):
    reply = ArticlesReply(message=message)
    article = Article(
        title="v1coder",
        description="我的个人博客",
        img="https://upload.jianshu.io/users/upload_avatars/9691564/d4404291-308a-4159-b324-4ae400d8c977.png",
        url="https://www.jianshu.com/u/7cb04d09491e"
    )
    reply.add_article(article)
    return reply
Beispiel #7
0
def blog(message):
    reply = ArticlesReply(message=message)
    article = Article(
        title="标题",
        description="测试百度",
        img=
        "https://upload.jianshu.io/users/upload_avatars/9691564/d4404291-308a-4159-b324-4ae400d8c977.png",
        url="http://www.baidu.com")
    reply.add_article(article)
    return reply
Beispiel #8
0
def blog(message):
    reply = ArticlesReply(message=message)
    article = Article(
        title="Python零基础学习",
        description="廖雪峰学习网站",
        img=
        "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1581182922983&di=99797126d30557e47892e7af4b5c663b&imgtype=jpg&src=http%3A%2F%2Fimg1.imgtn.bdimg.com%2Fit%2Fu%3D2046400996%2C3772250545%26fm%3D214%26gp%3D0.jpg",
        url="https://www.liaoxuefeng.com/wiki/1016959663602400")
    reply.add_article(article)
    return reply
Beispiel #9
0
def blog(message):
    reply = ArticlesReply(message=message)
    article = Article(
        title="CSDN首页",
        description="我的个人博客",
        img=
        "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=2146046871,2611785107&fm=27&gp=0.jpg",
        url="https://www.csdn.net/")
    reply.add_article(article)
    return reply
Beispiel #10
0
def baidu(message):
    reply = ArticlesReply(message=message)
    article = Article(
        title="百度网盘首页",
        description="我的百度网盘",
        img=
        "http://i0.hdslb.com/bfs/face/e3151d681ef3917565e757e5bee885ba1e528b54.jpg",
        url="https://pan.baidu.com")
    reply.add_article(article)
    return reply
Beispiel #11
0
def sing(message):
    reply = ArticlesReply(message=message)
    article = Article(
        title="网易云音乐",
        description="即将跳转网易云",
        img=
        'http://img1.imgtn.bdimg.com/it/u=3397394635,2323693060&fm=26&gp=0.jpg',
        url="https://music.163.com/")
    reply.add_article(article)
    return reply
Beispiel #12
0
def reply(message):
    reply = ArticlesReply(content="HoneywellMobilebus", message=message)
    article = Article(
        title="Mobilebus",
        description="点击进入Honeywell移动班车系统",
        img=
        "https://secure.gravatar.com/avatar/0024710771815ef9b74881ab21ba4173?s=420",
        url="http://mbus.honeywell.com.cn")
    reply.add_article(article)
    return reply
Beispiel #13
0
def blog(message):
    reply = ArticlesReply(message=message)
    article = Article(
        title="忧郁的炸酱面",
        description="我的个人博客",
        img="https://cdn2.jianshu.io/assets/default_avatar/8-a356878e44b45ab268a3b0bbaaadeeb7.jpg?imageMogr2/"
            "auto-orient/strip|imageView2/1/w/120/h/120",
        url="https://www.jianshu.com/u/3c58aa6164de"
    )
    reply.add_article(article)
    return reply
Beispiel #14
0
def blog(message):
    reply = ArticlesReply(message=message)
    article = Article(
        title="历史视频",
        description="乱七八糟的",
        img="http://img.duoziwang.com/2016/12/30/19570835988.jpg",
        url=
        "https://mp.weixin.qq.com/mp/homepage?__biz=MzI4Nzc4NjE2Nw==&hid=10&sn=39b20b7102bbfc7352a92e631b47b295"
    )
    reply.add_article(article)
    return reply
Beispiel #15
0
def echo(message):
    reply = ArticlesReply(message=message)
    article = Article(
        title="Learn by doing",
        description="相信自己",
        img=
        "http://img.taopic.com/uploads/allimg/120727/201995-120HG1030762.jpg",
        url="https://www.baidu.com/")

    reply.add_article(article)
    return reply
Beispiel #16
0
def menu1(message):
    reply = ArticlesReply(message=message)
    article = Article(
        title="胡说八道",
        description="找个树洞 打着胡说八道的名义 说那些只能、只敢、只想在梦里说的话",
        img='''https://mmbiz.qpic.cn/mmbiz_jpg/RnMhjm9oqzBG3
                      PcfuXDcxOdd9BhUBKibIMXDdOicU0sEKa1tYy1JOFsGu3icG73Xh4p0zSgicXP6zKJ5JWPPO5BLKQ/0?wx_fmt=jpeg''',
        url='''https://mp.weixin.qq.com/advanced/selfmenu?action=index&t=advanced
                      /menu-setting&token=1153211364&lang=zh_CN''')
    reply.add_article(article)
    return reply
Beispiel #17
0
def blog(message):
    reply = ArticlesReply(message=message)
    article = Article(
        title="历史群发",
        description="乱七八糟的",
        img=
        "http://image.biaobaiju.com/uploads/20180227/11/1519701852-pQFCqdYWoD.jpg",
        url=
        "https://mp.weixin.qq.com/mp/homepage?__biz=MzI4Nzc4NjE2Nw==&hid=9&sn=0fb12269521137c0bac5355777058cca"
    )
    reply.add_article(article)
    return reply
Beispiel #18
0
 def get_blog(message):
     reply = ArticlesReply(message=message)
     article = Article(
         title="王炳明の博客",
         description="明哥的个人网站",
         img=
         "https://mmbiz.qpic.cn/mmbiz_jpg/UFM3uMlAXxMehvNJYJ5uwlE1n2rfwbUkHl4MXaBUJO8xflmdLmNShqK9iaMQaLeqbpLbicGHe5V8MyibmhZ9lqbkA/0?wx_fmt=jpeg",
         url="https://iswbm.com")
     reply.add_article(article)
     client.send_text_message(
         message.source, content=cfg_dict["werobot"]["common"]["blog"])
     return reply
Beispiel #19
0
 def get_index(message):
     user_info = client.get_user_info(message.source)
     reply = ArticlesReply(message=message)
     article = Article(
         title="三年的 Python 精华文章汇总",
         description="专属于「{}」的干货目录".format(user_info["nickname"]),
         img=
         "https://mmbiz.qpic.cn/mmbiz_jpg/UFM3uMlAXxMehvNJYJ5uwlE1n2rfwbUkHl4MXaBUJO8xflmdLmNShqK9iaMQaLeqbpLbicGHe5V8MyibmhZ9lqbkA/0?wx_fmt=jpeg",
         url="https://t.1yb.co/69Kw"
         # url="https://github.com/iswbm/PythonCodingTime"
     )
     reply.add_article(article)
     return reply
Beispiel #20
0
def old_alarm_handler(message):
    source = message.source
    if not check_auth(source):
        return '您不是授权用户,无法使用该功能。'
    content = message.content
    query_id, url = old_alarm_query(content)
    print(new_query(source, query_id, url))
    reply = ArticlesReply(message=message)
    article = Article(title="告警详情",
                      description="南阳网络运维一点通",
                      img="https://github.com/apple-touch-icon-144.png",
                      url=APP_URL + "?open_id=%s&uuid=%s" % (source, query_id))
    reply.add_article(article)
    return reply
Beispiel #21
0
def convert_to_articlereply(articles, message):
    reply = ArticlesReply(message=message)
    for article in articles:
        imgs = re.findall(r'(?:http\:|https\:)?\/\/.*\.(?:png|jpg)',
                          article.body)
        imgurl = ''
        if imgs:
            imgurl = imgs[0]
        article = Article(title=article.title,
                          description=trancatechars_content(article.body),
                          img=imgurl,
                          url=article.get_full_url())
        reply.add_article(article)
    return reply
Beispiel #22
0
def on_wechat_message(message):
    print('type=%s' % message.type)
    if message.type == 'voice':
        return recognize_sound(message.media_id)
    if message.type == 'text':
        reply = ArticlesReply(message=message)
        article = Article(title="WeRoBot",
                          description="WeRoBot是一个微信机器人框架",
                          img="https://github.com/apple-touch-icon-144.png",
                          url="https://github.com/whtsky/WeRoBot")
        article1 = Article(title="WeRoBot",
                           description="WeRoBot是一个微信机器人框架",
                           img="https://github.com/apple-touch-icon-144.png",
                           url="https://github.com/whtsky/WeRoBot")
        article2 = Article(title="WeRoBot",
                           description="WeRoBot是一个微信机器人框架",
                           img="https://github.com/apple-touch-icon-144.png",
                           url="https://github.com/whtsky/WeRoBot")
        article3 = Article(title="WeRoBot",
                           description="WeRoBot是一个微信机器人框架",
                           img="https://github.com/apple-touch-icon-144.png",
                           url="https://github.com/whtsky/WeRoBot")
        reply.add_article(article)
        reply.add_article(article1)
        reply.add_article(article2)
        reply.add_article(article3)
        return reply
        '''logger.info(message.source)
Beispiel #23
0
def convert_to_articlereply(articles, message):
    reply = ArticlesReply(message=message)
    from blog.templatetags.blog_tags import truncatechars_content
    for post in articles:
        imgs = re.findall(r'(?:http\:|https\:)?\/\/.*\.(?:png|jpg)', post.body)
        imgurl = ''
        if imgs:
            imgurl = imgs[0]
        article = Article(title=post.title,
                          description=truncatechars_content(post.body),
                          img=imgurl,
                          url=post.get_full_url())
        reply.add_article(article)
    return reply
Beispiel #24
0
def convert_to_articlereply(articles, message):
    reply = ArticlesReply(message=message)
    from blog.templatetags.blog_tags import custom_markdown, truncatechars_content
    from web.utils import CommonMarkdown
    from django.utils.safestring import mark_safe
    for post in articles:
        imgs = re.findall(r'(?:http\:|https\:)?\/\/.*\.(?:png|jpg)', post.body)
        imgurl = ''
        if imgs:
            imgurl = imgs[0]
        article = Article(title=post.title,
                          description=truncatechars_content(post.body),
                          img=imgurl,
                          url=post.get_full_url())
        reply.add_article(article)
    return reply
Beispiel #25
0
def process_text_message(text, message):
    search = request_video_info_by_keywords(VIDEO_FROM_IQIYI, text)
    json_str = json.loads(search)
    result = filter_iqiyi_fields(json_str)
    reply = ArticlesReply(message=message)
    i = 0
    for data in result:
        if i >= 8:
            break
        article = Article(title=data[FORMAT_FIELDS['TITLE']],
                          img=data[FORMAT_FIELDS['PIC_URL']],
                          description=data[FORMAT_FIELDS['DESCRIPTION']],
                          url=data[FORMAT_FIELDS['PLAY_URL']])
        reply.add_article(article)
        i = i + 1
    return reply
Beispiel #26
0
def convert_to_articlereply(articles, message):
    reply = ArticlesReply(message=message)
    from blog.templatetags.blog_tags import custom_markdown, truncatechars_content
    from DjangoBlog.utils import CommonMarkdown
    from django.utils.safestring import mark_safe
    for post in articles:
        imgs = re.findall(r'(?:http\:|https\:)?\/\/.*\.(?:png|jpg)', post.body)
        imgurl = ''
        if imgs:
            imgurl = imgs[0]
        article = Article(
            title=post.title,
            description=truncatechars_content(post.body),
            img=imgurl,
            url=post.get_full_url()
        )
        reply.add_article(article)
    return reply
Beispiel #27
0
def fuzzy(message):
    source = message.source
    content = message.content
    if not check_auth(source):
        return '您不是授权用户,无法使用该功能。'
    # myrobot.client.send_text_message(user_id=source, content='正在根据关键字“%s”进行模糊告警查询,请稍后' % content)
    query_id, url = fuzzy_query(content)
    print(new_query(source, query_id, url))
    print(url)
    # result = fuzzy_query(content)
    # return result
    reply = ArticlesReply(message=message)
    article = Article(title="告警详情",
                      description="南阳网络运维一点通",
                      img='http://robot.loyowanwan.cc/static/pics/gumpla.jpg',
                      url=APP_URL + "?open_id=%s&uuid=%s" % (source, query_id))
    reply.add_article(article)
    return reply
Beispiel #28
0
def hello(message):
    print(message.content)
    if message.content.lower() in ['hello', '你好', '好', 'hi']:
        return "Hello, 欢迎来到【3E女子商学院】的世界"
    if message.content.lower() in ['ak', '猩猩', '李胖娃', '胖娃', '胖娃儿']:
        return "{} loves Winnie".format(message.content)
    if message.content.lower() in ['课表', 'kebiao', '课程表', '日程']:
        reply = ArticlesReply(message=message)
        article = Article(
            title="课表",
            description="3E女子商学院课表",
            img=
            '''https://github.com/Akagilnc/Landing_Page_3EWBS/blob/master/img/3e_logo.jpeg?raw=true''',
            url='''http://www.3ewbs.com/class_schedule.html''')
        reply.add_article(article)
        return reply
    if message.content.lower() in ['location', '地点', '教室']:
        reply = ImageReply(
            message=message,
            media_id='CVHC0-1CfQ0wxmPCoRJIMTg2kUalhmdPYsIfbDwBrfQ')
        return reply
    return "主人正在努力挖土烧砖盖楼 \n内容很快就来 \n不要着急 \n休息 \n休息一下"
def first(message, session):
    changdu = str(len(session))
    session[changdu] = message.content
    print(message.content)
    if '王方冰' in message.content:
        ans = '听名字就知道很漂亮~~'
        return ans
    elif '李韬' in message.content:
        ans = '听名字就知道很肥~~'
        return ans
    elif '李坤' in message.content:
        ans = '嗯,我见过,很帅~~'
        return ans
    elif '音乐' in message.content or '歌' in message.content:
        music1 = music_data()
        return music1
    elif '名字' in message.content:
        ans = '我叫昵昵~~'
        return ans
    elif '颜值' in message.content:
        ans = '请回复要测颜值的照片哦~~'
        return ans
    elif message.content in qishu_dict.keys():
        reply = ArticlesReply(message=message)
        article = Article(
            title=qishu_dict[message.content]['title'],
            description=qishu_dict[message.content]['description'],
            img=qishu_dict[message.content]['img'],
            url=qishu_dict[message.content]['url'])
        reply.add_article(article)
        return reply
    elif '报名' in message.content or '脱单' in message.content:
        reply = ArticlesReply(message=message)
        article = Article(
            title='等你脱单报名~~',
            description='等你脱单~~',
            img='http://kan.027cgb.com/623324/177048046.jpg',
            url='https://mp.weixin.qq.com/s/ruwj9ARcQX5tIj-B9et1FQ')
        reply.add_article(article)
        return reply
    else:
        ans = joke.chat_module(message.content)
        return ans
def yuyin(message, session):
    len_res = len(message.recognition)  #语音识别结果,微信自带
    res = message.recognition[0:len_res - 1]
    #print (res)
    if '王方冰' in res:
        ans = '听名字就知道很漂亮~~'
        return ans
    elif '李韬' in res:
        ans = '听名字就知道很肥~~'
        return ans
    elif '李坤' in res:
        ans = '嗯,我见过,很帅~~'
        return ans
    elif '音乐' in res or '歌' in res:
        music1 = music_data()
        return music1
    elif '名字' in res or '叫啥' in res:
        ans = '我叫昵昵~~'
        return ans
    elif '颜值' in res:
        ans = '请回复要测颜值的照片哦~~'
        return ans
    elif res in qishu_dict.keys():
        reply = ArticlesReply(message=message)
        article = Article(title=qishu_dict[res]['title'],
                          description=qishu_dict[res]['description'],
                          img=qishu_dict[res]['img'],
                          url=qishu_dict[res]['url'])
        reply.add_article(article)
        return reply
    elif '报名' in res or '脱单' in res:
        reply = ArticlesReply(message=message)
        article = Article(
            title='等你脱单报名~~',
            description='等你脱单~~',
            img='http://kan.027cgb.com/623324/177048046.jpg',
            url='https://mp.weixin.qq.com/s/ruwj9ARcQX5tIj-B9et1FQ')
        reply.add_article(article)
        return reply
    else:
        ans = joke.chat_module(res)
        return ans
Beispiel #31
0
def echo(message):
    
    import re
    for k,v in echos.items():
        if re.match(v['keyword'], message.content.strip(), re.IGNORECASE):
            if v['type'] == 'TextReply':
                reply = TextReply(message=message, content=v['content']+msgsuffix)
                return reply
            
            if v['type'] == 'ArticleReply':
                reply = ArticlesReply(message=message)
                article = Article(
                    title = v['title'],
                    description = v['description'],
                    img = v['img'],
                    url = v['url'],
                )
                reply.add_article(article)
                return reply
Beispiel #32
0
def test_articles_reply():
    article = Article(
        title="tt",
        description="附近的萨卡里发生",
        img="http",
        url="uuu"
    )
    t = int(time.time())
    reply = ArticlesReply(
        target='tg',
        source='ss',
        time=t
    )
    assert reply.render().strip() == """
    <xml>
    <ToUserName><![CDATA[tg]]></ToUserName>
    <FromUserName><![CDATA[ss]]></FromUserName>
    <CreateTime>{time}</CreateTime>
    <MsgType><![CDATA[news]]></MsgType>
    <Content><![CDATA[]]></Content>
    <ArticleCount>0</ArticleCount>
    <Articles></Articles>
    </xml>""".format(time=t).strip()

    reply._args['content'] = 'wwww'
    assert '<Content><![CDATA[wwww]]></Content>' in reply.render()
    reply.add_article(article)
    assert '<ArticleCount>1</ArticleCount>' in reply.render()
    assert article.render() in reply.render()
    for _ in range(9):
        reply.add_article(article)
    assert '<ArticleCount>10</ArticleCount>' in reply.render()
    with pytest.raises(AttributeError):
        reply.add_article(article)