示例#1
0
    def __init__(self):
        cache = Cache(60)
        super().__init__(app_type=APPTYPE.STREAMING, cache=cache)
        auth = tweepy.AppAuthHandler(self.configuration['TWITTER_APP_KEY'],
                                     self.configuration['TWITTER_APP_SECRET'])
        self.api = tweepy.API(auth)
        self.users = self.configuration['TWITTER_USERS_TO_FETCH_SCHEDULE']

        rule = Rule('Schedule Finder', alarmable=False)
        rule.description = 'Try to find a set of schedules'
        rule.app_id = self.APP_ID

        interval = Interval(hour=1, minute=0)

        for user in self.users:
            rule.create_subrule(subrule_name=user + ':sch',
                                func=self.get_schedule,
                                args=user,
                                triggers={
                                    'day_of_week':
                                    'mon,tue,wed,thu,fri,sat,sun',
                                    'hour': str(interval.hour),
                                    'minute': str(interval.minute)
                                })
            interval.increment_15_mins()

        self.overseer.add_rule(rule)
        self.start()
示例#2
0
文件: main.py 项目: bxpluse/Luminaria
 def create_subreddit_feeds(self):
     subs = self.configuration['SUBREDDIT_FEED_SITES']
     rule = Rule('Subreddit feeds', alarmable=False)
     rule.description = 'Store a set of Subreddit feeds'
     rule.app_id = self.APP_ID
     for sub_name in subs:
         rule.create_subrule(subrule_name=sub_name + '_feed',
                             func=self.get_submissions,
                             args=sub_name,
                             triggers={
                                 'hour': '5',
                             })
     self.overseer.add_rule(rule)
示例#3
0
文件: main.py 项目: bxpluse/Luminaria
 def create_rss_feeds(self):
     urls = self.configuration['RSS_FEED_SITES']
     rule = Rule('RSS feeds', alarmable=False)
     rule.description = 'Store a set of RSS feeds'
     rule.app_id = self.APP_ID
     for url in urls:
         rule.create_subrule(subrule_name=extract_domain(url) + '_feed',
                             func=get_feed,
                             args=url,
                             triggers={
                                 'day_of_week': 'sat',
                             })
     self.overseer.add_rule(rule)
示例#4
0
def create(rule: Rule, alert: QuoteAlert):
    return rule.create_subrule(subrule_name=alert.symbol,
                               func=scan,
                               args=alert,
                               metadata={
                                   'symbol': alert.symbol,
                                   'below': alert.below,
                                   'above': alert.above
                               },
                               triggers={
                                   'end_date': alert.end_time,
                                   'day_of_week': 'mon,tue,wed,thu,fri',
                                   'hour': '10-15',
                               })