def parsepost(self, postarr, total=0): articles = [] count = 0 for post in postarr: url = post['url'] title = post['title'] description = post['excerpt'] attachments = post['attachments'] img = '' if len(attachments) > 0: img = attachments[0]['url'] else: img = 'http://www.lylinux.org/imgs/%s.jpg' % random.randrange( 1, 8) article = Article(title=title, description=description, img=img, url=url) articles.append(article) # articles.append(description) count += 1 if count == 10: break if total != 0 and count == total: break return articles
def ShowBarDetail(barcodelist, message): """ 查看资产详情页面 :param barcodelist:联通资产码列表 :return: """ if len(barcodelist) > 9: barcodelist = barcodelist[0:10] from werobot.reply import ArticlesReply, Article, create_reply reply = ArticlesReply(message=message) for x in barcodelist: zz = ShowBarSmart(x) article = Article( title="点此查看" + x + "的资产详情", description=zz if zz else "尚未收录", img= "http://d.hiphotos.baidu.com/baike/c0%3Dbaike150%2C5%2C5%2C150%2C50/sign" "=5800ef19a61ea8d39e2f7c56f6635b2b/38dbb6fd5266d01662dec68a972bd40734fae6cd7a891570.jpg", url='http://dyit.org/showzc/?zcbh=' + x + '&msgid=' + str(message.id)) reply.add_article(article) return reply
def querycontests(message): if datetime.now().day != lastconteststime.day: cont.update() reply = ArticlesReply(message=message) reply.add_article( Article( title="发现最近有不少比赛哟!快去虐菜吧!!点击下面看详细", img= "https://raw.github.com/Liuchang0812/acmhand/master/acmhand/img/acmlogo.jpg", url=" http://acmicpc.info", description='')) for i in range(min(7, len(cont))): reply.add_article( Article(title=cont[i]['start_time'] + ' ' + cont[i]['oj'] + ' ' + cont[i]['access'] + " \n " + cont[i]['name'], url=cont[i]['link'], description='', img='')) return reply
def echo(message): myreply = ArticlesReply(message=message) article = Article( title="WeRoBot", description="WeRoBot是一个微信机器人框架", img="https://github.com/apple-touch-icon-144.png", url="https://github.com/whtsky/WeRoBot" ) myreply.add_article(article) if message.content == 'a': return myreply return message.content
def reply_article(message): content = message.content.strip() try: r = Articles.objects.get(keyword=content) send = ArticlesReply(message=message) article = Article(title=r.title, description=r.text, img='/media/' + r.img.url, url=r.url) send.add_article(article) return send except: pass
def echo(message): from werobot.reply import ArticlesReply, Article from interface import face reply = ArticlesReply(message=message) article = Article( title="智能测试心理年龄", description=face(message.img), img=message.img, url= "http://mp.weixin.qq.com/s?__biz=MzIwNjE2Mjg5NA==&mid=402671317&idx=1&sn=5abcb6337a32d66248cfd06504c29401#rd" ) reply.add_article(article) return reply
def SendSnList(message): """ 点击进入发展列表进行查询的界面 :param message: :return: """ reply = ArticlesReply(message=message) article = Article(title="号码状态查询", description="包含号码,发展时间,当前状态等信息", img=SITE_URL + "static/images/logo.gif", url=SITE_URL + 'showsnlist') reply.add_article(article) return reply
def SendBDPage(message): """ 产生绑定账户的页面 :param message: :return: """ reply = ArticlesReply(message=message) article = Article(title="请先绑代理商工号", description="点此进行绑定,请在打开的页面输入代理商工号,验证码会下发到返档手机号码", img=SITE_URL + "static/images/logo.gif", url=SITE_URL + 'bd/' + message.source) reply.add_article(article) return reply
def SendBDPage(message): """ 产生绑定账户的页面 :param message: :return: """ from werobot.reply import ArticlesReply, Article, create_reply reply = ArticlesReply(message=message) article = Article(title="请先绑定门户账户", description="点此进行绑定,请在打开的页面输入云门户账户,验证码会下发到您的手机号码", img="http://dyit.org/static/images/logo.gif", url='http://dyit.org/bd/' + message.source) reply.add_article(article) return reply
def on_text(message): content = message.content try: content = content.lower() total, artifact_ids = es_client.search_artifact(content) if total == 0: return "找不到你要的的内容,请换个关键词吧.(×_×)" else: reply = ArticlesReply(message=message) if artifact_ids: for artifact_id in artifact_ids: artifact_result = ArtifactResultProxy( artifact_id, show_topic=False, show_user=False).result() artifact = artifact_result.get("artifact") title = artifact.get("name") description = artifact.get("description") profile_image = artifact.get("profile_image") if "." in profile_image: last_dot = profile_image.rindex('.') else: last_dot = len(profile_image) profile_image = profile_image[: last_dot] + "-200x200" + profile_image[ last_dot:] url = settings.domain_name + "/projects/" + str( artifact.get("id")) reply.add_article( Article(title=title, description=description, img=profile_image, url=url)) return reply except Exception, e: _logger.exception(e) return "系统出错了,X﹏X"