Ejemplo n.º 1
0
		def new_privmsg(target, text):
			if irc.client.is_channel(target):
				username = config["username"]
				chatlog.log_chat(irc.client.Event("pubmsg", username, target, [text]), SELF_METADATA)
				original_privmsg(target, text)
			elif self.whisperconn:
				self.whisperconn.whisper(target, text)
			else:
				log.debug("Not sending private message to %s: %s", target, text)
Ejemplo n.º 2
0
		def new_privmsg(target, text):
			if irc.client.is_channel(target):
				username = config["username"]
				text = utils.trim_length(text, do_warn=True)
				chatlog.log_chat(irc.client.Event("pubmsg", username, target, [text]), SELF_METADATA)
				original_privmsg(target, text)
			elif self.whisperconn:
				self.whisperconn.whisper(target, text)
			else:
				log.info("Not sending private message to %s: %s", target, text)
Ejemplo n.º 3
0
 def new_privmsg(target, text):
     if irc.client.is_channel(target):
         username = config["username"]
         chatlog.log_chat(
             irc.client.Event("pubmsg", username, target, [text]),
             SELF_METADATA)
         original_privmsg(target, text)
     elif self.whisperconn:
         self.whisperconn.whisper(target, text)
     else:
         log.info("Not sending private message to %s: %s", target, text)
Ejemplo n.º 4
0
    def on_message(self, conn, event):
        source = irc.client.NickMask(event.source)
        nick = source.nick.lower()

        tags = dict((i['key'], i['value']) for i in event.tags)
        metadata = {
            'usercolor': tags.get('color'),
            'emotes': tags.get('emotes'),
            'display-name': tags.get('display-name') or nick,
            'specialuser': set(),
        }
        if int(tags.get('subscriber', 0)):
            metadata['specialuser'].add('subscriber')
        if int(tags.get('turbo', 0)):
            metadata['specialuser'].add('turbo')
        if tags.get('user-type'):
            metadata['specialuser'].add(tags.get('user-type'))
        if self.is_mod(event):
            metadata['specialuser'].add('mod')
        log.debug("Message metadata: %r", metadata)

        chatlog.log_chat(event, metadata)
        if not hasattr(conn.privmsg, "is_throttled"):
            conn.privmsg = utils.twitch_throttle()(conn.privmsg)
        if not hasattr(conn.privmsg, "is_logged"):
            conn.privmsg = self.log_outgoing(conn.privmsg)
        source = irc.client.NickMask(event.source)
        # If the message was sent to a channel, respond in the channel
        # If it was sent via PM, respond via PM
        if irc.client.is_channel(event.target):
            respond_to = event.target
        else:
            respond_to = source.nick

        if (nick == config['notifyuser']):
            self.on_notification(conn, event, respond_to)
        elif self.check_spam(conn, event, event.arguments[0]):
            return
        else:
            self.check_subscriber(conn, nick, metadata)
            if self.access == "mod" and not self.is_mod(event):
                return
            if self.access == "sub" and not self.is_mod(
                    event) and not self.is_sub(event):
                return
            command_match = self.re_botcommand.match(event.arguments[0])
            if command_match:
                command = command_match.group(command_match.lastindex)
                log.info("Command from %s: %s " % (source.nick, command))
                proc, end = self.command_groups[command_match.lastindex]
                params = command_match.groups()[command_match.lastindex:end]
                proc(self, conn, event, respond_to, *params)
Ejemplo n.º 5
0
	def on_message(self, conn, event):
		self.check_privmsg_wrapper(conn)

		source = irc.client.NickMask(event.source)
		nick = source.nick.lower()

		if event.type == "pubmsg":
			tags = dict((i['key'], i['value']) for i in event.tags)
			metadata = {
				'usercolor': tags.get('color'),
				'emotes': tags.get('emotes'),
				'display-name': tags.get('display-name') or nick,
				'specialuser': set(),
			}
			if int(tags.get('subscriber', 0)):
				metadata['specialuser'].add('subscriber')
			if int(tags.get('turbo', 0)):
				metadata['specialuser'].add('turbo')
			if tags.get('user-type'):
				metadata['specialuser'].add(tags.get('user-type'))
			if self.is_mod(event):
				metadata['specialuser'].add('mod')
			log.debug("Message metadata: %r", metadata)
			chatlog.log_chat(event, metadata)
			self.check_subscriber(conn, nick, metadata)

		source = irc.client.NickMask(event.source)
		# If the message was sent to a channel, respond in the channel
		# If it was sent via PM, respond via PM
		if event.type == "pubmsg":
			respond_to = event.target
		else:
			respond_to = source.nick

		if (nick == config['notifyuser']):
			self.on_notification(conn, event, respond_to)
		elif self.check_spam(conn, event, event.arguments[0]):
			return
		else:
			asyncio.async(self.check_urls(conn, event, event.arguments[0]), loop=self.loop).add_done_callback(utils.check_exception)
			if self.access == "mod" and not self.is_mod(event):
				return
			if self.access == "sub" and not self.is_mod(event) and not self.is_sub(event):
				return
			command_match = self.re_botcommand.match(event.arguments[0])
			if command_match:
				command = command_match.group(command_match.lastindex)
				log.info("Command from %s: %s " % (source.nick, command))
				proc, end = self.command_groups[command_match.lastindex]
				params = command_match.groups()[command_match.lastindex:end]
				asyncio.async(proc(self, conn, event, respond_to, *params), loop=self.loop).add_done_callback(utils.check_exception)
Ejemplo n.º 6
0
    def on_message(self, conn, event):
        source = irc.client.NickMask(event.source)
        nick = source.nick.lower()

        tags = dict((i["key"], i["value"]) for i in event.tags)
        metadata = {
            "usercolor": tags.get("color"),
            "emotes": tags.get("emotes"),
            "display-name": tags.get("display-name") or nick,
            "specialuser": set(),
        }
        if int(tags.get("subscriber", 0)):
            metadata["specialuser"].add("subscriber")
        if int(tags.get("turbo", 0)):
            metadata["specialuser"].add("turbo")
        if tags.get("user-type"):
            metadata["specialuser"].add(tags.get("user-type"))
        if self.is_mod(event):
            metadata["specialuser"].add("mod")
        log.debug("Message metadata: %r", metadata)

        chatlog.log_chat(event, metadata)
        if not hasattr(conn.privmsg, "is_throttled"):
            conn.privmsg = utils.twitch_throttle()(conn.privmsg)
        if not hasattr(conn.privmsg, "is_logged"):
            conn.privmsg = self.log_outgoing(conn.privmsg)
        source = irc.client.NickMask(event.source)
        # If the message was sent to a channel, respond in the channel
        # If it was sent via PM, respond via PM
        if irc.client.is_channel(event.target):
            respond_to = event.target
        else:
            respond_to = source.nick

        if nick == config["notifyuser"]:
            self.on_notification(conn, event, respond_to)
        elif self.check_spam(conn, event, event.arguments[0]):
            return
        else:
            self.check_subscriber(conn, nick, metadata)
            if self.access == "mod" and not self.is_mod(event):
                return
            if self.access == "sub" and not self.is_mod(event) and not self.is_sub(event):
                return
            command_match = self.re_botcommand.match(event.arguments[0])
            if command_match:
                command = command_match.group(command_match.lastindex)
                log.info("Command from %s: %s " % (source.nick, command))
                proc, end = self.command_groups[command_match.lastindex]
                params = command_match.groups()[command_match.lastindex : end]
                proc(self, conn, event, respond_to, *params)
Ejemplo n.º 7
0
 def log_chat(self, conn, event):
     source = irc.client.NickMask(event.source)
     metadata = {
         'usercolor': event.tags.get('color'),
         'emotes': event.tags.get('emotes'),
         'display-name': event.tags.get('display-name') or source.nick,
         'specialuser': set(),
     }
     if event.tags.get('subscriber'):
         metadata['specialuser'].add('subscriber')
     if int(event.tags.get('turbo', 0)):
         metadata['specialuser'].add('turbo')
     if event.tags.get('user-type'):
         metadata['specialuser'].add(event.tags.get('user-type'))
     if event.tags.get('mod'):
         metadata['specialuser'].add('mod')
     if event.tags.get('bits'):
         metadata['specialuser'].add('cheer')
     log.debug("Message metadata: %r", metadata)
     chatlog.log_chat(event, metadata)
Ejemplo n.º 8
0
	def log_chat(self, conn, event):
		source = irc.client.NickMask(event.source)
		metadata = {
			'usercolor': event.tags.get('color'),
			'emotes': event.tags.get('emotes'),
			'display-name': event.tags.get('display-name') or source.nick,
			'specialuser': set(),
			'id': event.tags.get('id'),
		}
		if event.tags.get('subscriber'):
			metadata['specialuser'].add('subscriber')
		if int(event.tags.get('turbo', 0)):
			metadata['specialuser'].add('turbo')
		if event.tags.get('user-type'):
			metadata['specialuser'].add(event.tags.get('user-type'))
		if event.tags.get('mod'):
			metadata['specialuser'].add('mod')
		if event.tags.get('bits'):
			metadata['specialuser'].add('cheer')
		log.debug("Message metadata: %r", metadata)
		chatlog.log_chat(event, metadata)
Ejemplo n.º 9
0
 def wrapper(target, message):
     username = config["username"]
     chatlog.log_chat(
         irc.client.Event("pubmsg", username, target, [message]),
         SELF_METADATA)
     return func(target, message)
Ejemplo n.º 10
0
 def wrapper(target, message):
     username = config["username"]
     chatlog.log_chat(irc.client.Event("pubmsg", username, target, [message]), SELF_METADATA)
     return func(target, message)