예제 #1
0
memstorage = MemcacheStorage()
# TODO 在容器中会报错 不存在文件werobot_session 但是文件在容器中是存在的 可能是操作系统的原因
# if memstorage.is_available:
#     robot.config['SESSION_STORAGE'] = memstorage
# else:
#     from werobot.session.filestorage import FileStorage
#     import os
#     from django.conf import settings
#
#     if os.path.exists(os.path.join(settings.BASE_DIR, 'werobot_session')):
#         print("=====================================")
#         print(os.path.join(settings.BASE_DIR, 'werobot_session'))
#         os.remove(os.path.join(settings.BASE_DIR, 'werobot_session'))
#     robot.config['SESSION_STORAGE'] = FileStorage(filename='werobot_session')
blogapi = BlogApi()
tuling = TuLing()


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,
예제 #2
0
 def test_tuling(self):
     t = TuLing()
     content = t.getdata('test')
     self.assertIsNotNone(content)
예제 #3
0
 def test_tuling(self):
     t = TuLing()
     content = t.getdata('test')
     self.assertIsNotNone(content)