Created
April 26, 2012 01:51
-
-
Save shogo82148/2495140 to your computer and use it in GitHub Desktop.
FUCOROIDフォローカウンター
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding:utf-8 -*- | |
import config | |
from TwitterBot import BaseBot | |
import logging | |
logger = logging.getLogger("Bot.counter") | |
class Bot(BaseBot): | |
def __init__(self): | |
super(Bot, self).__init__( | |
config.CONSUMER_KEY, | |
config.CONSUMER_SECRET, | |
config.ACCESS_KEY, | |
config.ACCESS_SECRET) | |
self.counter = {} | |
self.append_cron('00 00 * * *', Bot.report) | |
def on_follow(self, target, source): | |
name = source.screen_name | |
self.counter[name] = self.counter.get(name, 0) + 1 | |
logger.info("Follow: %s(%d)", name, self.counter[name]) | |
def report(self): | |
if "FUCOROID" in self.counter: | |
self.update_status(u"今日はFUROROIDに%d回フォローされました" % self.counter['FUCOROID']) | |
else: | |
self.update_status(u"今日はFUROROIDにフォローされませんでした!やったね!") | |
self.counter = {} | |
def main(): | |
bot = Bot() | |
bot.main() | |
if __name__=='__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment