Ejemplo n.º 1
0
from django.conf import settings
import jsonpickle
from servermanager.models import commands

robot = WeRoBot(token='lylinux', enable_session=True)
memstorage = MemcacheStorage()
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')):
        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 agrosite.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(
Ejemplo n.º 2
0
import os

from werobot.robot import BaseRoBot
from werobot.parser import parse_user_msg
from werobot.reply import create_reply
from werobot.logger import enable_pretty_logging
import werkzeug
from werobot.session.filestorage import FileStorage

import openerp
from openerp import http
from openerp.http import request

_logger = logging.getLogger(__name__)
data_dir = openerp.tools.config['data_dir']
session_storage = FileStorage(filename=os.path.join(data_dir, 'werobot_session') )

def abort(code):
    return werkzeug.wrappers.Response('Unknown Error: Application stopped.', status=code, content_type='text/html;charset=utf-8')


class WeRoBot(BaseRoBot):
    pass

robot = WeRoBot(token='K5Dtswpte', enable_session=True, logger=_logger, session_storage=session_storage)
enable_pretty_logging(robot.logger)
    
class WxController(http.Controller):

    ERROR_PAGE_TEMPLATE = """
    <!DOCTYPE html>