示例#1
0
	def mooReply(self, irc, msg, match):
		r'^((./door |!|.+:\s+)?moo+)+[\s.]*$'
		self.log.info('moo detected')
		if random.random()<0.05:
			if random.random()<0.5:
				text = 'mooMOOmooMOOmoomooMOO'
			else:
				text = 'POTATOES'
			colors = utils.iter.cycle([4, 7, 8, 3, 2, 12, 6])
			L = [self._color(c, fg=colors.next()) for c in unicode(ircutils.stripColor(text), 'utf-8')]
			irc.reply(''.join(L).encode('utf-8') + '\x03', prefixNick=False)
示例#2
0
    def colorize(self, irc, msg, args, text):
        """<text>

        Returns <text> with each character randomly colorized.
        """
        if minisix.PY2:
            text = text.decode('utf-8')
        text = ircutils.stripColor(text)
        L = [self._color(c) for c in text]
        if minisix.PY2:
            L = [c.encode('utf-8') for c in L]
        irc.reply('%s%s' % (''.join(L), '\x03'))
示例#3
0
    def colorize(self, irc, msg, args, text):
        """<text>

        Returns <text> with each character randomly colorized.
        """
        if minisix.PY2:
            text = text.decode('utf-8')
        text = ircutils.stripColor(text)
        L = [self._color(c) for c in text]
        if minisix.PY2:
            L = [c.encode('utf-8') for c in L]
        irc.reply('%s%s' % (''.join(L), '\x03'))
示例#4
0
    def rainbow(self, irc, msg, args, text):
        """<text>

        Returns <text> colorized like a rainbow.
        """
        if minisix.PY2:
            text = text.decode('utf-8')
        text = ircutils.stripColor(text)
        colors = utils.iter.cycle(['05', '04', '07', '08', '09', '03', '11',
                                   '10', '12', '02', '06', '13'])
        L = [self._color(c, fg=next(colors)) for c in text]
        if minisix.PY2:
            L = [c.encode('utf-8') for c in L]
        irc.reply(''.join(L) + '\x03')
示例#5
0
    def rainbow(self, irc, msg, args, text):
        """<text>

        Returns <text> colorized like a rainbow.
        """
        if minisix.PY2:
            text = text.decode('utf-8')
        text = ircutils.stripColor(text)
        colors = utils.iter.cycle(['05', '04', '07', '08', '09', '03', '11',
                                   '10', '12', '02', '06', '13'])
        L = [self._color(c, fg=next(colors)) for c in text]
        if minisix.PY2:
            L = [c.encode('utf-8') for c in L]
        irc.reply(''.join(L) + '\x03')
示例#6
0
    def mooReply(self, irc, msg, match):
        r"""^((./door |!|.+:\s+)?moo+)+[\s.]*$"""

        self.log.info("moo detected")
        if random.random() < 0.05:
            if random.random() < 0.5:
                text = "mooMOOmooMOOmoomooMOO"
            else:
                text = "POTATOES"
            colors = utils.iter.cycle([4, 7, 8, 3, 2, 12, 6])
            L = [
                self._color(c, fg=colors.next())
                for c in str(ircutils.stripColor(text), "utf-8")
            ]

            if self.registryValue('enableMooReply', msg.args[0]):
                irc.reply("".join(L).encode("utf-8") + "\x03",
                          prefixNick=False)
            else:
                return
示例#7
0
 def youtube(self, irc, msg, args):
     (recipients, text) = msg.args
     text = text.replace(".youtube ", "")
     yt_service = self.service
     query = gdata.youtube.service.YouTubeVideoQuery()
     query.vq = text
     query.orderby = 'relevance'
     query.racy = 'include'
     query.max_results = 3
     feed = yt_service.YouTubeQuery(query)
     logo1 = 'You'
     logo2 = 'Tube'
     logo1 = ircutils.bold(ircutils.mircColor(logo1, '1', '0'))
     logo2 = ircutils.bold(ircutils.mircColor(logo2, '0', '4'))
     text = ircutils.stripColor(text)
     i=1
     irc.reply("Top %s%s results for '%s':" % (logo1, logo2, text), private=True)
     for entry in feed.entry:
         irc.reply(format(ircutils.bold(ircutils.mircColor(i, '12')) + ircutils.bold(ircutils.mircColor(". ", '12')) + '%s <%s>', ircutils.bold(entry.media.title.text),entry.media.player.url),notice=False,prefixNick=False,private=True)
         i=1+i
示例#8
0
    def stripcolor(self, irc, msg, args, text):
        """<text>

        Returns <text> stripped of all color codes.
        """
        irc.reply(ircutils.stripColor(text))
示例#9
0
 def testStripColor(self):
     self.assertEqual(
         ircutils.stripColor('\x02bold\x0302,04foo\x03bar\x0f'),
         '\x02boldfoobar\x0f')
     self.assertEqual(ircutils.stripColor('\x03foo\x03'), 'foo')
     self.assertEqual(ircutils.stripColor('\x03foo\x0F'), 'foo\x0F')
     self.assertEqual(ircutils.stripColor('\x0312foo\x03'), 'foo')
     self.assertEqual(ircutils.stripColor('\x0312,14foo\x03'), 'foo')
     self.assertEqual(ircutils.stripColor('\x03,14foo\x03'), 'foo')
     self.assertEqual(ircutils.stripColor('\x03,foo\x03'), ',foo')
     self.assertEqual(ircutils.stripColor('\x0312foo\x0F'), 'foo\x0F')
     self.assertEqual(ircutils.stripColor('\x0312,14foo\x0F'), 'foo\x0F')
     self.assertEqual(ircutils.stripColor('\x03,14foo\x0F'), 'foo\x0F')
     self.assertEqual(ircutils.stripColor('\x03,foo\x0F'), ',foo\x0F')
示例#10
0
 def testStripColor(self):
     self.assertEqual(ircutils.stripColor('\x02bold\x0302,04foo\x03bar\x0f'),
                      '\x02boldfoobar\x0f')
     self.assertEqual(ircutils.stripColor('\x03foo\x03'), 'foo')
     self.assertEqual(ircutils.stripColor('\x03foo\x0F'), 'foo\x0F')
     self.assertEqual(ircutils.stripColor('\x0312foo\x03'), 'foo')
     self.assertEqual(ircutils.stripColor('\x0312,14foo\x03'), 'foo')
     self.assertEqual(ircutils.stripColor('\x03,14foo\x03'), 'foo')
     self.assertEqual(ircutils.stripColor('\x03,foo\x03'), ',foo')
     self.assertEqual(ircutils.stripColor('\x0312foo\x0F'), 'foo\x0F')
     self.assertEqual(ircutils.stripColor('\x0312,14foo\x0F'), 'foo\x0F')
     self.assertEqual(ircutils.stripColor('\x03,14foo\x0F'), 'foo\x0F')
     self.assertEqual(ircutils.stripColor('\x03,foo\x0F'), ',foo\x0F')
示例#11
0
 def testStripColor(self):
     self.assertEqual(ircutils.stripColor("\x02bold\x0302,04foo\x03bar\x0f"), "\x02boldfoobar\x0f")
     self.assertEqual(ircutils.stripColor("\x03foo\x03"), "foo")
     self.assertEqual(ircutils.stripColor("\x03foo\x0F"), "foo\x0F")
     self.assertEqual(ircutils.stripColor("\x0312foo\x03"), "foo")
     self.assertEqual(ircutils.stripColor("\x0312,14foo\x03"), "foo")
     self.assertEqual(ircutils.stripColor("\x03,14foo\x03"), "foo")
     self.assertEqual(ircutils.stripColor("\x03,foo\x03"), ",foo")
     self.assertEqual(ircutils.stripColor("\x0312foo\x0F"), "foo\x0F")
     self.assertEqual(ircutils.stripColor("\x0312,14foo\x0F"), "foo\x0F")
     self.assertEqual(ircutils.stripColor("\x03,14foo\x0F"), "foo\x0F")
     self.assertEqual(ircutils.stripColor("\x03,foo\x0F"), ",foo\x0F")