예제 #1
0
Created on 2013-7-7
the coder lao huang li!!! for moegirl wiki
@author: xuechong
'''
from google.appengine.api import memcache
from Weixin import textReply
import logging
from utils.Commons import randomFromList
from utils.Commons import loadFromMemcache
from utils.Commons import todayStr

client = memcache.Client()
__coderCalenderKey__ = ""
__namespace__ = "coderCalender"

todayKey = lambda: "coderCalender" + str(todayStr())

find = lambda: loadFromMemcache(__namespace__, todayKey(), newContent)


class CoderHandler():
    """
    the coder lao huang li!!! for moegirl wiki
    """
    @staticmethod
    def __helpkey__():
        return __coderCalenderKey__

    @staticmethod
    def __helpcontent__():
        return ""
    @staticmethod
    def __helpcontent__():
        return "输入'新番列表'就可以查看本周的新番列表哦"
    
    def handle(self,handlerChain):
        if handlerChain.getMsgContent() == __animeListKey__:
            return textReply(handlerChain.userMsg,todayContent())
        else:
            return handlerChain.invokeNext()


def getContent ():
    url = findDictByName("animeurl").content
    return fetchContentFromUrl(url)

def formatContent(content):
    result= ""
    soup = BeautifulSoup(content)
    _dtList = soup.find_all("dt")
    for dl in soup.find_all("dl"):
        result = result + "\r\n★" + dl.find("dt").contents[0].encode("utf-8") + ":\r\n"
        for dd in dl.find_all("dd"):
            result = result +  dd.find("a").contents[0].encode("utf-8") + "\r\n"
    return result
            
def todayContent():
    return loadFromMemcache("animeList", todayKey(), lambda :formatContent(getContent()))

todayKey = lambda : "animeList" + str(todayStr())

예제 #3
0
Created on 2013-7-7
the coder lao huang li!!! for moegirl wiki
@author: xuechong
'''
from google.appengine.api import memcache
from Weixin import textReply
import logging
from utils.Commons import randomFromList
from utils.Commons import loadFromMemcache
from utils.Commons import todayStr

client = memcache.Client()
__coderCalenderKey__ = ""
__namespace__ = "coderCalender"

todayKey = lambda : "coderCalender" + str(todayStr())

find = lambda: loadFromMemcache(__namespace__, todayKey(), newContent)

class CoderHandler():
    """
    the coder lao huang li!!! for moegirl wiki
    """
    
    @staticmethod
    def __helpkey__ ():
        return __coderCalenderKey__
    
    @staticmethod
    def __helpcontent__():
        return ""