Example #1
0
def showCmdUsage(f):
    info = f.command

    if 'usage' in info:
        cmd = irc.bold("/twitch %s %s" % (info['name'], info['usage']))
    else:
        cmd = irc.bold("/twitch %s" % info['name'])

    print("Usage: %s - %s" % (cmd, info['desc']))

    if 'detail' in info:
        detail = info['detail']
        if type(detail) is list:
            for line in detail:
                print(irc.format(line))
        else:
            print(irc.format(detail))

    if 'example' in info:
        print(irc.format("Example: %B/twitch %s%B") % info['example'])
Example #2
0
def showCmdUsage(f):
	info  = f.command
	
	if 'usage' in info:
		cmd = irc.bold("/twitch %s %s" % (info['name'], info['usage']))
	else:
		cmd = irc.bold("/twitch %s" % info['name'])
	
	print("Usage: %s - %s" % (cmd, info['desc']))
	
	if 'detail' in info:
		detail = info['detail']
		if type(detail) is list:
			for line in detail:
				print(irc.format(line))
		else:
			print(irc.format(detail))
	
	if 'example' in info:
		print(irc.format("Example: %B/twitch %s%B") % info['example'])
Example #3
0
    def makeTopic(self):
        attrs = {}
        for k, v in self.__dict__.items():
            #log.debug("attrs[%s] = %s", k, v)
            attrs[k] = v

        if self.online:
            attrs['online'] = '%C(green)[LIVE]'
        else:
            attrs['online'] = '%C(red)[OFFLINE]'

        if self.mature:
            attrs['mature'] = " %C(red)🔞%R"
        else:
            attrs['mature'] = ""

        #attrs['displayName'] = irc.color('yellow', attrs['displayName'])
        #attrs['game']        = irc.color('yellow', attrs['game'])

        # add commas to numbers
        log.debug("viewers = %s (%s)", attrs['viewers'],
                  type(attrs['viewers']))
        attrs['viewers'] = locale.format('%d', attrs['viewers'], grouping=True)
        attrs['followers'] = locale.format('%d',
                                           attrs['followers'],
                                           grouping=True)
        attrs['views'] = locale.format('%d', attrs['views'], grouping=True)

        topic = \
         "%B{online}%R{mature} 👤{viewers} ♥{followers} 👁{views} | " + \
         "{title} | %C(yellow){displayName}%R playing %C(yellow){game}%R"
        topic = irc.format(topic.format(**attrs))

        if topic == self.topic:
            log.debug("%s.makeTopic(): topic not changed", self)
            return None

        self.topic = topic
        return topic
Example #4
0
def emote(param, param_eol):
    action = param[0]

    if action == 'set':
        if len(param) < 3:
            raise BadParameterError("Usage: emote set text replacement")
        twitch.emotes.set(param[1], param[2])
        twitch.emotes.save()
        print("* %s => %s" % (param[1], irc.format(param[2])))

    elif action == 'del':
        if len(param) < 2:
            raise BadParameterError("Usage: emote del name")
        twitch.emotes.delete(param[1])
        twitch.emotes.save()
        print("* %s deleted" % param[1])

    elif action == 'reload':
        twitch.emotes.load()
        print("* Loaded %d emotes" % len(twitch.emotes.emotes))

    elif action == 'list':
        for key in twitch.emotes.parsed_emotes:
            print("* %s => %s" % (key, twitch.emotes.parsed_emotes[key]))

    elif action == 'show':
        if len(param) < 2:
            raise BadParameterError("Usage: emote show name")
        name = param[1]
        if name in twitch.emotes.parsed_emotes:
            print("* %s => %s" % (name, twitch.emotes.parsed_emotes[name]))
        else:
            print("* No emote '%s' defined" % name)

    else:
        raise BadParameterError("Unknown action '%s'" % action)
Example #5
0
def emote(param, param_eol):
	action = param[0]
	
	if action == 'set':
		if len(param) < 3:
			raise BadParameterError("Usage: emote set text replacement")
		twitch.emotes.set(param[1], param[2])
		twitch.emotes.save()
		print("* %s => %s" % (param[1], irc.format(param[2])))
	
	elif action == 'del':
		if len(param) < 2:
			raise BadParameterError("Usage: emote del name")
		twitch.emotes.delete(param[1])
		twitch.emotes.save()
		print("* %s deleted" % param[1])
	
	elif action == 'reload':
		twitch.emotes.load()
		print("* Loaded %d emotes" % len(twitch.emotes.emotes))
	
	elif action == 'list':
		for key in twitch.emotes.parsed_emotes:
			print("* %s => %s" % (key, twitch.emotes.parsed_emotes[key]))
	
	elif action == 'show':
		if len(param) < 2:
			raise BadParameterError("Usage: emote show name")
		name = param[1]
		if name in twitch.emotes.parsed_emotes:
			print("* %s => %s" % (name, twitch.emotes.parsed_emotes[name]))
		else:
			print("* No emote '%s' defined" % name)
	
	else:
		raise BadParameterError("Unknown action '%s'" % action)
Example #6
0
	def makeTopic(self):
		attrs = {}
		for k, v in self.__dict__.items():
			#log.debug("attrs[%s] = %s", k, v)
			attrs[k] = v
		
		if self.online:
			attrs['online'] = '%C(green)[LIVE]'
		else:
			attrs['online'] = '%C(red)[OFFLINE]'
			
		if self.mature:
			attrs['mature'] = " %C(red)🔞%R"
		else:
			attrs['mature'] = ""
			
		#attrs['displayName'] = irc.color('yellow', attrs['displayName'])
		#attrs['game']        = irc.color('yellow', attrs['game'])
		
		# add commas to numbers
		log.debug("viewers = %s (%s)", attrs['viewers'], type(attrs['viewers']))
		attrs['viewers']  =locale.format('%d',attrs['viewers'],   grouping=True)
		attrs['followers']=locale.format('%d',attrs['followers'], grouping=True)
		attrs['views']    =locale.format('%d',attrs['views'],     grouping=True)
		
		topic = \
			"%B{online}%R{mature} 👤{viewers} ♥{followers} 👁{views} | " + \
			"{title} | %C(yellow){displayName}%R playing %C(yellow){game}%R"
		topic = irc.format(topic.format(**attrs))
		
		if topic == self.topic:
			log.debug("%s.makeTopic(): topic not changed", self)
			return None
		
		self.topic = topic
		return topic
Example #7
0
def echo(param, param_eol):
    print(irc.format(twitch.emotes.insert(param_eol[0])))
Example #8
0
 def formatMessageText(self, chan, text):
     text = twitch.emotes.insert(text)
     for name, utype in self.getTypes(chan).items():
         if 'format' in utype:
             text = irc.format(utype['format'].format(text))
     return text
Example #9
0
 def getNameBadges(self, chan):
     badges = []
     for name, utype in self.getTypes(chan).items():
         if 'badge' in utype:
             badges.append(irc.format(utype['badge']))
     return badges
Example #10
0
	def formatMessageText(self, chan, text):
		text = twitch.emotes.insert(text)
		for name, utype in self.getTypes(chan).items():
			if 'format' in utype:
				text = irc.format(utype['format'].format(text))
		return text
Example #11
0
	def getNameBadges(self, chan):
		badges = []
		for name, utype in self.getTypes(chan).items():
			if 'badge' in utype:
				badges.append(irc.format(utype['badge']))
		return badges
Example #12
0
def echo(param, param_eol):
	print(irc.format(twitch.emotes.insert(param_eol[0])))