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

Python ircutils.mircColor函数代码示例

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

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



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

示例1: _query_new_smoketest

    def _query_new_smoketest(self, status=False):
        current_smoketest_path = os.path.join(self._workdir, 'tasks/smoketest/current')
        meta_path = os.path.join(current_smoketest_path, 'meta.json')
        if not os.path.exists(meta_path):
            if status:
                self._broadcast("No current smoketest completed")
            return

        f = open(meta_path)
        smoketest_meta = json.load(f)
        f.close()
        
        taskver = smoketest_meta['taskVersion']

        version_unchanged = taskver == self._last_smoketest_version
        if (not status and version_unchanged):
            return

        self._last_smoketest_version = taskver
        if (not status and not version_unchanged):
            msg = "New smoketest"
        else:
            msg = "Current smoketest"
        success = smoketest_meta['success']
        success_str = success and 'successful' or 'failed'
        msg += " %s: %s. " % (taskver, success_str)
        msg += self._workurl + "tasks/smoketest/%s/%s/output.txt" % (success_str, taskver)

        if not success:
            msg = ircutils.mircColor(msg, fg='red')
        else:
            msg = ircutils.mircColor(msg, fg='green')

        self._broadcast(msg)
开发者ID:djdeath,项目名称:gnome-ostree,代码行数:34,代码来源:plugin.py


示例2: wp

    def wp(self, irc, msg, args, wpnum, reason):
        """<number if more than one> <reason>
        """
        name = str.capitalize(msg.nick)
        currentChannel, bot = msg.args[0], 'CAINE'

        if currentChannel == bot:
            irc.reply("You must be in a channel")
        else:
            if wpnum > 1:
                irc.reply("You must spend each point separately.")
            else:
                wpnum = 1
                try:
                    with db.atomic():
                        q = Character.get(Character.name == name)
                        if wpnum >= q.wp_cur:
                            irc.reply(ircutils.mircColor("Not enough willpower available."), prefixNick=False,
                                      private=True)
                        else:
                            wpnew = q.wp_cur - wpnum
                            Character.update(wp_cur=wpnew).where(Character.name == name).execute()
                            Willpower.create(name=name)
                            q = Character.select().where(Character.name == name).get()
                            message = ircutils.mircColor("Willpower spent. Willpower Remaining: {0}/{1}".format(
                                str(q.wp_cur), str(q.wp)), 12)
                            irc.reply(message, prefixNick=False, private=True)
                except Character.DoesNotExist:
                    irc.reply("Character Not Found.", private=True)
开发者ID:Dark-Father,项目名称:caine-bot,代码行数:29,代码来源:plugin.py


示例3: _query_new_task

    def _query_new_task(self, taskname, status=False, announce_success=False, announce_periodic=False):
        querystate = self._update_task_state(taskname, status=status)
        if querystate is None:
            return
        (last_state, new_state, status_msg) = querystate
        last_success = last_state['success']
        success = new_state['success']
        taskver = new_state['taskVersion']
        success_changed = last_success != success
        success_str = success and 'successful' or 'failed'
        millis = float(new_state['elapsedMillis'])
        msg = "gnostree:%s %s: %s in %.1f seconds. %s " \
              % (taskname, taskver, success_str, millis / 1000.0, status_msg)

        msg += "%s/%s/output.txt" % (self._workurl, new_state['path'])

        if not success:
            msg = ircutils.mircColor(msg, fg='red')
        else:
            msg = ircutils.mircColor(msg, fg='green')

        if announce_success:
            self._sendTo(self._flood_channels, msg)
        if ((not announce_periodic and success_changed) or
            (announce_periodic and self._periodic_announce_ticks == self._periodic_announce_seconds)):
            self._sendTo(self._status_channels, msg)
开发者ID:GNOME,项目名称:gnome-ostree,代码行数:26,代码来源:plugin.py


示例4: bp

    def bp(self, irc, msg, args, bpnum, reason):
        name = str.capitalize(msg.nick)
        currentChannel, bot = msg.args[0], 'CAINE'

        if currentChannel == bot:
            irc.reply("You must be in a channel")
        else:
            if not bpnum:
                bpnum = 1

            try:
                with db.atomic():
                    q = Character.get(Character.name == name)
                    if bpnum >= q.bp_cur:
                        irc.reply(ircutils.mircColor("Not enough blood available."),
                                  prefixNick=False, private=True)
                    else:
                        bpnew = q.bp_cur - bpnum
                        Character.update(bp_cur=bpnew).where(Character.name == name).execute()
                        q = Character.select().where(Character.name == name).get()
                        message = ircutils.mircColor("Blood spent. Blood Remaining: {0}/{1}".format(
                            str(q.bp_cur), str(q.bp)), 4)
                        irc.reply(message, prefixNick=False, private=True)
            except Character.DoesNotExist:
                irc.reply("Character Not Found.", private=True)
开发者ID:Dark-Father,项目名称:caine-bot,代码行数:25,代码来源:plugin.py


示例5: present_listing_first

def present_listing_first(res, original_link=False, color_score=False):
	try:
		d = res.get("data", {}).get("children", [{}])[0].get("data",{})
		if d:
			if not original_link:
				d["url"] = "http://www.reddit.com/r/%(subreddit)s/comments/%(id)s/" % d
            
			if color_score:
				score_part = "(%s|%s)[%s]" % (ircutils.bold(ircutils.mircColor("%(ups)s", "orange")),
                                              ircutils.bold(ircutils.mircColor("%(downs)s", "12")),
                                              ircutils.bold(ircutils.mircColor("%(num_comments)s", "dark grey")))
			else:
				score_part = "(%(score)s)"
			title_part = "%(title)s"
			url_part = ircutils.underline("%(url)s")
			nsfw_part = "NSFW"*d['over_18'] or ''
			nsfw_part =ircutils.bold(ircutils.mircColor(nsfw_part, 'red'))
			template = "%s %s %s %s" % (nsfw_part, score_part, title_part, url_part)
			template = (template % d)
			template = template.replace('\n', ' ')
			template = template.replace('&amp;','&')
		
			if d["created_utc"] < time.time() - 2678400:
				return False
			return template
			
    
	except IndexError:
		return None
开发者ID:AwwCookies,项目名称:peacekeeper,代码行数:29,代码来源:plugin.py


示例6: _color

    def _color(self, deg, u):
        """Colorize the temperature. Use the same scale as
        https://github.com/reticulatingspline/Supybot-Weather to match that
        plugin, in case it is also loaded. Code copyright spline, with my
        modifications."""

        # first, convert into F so we only have one table.
        if u == 'c':   # celcius, convert to farenheit, make float
            deg = deg * 9.0/5.0 + 32

        # determine color
        if deg < 10.0:
            color = 'light blue'
        elif 10.0 <= deg <= 32.0:
            color = 'teal'
        elif 32.1 <= deg <= 50.0:
            color = 'blue'
        elif 50.1 <= deg <= 60.0:
            color = 'light green'
        elif 60.1 <= deg <= 70.0:
            color = 'green'
        elif 70.1 <= deg <= 80.0:
            color = 'yellow'
        elif 80.1 <= deg <= 90.0:
            color = 'orange'
        else:
            color = 'red'

        # return
        if u == 'f':    # no need to convert back
            return ircutils.mircColor("{0}°F".format(deg), color)
        elif u == 'c':    # convert back
            return ircutils.mircColor("{0}°C".format((deg - 32) * 5/9), color)
开发者ID:atoponce,项目名称:supybot-plugins,代码行数:33,代码来源:plugin.py


示例7: stfree

    def stfree(self, irc, msg, args):
        """takes no arguments
        Checks #stchambers to see if occupied."""
        channel = "#storyteller"
        bot = str.capitalize(irc.nick)
        storytellers = [x.capitalize() for x in list(irc.state.channels[channel].ops)]
        diff = list(set([x.lower() for x in list(irc.state.channels[channel].users)]) -
                    set([x.lower() for x in list(irc.state.channels[channel].ops)]))
        diff = [x.capitalize() for x in diff]
        if bot in diff:
            diff.pop(diff.index(bot))
        if bot in storytellers:
            storytellers.pop(storytellers.index(bot))

        diff = [ircutils.mircColor(x, 4) for x in diff]

        if diff:
            abbra = "Chambers is " + ircutils.mircColor("BUSY", 4) + ". Occupied by: " + ircutils.bold(", ".join(diff))
            irc.reply(abbra)
        elif not storytellers:
            abbra = "There are no Storytellers logged in. Try again later."
            irc.reply(abbra)
        elif not diff:
            abbra = "Chambers is " + ircutils.mircColor("OPEN", 3) + ". Join #stchambers now!"
            irc.reply(abbra)
开发者ID:Dark-Father,项目名称:caine-bot,代码行数:25,代码来源:plugin.py


示例8: roulette

    def roulette(self, irc, msg, args, spin):
        """[spin]

        Fires the revolver.  If the bullet was in the chamber, you're dead.
        Tell me to spin the chambers and I will.
        """
        if spin:
            self._rouletteBullet = random.randrange(0, 6)
            irc.reply(ircutils.bold(ircutils.mircColor('*SPIN*','10')) + ' Are you feeling lucky?', prefixNick=True)
            return
        channel = msg.args[0]
        if self._rouletteChamber == self._rouletteBullet:
            self._rouletteBullet = random.randrange(0, 6)
            self._rouletteChamber = random.randrange(0, 6)
            if irc.nick in irc.state.channels[channel].ops or \
                    irc.nick in irc.state.channels[channel].halfops:
                irc.queueMsg(ircmsgs.kick(channel, msg.nick, ircutils.bold(ircutils.mircColor('BANG!','4'))))
            else:
                irc.reply(ircutils.bold(ircutils.mircColor('*BANG*','4')) + '...Hey, who put a blank in here?!',
                          prefixNick=True)
            irc.reply('reloads and spins the chambers.', action=True)
        else:
            irc.reply(ircutils.bold(ircutils.mircColor('*click*','14')),prefixNick=True)
            self._rouletteChamber += 1
            self._rouletteChamber %= 6
开发者ID:GlitterCakes,项目名称:PoohBot,代码行数:25,代码来源:plugin.py


示例9: _formatPrivmsg

 def _formatPrivmsg(self, nick, network, msg):
     channel = msg.args[0]
     if self.registryValue("includeNetwork", channel):
         network = "@" + network
     else:
         network = ""
     # colorize nicks
     color = self.registryValue("color", channel)  # Also used further down.
     if color:
         nick = ircutils.IrcString(nick)
         newnick = ircutils.mircColor(nick, *ircutils.canonicalColor(nick))
         colors = ircutils.canonicalColor(nick, shift=4)
         nick = newnick
     if ircmsgs.isAction(msg):
         if color:
             t = ircutils.mircColor("*", *colors)
         else:
             t = "*"
         s = format("%s %s%s %s", t, nick, network, ircmsgs.unAction(msg))
     else:
         if color:
             lt = ircutils.mircColor("<", *colors)
             gt = ircutils.mircColor(">", *colors)
         else:
             lt = "<"
             gt = ">"
         s = format("%s%s%s%s %s", lt, nick, network, gt, msg.args[1])
     return s
开发者ID:technogeeky,项目名称:Supybot,代码行数:28,代码来源:plugin.py


示例10: heart

 def heart(self, irc, msg, args, target):
 	if not target:
 		target=msg.nick
 	text1 = ircutils.mircColor('♥.¸¸.•´¯`•.♥','4')
 	text2 = ircutils.mircColor('♥.•´¯`•.¸¸.♥','4')
 	target = ircutils.bold(target)
 	irc.reply('%s %s %s'%(text1, target, text2))
开发者ID:GlitterCakes,项目名称:PoohBot,代码行数:7,代码来源:plugin.py


示例11: _formatPrivmsg

 def _formatPrivmsg(self, nick, network, msg):
     channel = msg.args[0]
     if self.registryValue('includeNetwork', channel):
         network = '@' + network
     else:
         network = ''
     # colorize nicks
     color = self.registryValue('color', channel) # Also used further down.
     if color:
         nick = ircutils.IrcString(nick)
         newnick = ircutils.mircColor(nick, *ircutils.canonicalColor(nick))
         colors = ircutils.canonicalColor(nick, shift=4)
         nick = newnick
     if ircmsgs.isAction(msg):
         if color:
             t = ircutils.mircColor('*', *colors)
         else:
             t = '*'
         s = format('%s %s%s %s', t, nick, network, ircmsgs.unAction(msg))
     else:
         if color:
             lt = ircutils.mircColor('<', *colors)
             gt = ircutils.mircColor('>', *colors)
         else:
             lt = '<'
             gt = '>'
         s = format('%s%s%s%s %s', lt, nick, network, gt, msg.args[1])
     return s
开发者ID:GlitterCakes,项目名称:PoohBot,代码行数:28,代码来源:plugin.py


示例12: _query_new_build

    def _query_new_build(self, status=False):
        path = os.path.expanduser('~/ostbuild/work/autobuilder-default.json')
        f = open(path)
        data = json.load(f)
        f.close()
        
        builds = data['build']
        if len(builds) == 0:
            if status:
                self._broadcast("No builds")
            return
        latest = None
        latest_failed = None
        # find the first successful build
        for build in reversed(builds):
            if build['state'] == 'running':
                continue
            latest = build
            break
        # find the first failed build
        for build in reversed(builds):
            if build['state'] != 'failed':
                continue
            latest_failed = build
            break
        version = latest['meta']['version']
        version_matches = version == self._last_version
        if (not status and version_matches):
            return

        self._last_version = version
        if (not status and not version_matches):
            msg = "New build"
        else:
            msg = "Current build"
            if status and builds[-1]['state'] == 'running':
                building = builds[-1]
                msg = "Active build: %s; %s" % (building['build-status']['description'], msg)
        if latest['state'] == 'failed' and latest['meta']['version'] != latest_failed['meta']['version']:
            msg += " %s: %s (fails since: %s)." % (version, latest['state'], latest_failed['meta']['version'])
        else:
            msg += " %s: %s." % (version, latest['state'])
        diff = latest['diff']
        if len(diff[0]) > 0:
            msg += " Latest added modules: %s." % (', '.join(diff[0]), )
        if len(diff[1]) > 0:
            msg += " Latest updated modules: %s." % (', '.join(diff[1]), )
        if len(diff[2]) > 0:
            msg += " Latest removed modules: %s." % (', '.join(diff[2]), )

        msg += " http://ostree.gnome.org/work/tasks/%s-build/%s/log" % (data['prefix'],
                                                                        latest['v'])

        if latest['state'] == 'failed':
            msg = ircutils.mircColor(msg, fg='red')
        elif latest['state'] == 'success':
            msg = ircutils.mircColor(msg, fg='green')

        self._broadcast(msg)
开发者ID:gcampax,项目名称:gnome-ostree,代码行数:59,代码来源:plugin.py


示例13: _colorizeString

 def _colorizeString(self, string):
     """Return a string containing colorized portions of common game elements."""
     string = string.replace('Half', ircutils.mircColor('H', 'yellow')).replace('Final', ircutils.mircColor('F', 'red')).replace('F/OT', ircutils.mircColor('F/OT', 'red'))
     string = string.replace('F/OT', ircutils.mircColor('F/2OT', 'red')).replace('1st', ircutils.mircColor('1st', 'green')).replace('2nd', ircutils.mircColor('2nd', 'green'))
     string = string.replace('3rd', ircutils.mircColor('3rd', 'green')).replace('4th', ircutils.mircColor('4th', 'green')).replace('PPD', ircutils.mircColor('PPD', 'yellow'))
     string = string.replace('Dly', ircutils.mircColor('DLY', 'yellow')).replace('Del:', ircutils.mircColor('DLY', 'yellow')).replace('PPD',ircutils.mircColor('PPD', 'yellow'))
     string = string.replace('Del', ircutils.mircColor('DLY', 'yellow')).replace('F/3OT', ircutils.mircColor('F/3OT', 'red')).replace('F/4OT', ircutils.mircColor('F/4OT', 'red'))
     return string
开发者ID:GlitterCakes,项目名称:PoohBot,代码行数:8,代码来源:plugin.py


示例14: _colorize

 def _colorize(self, s, bold=True, color=None):
     if not (color or bold):
         raise ValueError("bold or color must be set")
     elif color and bold:
         return ircutils.bold(ircutils.mircColor(s, color))
     elif bold:
         return ircutils.bold(s)
     elif color:
         return ircutils.mircColor(s, color)
开发者ID:BackupTheBerlios,项目名称:pystocks-svn,代码行数:9,代码来源:plugin.py


示例15: get_youtube_logo

 def get_youtube_logo(self):
     colored_letters = [
         "%s" % ircutils.mircColor("You", fg="red", bg="white"),
         "%s" % ircutils.mircColor("Tube", fg="white", bg="red")
     ]
                     
     yt_logo = "".join(colored_letters)
     
     return yt_logo
开发者ID:kerozene,项目名称:limnoria-plugins,代码行数:9,代码来源:plugin.py


示例16: updown

def updown(x, s=None):
	if x < 0:
		if not s: s = 'down'
		return ircutils.mircColor(s, 'red')
	elif x > 0:
		if not s: s = ' up '
		return ircutils.mircColor(s, 'green')
	else:
		if not s: s = 'same'
		return s
开发者ID:loisaidasam,项目名称:idioterna-stuff,代码行数:10,代码来源:plugin.py


示例17: _fpm

 def _fpm(self, string):
     """Format the string for output with color."""
     try:
         if float(str(string).replace('.0','')) > 0:
             string = ircutils.mircColor((str(string)), 'green')
         else:
             string = ircutils.mircColor((str(string)), 'red')
         return string
     except:
         return ircutils.bold(string)
开发者ID:GlitterCakes,项目名称:PoohBot,代码行数:10,代码来源:plugin.py


示例18: _aspect

 def _aspect(self, i):
     # red if negative
     # green if positive
     # yellow if zero
     if float(i.strip("%s")) < 0:
         return ircutils.mircColor(str(i), "red")
     elif float(i.strip("%s")) > 0:
         return ircutils.mircColor(str(i), "light green")
     else:
         return ircutils.mircColor(str(i), "yellow")
开发者ID:BackupTheBerlios,项目名称:pystocks-svn,代码行数:10,代码来源:plugin.py


示例19: _fml

    def _fml(self, string):
        """Format and color moneyline based on value (-/+)."""

        if string == "":  # empty.
            return "-"
        elif float(str(string).replace('.0','')) > 0:  # positive
            return ircutils.mircColor("+"+(str(string)), 'green')
        elif float(str(string).replace('.0','')) < 0:  # negative
            return ircutils.mircColor((str(string)), 'red')
        else:  # no clue what to do so just bold.
            return ircutils.bold(string)
开发者ID:ctaylors,项目名称:Odds,代码行数:11,代码来源:plugin.py


示例20: status

def status(r):
    """
    Prints the textual status of a release as a formatted string for IRC messages.
    """
    latest = r.last_nuke()
    if latest:
        if latest.isnuke:
            return irc.bold(irc.mircColor('NUKED', fg=7))
        else:
            return irc.bold(irc.mircColor('UNNUKED', fg=3))
    return irc.bold('PRE')
开发者ID:bcowdery,项目名称:supybot-predb-plugin,代码行数:11,代码来源:util.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python ircutils.nickEqual函数代码示例发布时间:2022-05-27
下一篇:
Python ircutils.isUserHostmask函数代码示例发布时间: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