当前位置: 首页>>代码示例>>Python>>正文


Python schedule.addPeriodicEvent函数代码示例

本文整理汇总了Python中supybot.schedule.addPeriodicEvent函数的典型用法代码示例。如果您正苦于以下问题:Python addPeriodicEvent函数的具体用法?Python addPeriodicEvent怎么用?Python addPeriodicEvent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了addPeriodicEvent函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, irc):
        self.__parent = super(SubredditAnnouncer, self)
        self.__parent.__init__(irc)
        self.savefile = conf.supybot.directories.data.dirize("subredditAnnouncer.db")
        self.headers = {"User-Agent": "SubredditAnnouncer ([email protected])"}

        def checkForPosts():
            self.checkReddit(irc)
        try:
            schedule.addPeriodicEvent(checkForPosts,
                                      self.registryValue('checkinterval')*60,
                                      'redditCheck', False)
        except AssertionError:
            schedule.removeEvent('redditCheck')
            schedule.addPeriodicEvent(checkForPosts,
                                      self.registryValue('checkinterval')*60,
                                      'redditCheck', False)
        try:
            if self.registryValue('dsn') != "":
                if "raven" in dir():  # Check that raven was actually imported
                    self.raven = raven.Client(self.registryValue("dsn"))
                else:
                    self.log.error("dsn defined but raven not installed! Please pip install raven")
        except NonExistentRegistryEntry:
            pass
开发者ID:thefinn93,项目名称:SubredditAnnouncer,代码行数:25,代码来源:plugin.py

示例2: __init__

    def __init__(self, irc):
        self.__parent = super(DeedSystem, self)
        self.__parent.__init__(irc)
        
        # load deeds config
        config_path = self.registryValue('configPath')
	with open(config_path,'r') as f:
		deeds_config = json.loads(f.read())

        # prompt for password
        pwd = getpass('Enter wallet password:')
        deeds_config['wallet_pass'] = pwd

        # start the bundler
        self.deeds = Bundler(deeds_config)
        self.deeds.setup()

        # schedule events
        def make_bundle():
            self._make_bundle(irc)

        def confirm_bundle():
            self._confirm_bundle(irc)

        schedule.addPeriodicEvent(make_bundle, deeds_config['make_bundle_interval'], now=False, name='make_bundle')
        schedule.addPeriodicEvent(confirm_bundle, deeds_config['confirm_bundle_interval'], now=False, name='confirm_bundle')
开发者ID:RagnarDanneskjold,项目名称:deedbundler,代码行数:26,代码来源:plugin.py

示例3: __init__

    def __init__(self, irc):
        self.__parent = super(Bantracker, self)
        self.__parent.__init__(irc)
        self.default_irc = irc
        self.lastMsgs = {}
        self.lastStates = {}
        self.replies = {}
        self.logs = ircutils.IrcDict()
        self.nicks = {}
        self.hosts = {}
        self.bans = ircutils.IrcDict()

        self.thread_timer = threading.Timer(10.0, dequeue, args=(self,irc))
        self.thread_timer.start()

        db = self.registryValue('database')
        if db:
            self.db = sqlite3.connect(db)
        else:
            self.db = None
        self.get_bans(irc)
        self.get_nicks(irc)
        self.pendingReviews = PersistentCache('bt.reviews.db')
        self.pendingReviews.open()
        self._banreviewfix()
        # add scheduled event for check bans that need review, check every hour
        try:
            schedule.removeEvent(self.name())
        except:
            pass
        schedule.addPeriodicEvent(lambda : self.reviewBans(irc), 60*60,
                name=self.name())
开发者ID:Affix,项目名称:Fedbot,代码行数:32,代码来源:plugin.py

示例4: __init__

    def __init__(self, irc):
        self.__parent = super(DebianDevelChanges, self)
        self.__parent.__init__(irc)
        self.irc = irc
        self.topic_lock = threading.Lock()

        fr = FifoReader()
        fifo_loc = '/var/run/debian-devel-changes/fifo'
        fr.start(self._email_callback, fifo_loc)

        self.queued_topics = {}
        self.last_n_messages = []

        # Schedule datasource updates
        for klass, interval, name in get_datasources():
            try:
                schedule.removePeriodicEvent(name)
            except KeyError:
                pass

            def wrapper(klass=klass):
                klass().update()
                self._topic_callback()

            schedule.addPeriodicEvent(wrapper, interval, name, now=False)
            schedule.addEvent(wrapper, time.time() + 1)
开发者ID:rhonda,项目名称:debian-devel-changes-bot,代码行数:26,代码来源:plugin.py

示例5: pollon

    def pollon(self, irc, msg, args, channel, pollid, interval):
        """<[channel]> <id> <interval in minutes>
        Schedules announcement of poll with the given <id> every <interval>.
        <channel> is only necessary if the message is not sent in the channel
        itself."""

        db = self.getDb(channel)
        cursor = db.cursor()

        # query to check poll exists, and if it is already on
        pollinfo = self._poll_info(db, pollid)
        if pollinfo is None:
            irc.error('That poll id does not exist')
            return
        if pollinfo[0] == 1:
            irc.error('Poll is already active')
            return

        # query to set poll off
        db.execute('UPDATE polls SET isAnnouncing=? WHERE id=?', (1, pollid))
        db.commit()

        if pollinfo[1] is not None:
            irc.reply('Note: you are turning on closed poll. I will not start announcing it')
            return

        # function called by schedule event. can not have args
        def runPoll():
            self._runPoll(irc, channel, pollid)

        # start schedule. will announce poll/choices to channel at interval
        schedule.addPeriodicEvent(runPoll, interval*60, name='%s_poll_%s' % (channel, pollid))
        self.poll_schedules.append('%s_poll_%s' % (channel, pollid))
开发者ID:tz18,项目名称:Supybot-Polls,代码行数:33,代码来源:plugin.py

示例6: search

    def search(self, irc, msg, arg, search):
        """<terms>

        Start streaming a Twitter search."""
        name = 'twitterstream_search_'+search
        api = twitter.Api()
        def fetch(send=True):
            url = 'http://search.twitter.com/search.json?q=%s&since_id=%i' % \
                    (search, self._searches[name])
            timeline = requests.get(url).json['results']
            for tweet in timeline:
                self._searches[name] = max(self._searches[name], tweet['id'])
            format_ = '@%(user)s> %(msg)s'
            replies = [format_ % {'longid': x['id'],
                                  'user': x['from_user'],
                                  'msg': x['text']
                                 } for x in timeline
                                 if not x['text'].startswith('RT ')]
            replies = [x.replace("&lt;", "<").replace("&gt;", ">")
                    .replace("&amp;", "&") for x in replies]
            if send:
                for reply in replies:
                    irc.reply(reply, prefixNick=False)
        self._searches[name] = 0
        fetch(False)
        schedule.addPeriodicEvent(fetch, 60, name)
        irc.replySuccess()
开发者ID:ArtRichards,项目名称:Supybot-plugins,代码行数:27,代码来源:plugin.py

示例7: __init__

 def __init__(self, irc):
     self.__parent = super(Hardball, self)
     self.__parent.__init__(irc)
     # initial states for channels.
     self.channels = {}  # dict for channels with values as teams/ids
     self._loadpickle()  # load saved data.
     # initial states for games.
     self.games = None
     self.nextcheck = None
     # dupedict.
     self.dupedict = {}
     # base url.
     self.baseurl = b64decode('aHR0cDovL2dkMi5tbGIuY29t')
     try:
         self.nohitterInning = self.registryValue('inningToAnnounceNoHitter')
     except:
         self.log.info('Registry value for no-hitter inning not set, defaulting to 7')
         self.nohitterInning = 7
     # fill in the blanks.
     if not self.games:
         self.games = self._fetchgames()
     # now schedule our events.
     def checkhardballcron():
         self.checkhardball(irc)
     try:  # check scores.
         schedule.addPeriodicEvent(checkhardballcron, self.registryValue('checkInterval'), now=False, name='checkhardball')
     except AssertionError:
         try:
             schedule.removeEvent('checkhardball')
         except KeyError:
             pass
         schedule.addPeriodicEvent(checkhardballcron, self.registryValue('checkInterval'), now=False, name='checkhardball')
开发者ID:cottongin,项目名称:Hardball,代码行数:32,代码来源:plugin.py

示例8: __init__

    def __init__(self, irc):
        self.__parent = super(Mantis, self)
        self.__parent.__init__(irc)

        self.saidBugs = ircutils.IrcDict()
        sayTimeout = self.registryValue('bugSnarferTimeout')
        for k in irc.state.channels.keys():
            self.saidBugs[k] = TimeoutQueue(sayTimeout)

        self.urlbase = self.registryValue('urlbase')
        self.privateurlbase = self.registryValue('privateurlbase')

        if self.privateurlbase != "":
            serviceUrl = self.privateurlbase + '/api/soap/mantisconnect.php'
        else:
            serviceUrl = self.urlbase + '/api/soap/mantisconnect.php'

        self.server = SOAPProxy(serviceUrl)._ns(namespace)
        self.username = self.registryValue('username')
        self.password = self.registryValue('password')
        self.oldperiodic = self.registryValue('bugPeriodicCheck')
        self.irc = irc
        self.lastBug = 0

        bugPeriodicCheck = self.oldperiodic
        if bugPeriodicCheck > 0:
            schedule.addPeriodicEvent(self._bugPeriodicCheck, bugPeriodicCheck, name=self.name())

        reload(sys)
        sys.setdefaultencoding('utf-8')
开发者ID:dregad,项目名称:supybot-mantis,代码行数:30,代码来源:plugin.py

示例9: __init__

 def __init__(self, irc):
     self.__parent = super(Lunch, self)
     self.__parent.__init__(irc)
     self.irc = irc
     self.scheduled = None
     self._scheduleAnnouncement()
     schedule.addPeriodicEvent(self._checkTopic, self.registryValue('period'), 'lunch')
开发者ID:jpnurmi,项目名称:supybot-lunch,代码行数:7,代码来源:plugin.py

示例10: openpoll

    def openpoll(self, irc, msg, args, channel, pollid, interval):
        """[<channel>] <id>
        Starts announcing poll with the given <id> if set to active.
        <channel> is only necessary if the message isn't sent in the channel
        itself."""

        db = self.getDb(channel)
        cursor = db.cursor()

        # query to check poll exists and if it is open
        pollinfo = self._poll_info(db, pollid)
        if pollinfo is None:
            irc.error('Poll id doesnt exist')
            return
        if pollinfo[1] is None:
            irc.error('Poll is still open')
            return

        # query to OPEN IT UP! unsets closed time
        self._execute_query(cursor, 'UPDATE polls SET closed=? WHERE id=?', None, pollid)
        db.commit()

        # if poll was set active then start schedule for it
        if pollinfo[0] == 1:
            if interval is None:
                irc.reply('Note: Poll set to active, but you didnt supply interval, using default of 10 minutes')
                interval = 10
            # function called by schedule event. can not have args
            def runPoll():
                self._runPoll(irc, channel, pollid)

            # start schedule. will announce poll/choices to channel at interval
            schedule.addPeriodicEvent(runPoll, interval*60, name='%s_poll_%s' % (channel, pollid))
            self.poll_schedules.append('%s_poll_%s' % (channel, pollid))
开发者ID:tz18,项目名称:Supybot-Polls,代码行数:34,代码来源:plugin.py

示例11: __init__

 def __init__(self, irc):
     self.__parent = super(Twitter, self)
     self.__parent.__init__(irc)
     self.irc = irc
     self.mentionSince = None
     self.tweetsSince = None
     self.snarfdb = SNARFDB()
     try:
         schedule.removeEvent('Mentions')
     except KeyError:
         pass
     try:
         schedule.removeEvent('Tweets')
     except KeyError:
         pass
     t_consumer_key = self.registryValue('consumer_key')
     t_consumer_secret = self.registryValue('consumer_secret')
     t_access_key = self.registryValue('access_key')
     t_access_secret = self.registryValue('access_secret')
     self.api = twitter.Api(consumer_key=t_consumer_key, consumer_secret=t_consumer_secret, access_token_key=t_access_key, access_token_secret=t_access_secret)
     if self.registryValue('displayTweets'):
         statuses = self.api.GetUserTimeline(include_rts=True, count=1)
         if len(statuses) > 0:
             self.tweetsSince = statuses[0].id
         def tweetsCaller():
             self._tweets(irc)
         schedule.addPeriodicEvent(tweetsCaller, 300, 'Tweets')
     if self.registryValue('displayReplies'):
         statuses = self.api.GetMentions()
         if len(statuses) > 0:
             self.mentionSince = statuses[0].id
         def mentionCaller():
             self._mention(irc)
         schedule.addPeriodicEvent(mentionCaller, 300, 'Mentions')
开发者ID:boamaod,项目名称:supybot-twitter,代码行数:34,代码来源:plugin.py

示例12: newpoll

    def newpoll(self, irc, msg, args, channel, interval, answers, question):
        """<number of minutes for announce interval> <"answer,answer,..."> question
        Creates a new poll with the given question and answers. <channel> is
        only necessary if the message isn't sent in the channel itself."""

        capability = ircdb.makeChannelCapability(channel, 'op')
        if not ircdb.checkCapability(msg.prefix, capability):
            irc.error('Need ops')
            return

        db = self.getDb(channel)
        cursor = db.cursor()
        self._execute_query(cursor, 'INSERT INTO polls VALUES (?,?,?,?,?)', None, datetime.datetime.now(), 1, None, question)
        pollid = cursor.lastrowid

        # used to add choices into db. each choice represented by character, starting at capital A (code 65)
        def genAnswers():
            for i, answer in enumerate(answers, start=65):
                yield pollid, chr(i), answer

        cursor.executemany('INSERT INTO choices VALUES (?,?,?)', genAnswers())

        db.commit()

        irc.reply('Started new poll #%s' % pollid)

        # function called by schedule event. can not have args
        def runPoll():
            self._runPoll(irc, channel, pollid)

        # start schedule. will announce poll/choices to channel at interval
        schedule.addPeriodicEvent(runPoll, interval*60, name='%s_poll_%s' % (channel, pollid))
        self.poll_schedules.append('%s_poll_%s' % (channel, pollid))
开发者ID:tz18,项目名称:Supybot-Polls,代码行数:33,代码来源:plugin.py

示例13: spammer

    def spammer(self, irc, msg, args):
        """<none

        Spamming!!!"""
        #global lines
        #lines = []
        #irc.reply('asdsad')
        #with open('C:\\KAVIRC\\11-14-2013-SasaIka.txt', 'r') as k:
        #b = k.readlines()
        #reg = re.match('(.*)(Z|z)naci(.*)', b)
        #url = conf.supybot.plugins.ERep.url()
        #bata = json.load(utils.web.getUrlFd('%scitizen/search/Digital_Lemon/1.json' % (url)))
        #id = str(bata[0]['id'])
        #irc.reply(id)
        #if id == '3876733':
            #irc.reply('\x02 Link\x02: http://www.erepublik.com/en/citizen/profile/%s' % id)
        #else:
            #return
        #for line in b:
            #lines.append(line)
        #for l in lines:
            #time.sleep(5)
            #irc.reply(l)
        #t = time.time() + 7
        #schedule.addPeriodicEvent(self._checkTime, 7, 'MyFirstEvent')
        def _checkTime():
            url = conf.supybot.plugins.ERep.url()
            bata = json.load(utils.web.getUrlFd('%scitizen/search/Crazy_Hospy/1.json' % (url)))
            id = str(bata[0]['id'])
            irc.reply(id)
            if id == '3876733':
                irc.reply(id)
            if id == '4693953':
                irc.reply('ADsddad')
        schedule.addPeriodicEvent(_checkTime, 7, 'ms')
开发者ID:kg-bot,项目名称:SupyBot,代码行数:35,代码来源:plugin.py

示例14: starthello

 def starthello(self, irc, msg, args):
     """Nothing"""
     channel = msg.args[0]
     eventName = "%s_sayhello" % channel
     def sayHello():
         irc.queueMsg(ircmsgs.privmsg("DonVitoCorleone", "Function _sayHello is called"))
         eventNumber = self.read_timer_number()
         eventNumber = eventNumber["n"]
         irc.queueMsg(ircmsgs.privmsg("DonVitoCorleone", "eventN is %i" % eventNumber))
         if eventNumber <= 1:
             irc.queueMsg(ircmsgs.privmsg("DonVitoCorleone", "It's diferent"))
             self.write_timer_number()
         """if eventNumber <= 5:
             irc.sendMsg(ircmsgs.privmsg("DonVitoCorleone", "Current i before is %i" % eventNumber))
             eventNumber += 1
             irc.queueMsg(ircmsgs.privmsg("DonVitoCorleone", "I after is %i" % eventNumber))
             irc.queueMsg(ircmsgs.privmsg("DonVitoCorleone", "Hello World"))
         else:
             irc.queueMsg(ircmsgs.privmsg("DonVitoCorleone", schedule.schedule.events.keys()))
             schedule.removeEvent(eventName)
             irc.queueMsg(ircmsgs.privmsg("DonVitoCorleone", "Going to remove event %s" % eventName))"""
     schedule.addPeriodicEvent(sayHello, 60, eventName, now=False)
     def stopHello():
         print "Going to stop %s" % eventName
         try:
             schedule.removeEvent(eventName)
             print "Event %s stopped" % eventName
         except Exception as e:
             print e
     schedule.addEvent(stopHello, time.time() + 100)
开发者ID:kg-bot,项目名称:SupyBot,代码行数:30,代码来源:plugin.py

示例15: user

    def user(self, irc, msg, arg, username):
        """<username>

        Start usering a Twitter account."""
        name = 'twitterstream_user_'+username
        api = twitter.Api()
        def fetch(send=True):
            timeline = api.GetUserTimeline(username,
                    since_id=self._users[name])
            for tweet in timeline:
                self._users[name] = max(self._users[name], tweet.id)
            format_ = '@%(user)s> %(msg)s'
            replies = [format_ % {'longid': x.id,
                                  'user': x.user.screen_name,
                                  'msg': x.text
                                 } for x in timeline]
            replies = [x.replace("&lt;", "<").replace("&gt;", ">")
                    .replace("&amp;", "&") for x in replies]
            if send:
                for reply in replies:
                    irc.reply(reply, prefixNick=False)
        self._users[name] = 0
        fetch(False)
        schedule.addPeriodicEvent(fetch, 60, name)
        irc.replySuccess()
开发者ID:ArtRichards,项目名称:Supybot-plugins,代码行数:25,代码来源:plugin.py


注:本文中的supybot.schedule.addPeriodicEvent函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。