Example #1
0
   def __init__(self,
                oauth_config_file="",
                oauth_config={},
                check_period=duration.Duration(seconds=90),
                last_id_file="last_ids.dat",
                **kwargs):
      '''
      The twitter bot constructor takes ...(TODO)
      '''
      if len(oauth_config_file) > 0:
         oauth_config = storage.load_data(oauth_config_file)

      # twitter API object
      self._api = twitter.Api(**oauth_config)
      # the user for this bot
      self._me = self._api.VerifyCredentials()
      # duration between checking feed, timeline, replies, etc.
      self._check_period=check_period
      # filename to store last IDs
      self._last_id_filename=last_id_file
      # timelines to watch, and the number of statuses from the timeline to view.  If the count is
      # set to '0', the default number of timelines will be returned.  This can be overwritten in
      # a subclass to watch additional timelines.  If this list is empty, no timelines will be
      # specifically watched
      self._watched_timelines=[]
      # start by trying to process direct messages.  this will be turned to false if DM access is
      # denied, or can be set to false in subclass
      self._do_process_direct_messages=False
      # whether or not to check replies
      self._do_process_replies=False
      # whether or not to process home timeline
      self._do_process_home_timeline=False
      # whether or not to process mentions (including commands)
      self._do_process_mentions=True
      # whether or not bot should keep running
      self._running=False
      # whether or not to have extra printouts
      self._DEBUG=False

      # list of screen names allowed to send commands
      self._allowed_bosses_filename="allowed_bosses.dat"
      self._allowed_bosses=storage.load_list(self._allowed_bosses_filename)

      # only respond to actions that are newer than this duration
      # this prevents responding to really old stuff if the bot goes down or if last_ids gets
      # deleted
      self._max_actionable_age=duration.Duration(hours=6)

      # any subclass initialization can go in this class to avoid unnecessary constructor chaining
      self.on_subclass_init(**kwargs)
Example #2
0
    def __init__(self, *args, **kwargs):
        super(UpdaterBot, self).__init__(*args, **kwargs)

        self._step_size = 10
        if "step_size" in kwargs:
            self._step_size = kwargs["step_size"]
        self._update_period = duration.Duration(hours=2)
        if "update_period" in kwargs:
            self._update_period = kwargs["update_period"]
        self._nag_period = duration.Duration(hours=6)
        if "nag_period" in kwargs:
            self._nag_period = kwargs["nag_period"]
        self._h = 256
        if "h" in kwargs:
            self._h = kwargs["h"]
        if "height" in kwargs:
            self._h = kwargs["height"]
        self._w = 256
        if "w" in kwargs:
            self._w = kwargs["w"]
        if "width" in kwargs:
            self._w = kwargs["width"]

        # create separate twitter api object for profile we're updating
        if "profile_oauth_file" not in kwargs:
            raise twitterbot.TwitterBotError("Unable to create UpdaterBot: no profile oauth provided")
        profile_oauth = storage.load_data(kwargs["profile_oauth_file"])
        self._profile_api = twitter.Api(**profile_oauth)
        self._profile_user = self._profile_api.VerifyCredentials()

        self._target_color_filename = "target_color.dat"
        self._current_color_filename = "current_color.dat"
        self._next_color_filename = "next_color.dat"
        self._last_update_file = "last_profile_update.dat"

        self._DEBUG = True