Пример #1
0
    def __init__(self, name):
        from curtana.lib.parser_aliases import RE, R
        B.Base.__init__(self, ApiMod.from_name(name))
        vocab.Vocabulary.__init__(self)
        
        self.screen_name = name
        self.talked = []
        self.assoc_table = Counter()
        self.markov_table = G.Table()
        self.load(B.PATH)

        self.pattern = (RE("もしゃもしゃ|モシャモシャ|もふもふ|モフモフ") >> R(self.response0)
                        | RE("(^|む|[^く])ぎゅ[っうぅー]?") >> R(self.response1)
                        | RE("なでなで|ナデナデ") >> R(self.response2)
                        | RE("ぺろぺろ|ペロペロ|ちゅっちゅ|チュッチュ") >> R(self.response3) 
                        )
        self.voluntary = (RE("((^|[^ァ-ヾ])リサ|(^|[^ぁ-ゞ])りさ)(ちゃん|チャン)")
                         >> R(compose(star(OP.rshift), fanout(self.chan_ha_fuyou, self.favorite)))
                         #|RE("((^|[^ァ-ヾ])リサ|^りさ)") >> R(self.favorite)
                         )
Пример #2
0
 def __init__(self, name):
     threading.Thread.__init__(self)
     self.daemon = True
     self.name = name
     self.api = ApiMod.from_name(name)
Пример #3
0
    def run(self):
        self.action.do()

class TrackFollowme(threading.Thread):
    def __init__(self, name):
        threading.Thread.__init__(self)
        self.daemon = True
        self.name = name
        self.api = ApiMod.from_name(name)
    def run(self):
        stream = streaming.streamopen(self.name, streaming.STATUSES_FILTER_URL, track="#Lisa_math_follow_me")
        for status in stream:
            self.api.createFriendship(user_id=status["user"]["id_str"])
            self.api.updateStatus(vocab.FOLLOW_COMPLETE.format(status["user"]["screen_name"]), in_reply_to_status_id=status["id_str"])

def consume(name, responder):
    for status in streaming.iterstream(streaming.streamopen(name)):
        Execute(responder.action(status)).start()

def main(name):
    TrackFollowme(name).start()
    consume(name, ResponderLisa(name))

if __name__ == "__main__":
    import sys
    if sys.argv[1] == "run":
        main(REGISTERD_NAME)
    elif sys.argv[1] == "post":
        ApiMod.from_name(REGISTERD_NAME).updateStatus(status=sys.argv[2])
    elif sys.argv[1] == "tweet":
        pass #G.format_words(G.generate(table, N=32, P=100, extra=3)[16][0])