def tweet_to_addr(cls, tweet): mentions = messagetools.tweet_user_mentions(tweet) to_addr = cls.NO_USER_ADDR if mentions: mention = mentions[0] [start_index, end_index] = mention['indices'] if start_index == 0: to_addr = cls.screen_name_as_addr(mention['screen_name']) return to_addr
def publish_tweet(self, tweet): return self.publish_message( content=self.tweet_content(tweet), to_addr=self.tweet_to_addr(tweet), from_addr=self.tweet_from_addr(tweet), transport_type=self.transport_type, routing_metadata={ 'endpoint_name': self.endpoints['tweets'] }, transport_metadata={ 'twitter': { 'status_id': messagetools.tweet_id(tweet) } }, helper_metadata={ 'twitter': { 'in_reply_to_status_id': ( messagetools.tweet_in_reply_to_id(tweet)), 'in_reply_to_screen_name': ( messagetools.tweet_in_reply_to_screen_name(tweet)), 'user_mentions': messagetools.tweet_user_mentions(tweet), } })