• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python schedule.removeEvent函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: _start

	def _start (self, irc, prefix=True):
		if self.tache != 0:
			schedule.removeEvent(self.tache)
			self.tache = 0
		if self.en_cours:
			s = self.c.getSolution ()
			sr = ""
			if s[0] == 0:
				sr = "Le compte est bon: "
			else:
				sr = "Loin de %s: " % str(s[0])
			sr += "|".join (s[1])
			irc.reply (sr, prefixNick=False)
			self.en_cours = False
			if not self.tries:
				irc.reply ("Fin du jeu", prefixNick=prefix)
				return
		self.tries = False
		self.c.generate ()
		irc.reply (self.c.nombres, prefixNick=prefix)
		irc.reply ("Cible: %d" % self.c.res_cible, prefixNick=prefix)
		self.en_cours = True
		def f():
			self.tache = 0
			self._start (irc, prefix=False)
		self.tache = schedule.addEvent(f, time.time() + 300)
开发者ID:WnP,项目名称:archange,代码行数:26,代码来源:plugin.py


示例2: _topic_callback

    def _topic_callback(self):
        self.topic_lock.acquire()

        sections = {
            lambda: len(TestingRCBugs().get_bugs()): 'RC bug count:',
            NewQueue().get_size: 'NEW queue:',
            RmQueue().get_size: 'RM queue:',
        }

        try:
            values = {}
            for callback, prefix in sections.iteritems():
                values[callback] = callback()

            for channel in self.irc.state.channels:
                new_topic = topic = self.irc.state.getTopic(channel)

                for callback, prefix in sections.iteritems():
                    if values[callback]:
                        new_topic = rewrite_topic(new_topic, prefix, values[callback])

                if topic != new_topic:
                    log.info("Queueing change of topic in #%s to '%s'" % (channel, new_topic))
                    self.queued_topics[channel] = new_topic

                    event_name = '%s_topic' % channel
                    try:
                        schedule.removeEvent(event_name)
                    except KeyError:
                        pass
                    schedule.addEvent(lambda channel=channel: self._update_topic(channel),
                        time.time() + 60, event_name)
        finally:
            self.topic_lock.release()
开发者ID:rhonda,项目名称:debian-devel-changes-bot,代码行数:34,代码来源:plugin.py


示例3: __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


示例4: doPrivmsg

 def doPrivmsg(self, irc, msg):
     channel = msg.args[0]
     nick = msg.prefix.split("!")[0]
     if channel not in self.states:
         return
     reply = None
     state = self.states[channel]
     for mode, answer in state.answers:
         if mode == "r":
             if msg.args[1].lower() == answer.lower():
                 state.adjust(nick, state.question[0])
                 reply = _("Congratulations %s! The answer was %s.")
                 reply %= (nick, answer)
         elif mode == "m":
             if answer.match(msg.args[1]):
                 state.adjust(nick, state.question[0])
                 reply = _("Congratulations %s! The answer was %s.")
                 reply %= (nick, msg.args[1])
     if reply is not None:
         schedule.removeEvent("Eureka-nextClue-%s" % channel)
         otherAnswers = [y for x, y in state.answers if x == "r" and y.lower() != msg.args[1].lower()]
         if len(otherAnswers) == 1:
             reply += " " + _("Another valid answer is: '%s'.")
             reply %= otherAnswers[0]
         elif len(otherAnswers) >= 2:
             reply += " " + _("Other valid answers are: '%s'.")
             reply %= "', '".join([x for x in otherAnswers])
         irc.reply(reply, prefixNick=False)
         self._ask(irc, channel, True)
开发者ID:Azelphur,项目名称:Supybot-plugins,代码行数:29,代码来源:plugin.py


示例5: defuse

        def defuse(self):
            if not self.active:
                return

            self.active = False
            self.thrown = False
            schedule.removeEvent("{}_bomb".format(self.channel))
开发者ID:Brilliant-Minds,项目名称:Limnoria-Plugins,代码行数:7,代码来源:plugin.py


示例6: run_callback

 def run_callback(callback, id_):
     ''' Run the callback 'now' on main thread. '''
     try:
         schedule.removeEvent(id_)
     except KeyError:
         pass
     schedule.addEvent(callback, time.time(), id_)
开发者ID:gmorell,项目名称:supybot-git,代码行数:7,代码来源:plugin.py


示例7: _giveClue

    def _giveClue(self, irc, channel, now=False):
        state = self.states[channel]
        (delay, clue, valid) = state.getClue()

        def event():
            try:
                schedule.removeEvent("Eureka-nextClue-%s" % channel)
            except KeyError:
                pass
            if clue is None:
                assert valid is None
                irc.reply(
                    _("Nobody replied with (one of this) " "answer(s): %s.")
                    % ", ".join([y for x, y in state.answers if x == "r"]),
                    prefixNick=False,
                )
                self._ask(irc, channel)
            else:
                irc.reply(_("Another clue: %s") % clue, prefixNick=False)
                self._giveClue(irc, channel)

        eventName = "Eureka-nextClue-%s" % channel
        if now and eventName in schedule.schedule.events:
            schedule.schedule.events[eventName]()
            schedule.removeEvent(eventName)
        schedule.addEvent(event, time.time() + delay, eventName)
开发者ID:Azelphur,项目名称:Supybot-plugins,代码行数:26,代码来源:plugin.py


示例8: _topic_callback

    def _topic_callback(self):
        sections = {
            self.testing_rc_bugs.get_number_bugs: 'RC bug count',
            self.stable_rc_bugs.get_number_bugs: 'Stable RC bug count',
            self.new_queue.get_size: 'NEW queue',
            RmQueue().get_size: 'RM queue',
        }

        with self.topic_lock:
            values = {}
            for callback, prefix in sections.iteritems():
                values[callback] = callback()

            for channel in self.irc.state.channels:
                new_topic = topic = self.irc.state.getTopic(channel)

                for callback, prefix in sections.iteritems():
                    if values[callback]:
                        new_topic = rewrite_topic(new_topic, prefix, values[callback])

                if topic != new_topic:
                    log.info("Queueing change of topic in #%s to '%s'" % (channel, new_topic))
                    self.queued_topics[channel] = new_topic

                    event_name = '%s_topic' % channel
                    try:
                        schedule.removeEvent(event_name)
                    except KeyError:
                        pass
                    schedule.addEvent(lambda channel=channel: self._update_topic(channel),
                        time.time() + 60, event_name)
开发者ID:xtaran,项目名称:debian-devel-changes-bot,代码行数:31,代码来源:plugin.py


示例9: start

    def start(self, irc, msg, args, channel, num):
        """[<kanal>] [<broj pitanja>]

        Zapocinje novu igru.  <kanal> nije obavezan osim u slucaju da komandu dajete botu na PM."""
        if num == None:
            num = self.registryValue('defaultRoundLength', channel)
        #elif num > 100:
        #    irc.reply('Zao nam je ali za sada ne mozete igrati sa vise '
        #              'od 100 pitanja :(')
        #    num = 100
        channel = ircutils.toLower(channel)
        if channel in self.games:
            if not self.games[channel].active:
                del self.games[channel]
                try:
                    schedule.removeEvent('next_%s' % channel)
                except KeyError:
                    pass
                irc.reply(_('Orphaned trivia game found and removed.'))
            else:
                self.games[channel].num += num
                self.games[channel].total += num
                irc.reply(_('%d pitanja dodano u trenutnu igru!') % num)
        else:
            self.games[channel] = self.Game(irc, channel, num, self)
        irc.noReply()
开发者ID:kg-bot,项目名称:SupyBot,代码行数:26,代码来源:plugin.py


示例10: stopHello

 def stopHello():
     print "Going to stop %s" % eventName
     try:
         schedule.removeEvent(eventName)
         print "Event %s stopped" % eventName
     except Exception as e:
         print e
开发者ID:kg-bot,项目名称:SupyBot,代码行数:7,代码来源: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: __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


示例13: __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


示例14: stop_previous_task

 def stop_previous_task(self, task):
     try:
         schedule.removeEvent(task)
         return 'Stopped'
         pass
     except:
         pass
开发者ID:kg-bot,项目名称:SupyBot,代码行数:7,代码来源:plugin.py


示例15: die

 def die(self):
     try:
         schedule.removeEvent(self.name())
         schedule.removeEvent(self.name() + 'b')
     except AssertionError:
         pass
     self.cache.clear()
开发者ID:bnrubin,项目名称:ubuntu-bots,代码行数:7,代码来源:plugin.py


示例16: cutwire

 def cutwire(self, irc, cutWire):
     self.cutWire = cutWire
     self.responded = True
     specialWires = False
     if self.rng.randint(1,len(self.wires)) == 1 or self.victim.lower()=='jacksonmj':
         specialWires = True
     if self.cutWire.lower() == 'potato' and specialWires:
         self.irc.queueMsg(ircmsgs.privmsg(self.channel, '%s has turned the bomb into a potato! This has rendered it mostly harmless, and slightly %s.' % (self.victim, self.goodWire)))
         self.defuse()
     elif self.cutWire.lower() == 'pizza' and specialWires:
         self.irc.queueMsg(ircmsgs.privmsg(self.channel, '%s has turned the bomb into a pizza! %s\'s pants have been ruined by the pizza stuffed into them, but at least they haven\'t exploded.' % (self.victim, self.victim)))
         self.defuse()
     elif self.goodWire.lower() == self.cutWire.lower():
         self.irc.queueMsg(ircmsgs.privmsg(self.channel, '%s has cut the %s wire!  This has defused the bomb!' % (self.victim, self.cutWire)))
         if self.victim.lower() != self.sender.lower():
             self.irc.queueMsg(ircmsgs.privmsg(self.channel, 'He then quickly rearms the bomb and throws it back at %s with just seconds on the clock!' % self.sender))
             tmp = self.victim
             self.victim = self.sender
             self.sender = tmp
             self.thrown = True
             schedule.rescheduleEvent('%s_bomb' % self.channel, time.time() + 10)
             if self.victim == irc.nick:
                 time.sleep(1)
                 self.irc.queueMsg(ircmsgs.privmsg(self.channel, '@duck'))
                 time.sleep(1)
                 self.duck(self.irc, irc.nick)
         else:
             self.defuse()
     else:
         schedule.removeEvent('%s_bomb' % self.channel)
         self.detonate(irc)
开发者ID:jacksonmj,项目名称:StewieGriffin,代码行数:31,代码来源:plugin.py


示例17: die

 def die(self):
     for user in self._users:
         schedule.removeEvent(user)
     for search in self._searches:
         schedule.removeEvent(search)
     self._streams = []
     self._searches = []
开发者ID:ArtRichards,项目名称:Supybot-plugins,代码行数:7,代码来源:plugin.py


示例18: answer

 def answer(self, msg):
     correct = False
     for ans in self.a:
         dist = self.DL(str.lower(msg.args[1]), str.lower(ans))
         flexibility = self.registryValue('flexibility', self.channel)
         if dist <= len(ans) / flexibility:
             correct = True
         #if self.registryValue('debug'):
         #    self.reply('Distance: %d' % dist)
     if correct:
         if not msg.nick in self.scores:
             self.scores[msg.nick] = 0
         self.scores[msg.nick] += 1
         if not msg.nick in self.roundscores:
             self.roundscores[msg.nick] = 0
         self.roundscores[msg.nick] += 1
         self.unanswered = 0
         gotit = '%s got it!' % (msg.nick)
         gotit = ircutils.bold(gotit)
         points= ircutils.bold('Points')
         self.reply('%s The full answer was: %s. %s: %d' %
                    (gotit, self.a[0], points, self.scores[msg.nick]))
         schedule.removeEvent('next_%s' % self.channel)
         self.writeScores()
         self.newquestion()
开发者ID:GlitterCakes,项目名称:PoohBot,代码行数:25,代码来源:plugin.py


示例19: __init__

 def __init__(self, irc, channel, num, plugin):
     self.rng = random.Random()
     self.rng.seed()
     self.registryValue = plugin.registryValue
     self.irc = irc
     self.channel = channel
     self.num = num
     self.numAsked = 0
     self.hints = 0
     self.games = plugin.games
     self.scores = plugin.scores
     self.scorefile = plugin.scorefile
     self.questionfile = self.registryValue('questionFile')
     self.total = num
     self.active = True
     self.questions = []
     self.roundscores = {}
     self.unanswered = 0
     f = open(self.questionfile, 'r')
     line = f.readline()
     while line:
         self.questions.append(line.strip('\n\r'))
         line = f.readline()
     f.close()
     try:
         schedule.removeEvent('next_%s' % self.channel)
     except KeyError:
         pass
     self.newquestion()
开发者ID:AlanBell,项目名称:Supybot-plugins,代码行数:29,代码来源:plugin.py


示例20: start

    def start(self, irc, msg, args, channel, num):
        """[<channel>] [<number of questions>]

        Starts a game of trivia.  <channel> is only necessary if the message
        isn't sent in the channel itself."""
        if num == None:
            num = self.registryValue('defaultRoundLength', channel)
        #elif num > 100:
        #    irc.reply('sorry, for now, you can\'t start games with more '
        #              'than 100 questions :(')
        #    num = 100
        channel = ircutils.toLower(channel)
        if channel in self.games:
            if not self.games[channel].active:
                del self.games[channel]
                try:
                    schedule.removeEvent('next_%s' % channel)
                except KeyError:
                    pass
                irc.reply(_('Orphaned trivia game found and removed.'))
            else:
                self.games[channel].num += num
                self.games[channel].total += num
                irc.reply(_('%d questions added to active game!') % num)
        else:
            self.games[channel] = self.Game(irc, channel, num, self)
        irc.noReply()
开发者ID:AlanBell,项目名称:Supybot-plugins,代码行数:27,代码来源:plugin.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.exnToString函数代码示例发布时间:2022-05-27
下一篇:
Python schedule.addPeriodicEvent函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap