示例#1
0
    def command(self, event):
        if not event.command in self._module_data['commands']:
            return

        for seq in self._module_data['commands'][event.command]['sequence']:
            command_args = seq['command'].split()
            message = ' '.join(command_args[1:])
            if not message:
                message = event.message
            command_event = ChatCommandEvent(command_args[0],
                                             message,
                                             event.display_name,
                                             event.user_id,
                                             event.is_vip,
                                             event.is_mod,
                                             event.is_broadcaster,
                                             bypass_permissions=True,
                                             original_message=event.message,
                                             **event.kwargs)
            if seq['delay'] == 0:
                self.event_loop.event_queue.put(command_event)
            else:
                delay = seq['delay'] / 1000
                t = threading.Thread(target=self._delayed_event_queue,
                                     args=(command_event, delay))
                t.start()
示例#2
0
    def points_redeemed(self, event):
        message = f"{event.display_name} just redeemed {event.title} for {event.cost} points!"
        self.print(message)
        if not event.reward_id in self._channel_point_data['attachments']:
            return

        command = self._channel_point_data['attachments'][event.reward_id].get(
            'command')
        user_input = event.user_input.lower() if event.user_input else ''
        if user_input in self._channel_point_data['attachments'][
                event.reward_id].get('message_command', {}):
            command = self._channel_point_data['attachments'][
                event.reward_id]['message_command'][user_input]

        if command:
            command_args = command.split()
            message = ' '.join(command_args[1:])
            if not message:
                message = user_input
            command_event = ChatCommandEvent(command_args[0],
                                             message,
                                             event.display_name,
                                             event.user_id,
                                             False,
                                             False,
                                             False,
                                             bypass_permissions=True)
            self.event_loop.event_queue.put(command_event)
示例#3
0
	def bits(self, event):
		message = None
		if event.is_anonymous:
			message = f"An anonymous viewer cheered {event.bits_used} bits!"
		else:
			message = f"{event.display_name} just cheered {event.bits_used} bits!"

		if message is not None:
			self.print(message)

		command = self._module_data['attachments'].get('cheer')
		if not command:
			return

		command_args = command.split()
		message = ' '.join(command_args[1:])
		if not message:
			message = event.message
		command_event = ChatCommandEvent(
			command_args[0],
			message,
			event.display_name,
			event.user_id,
			False,
			False,
			False,
			bypass_permissions = True,
			bits_used = event.bits_used,
			total_bits_used = event.total_bits_used,
			cheer_message = event.message
		)
		self.event_loop.event_queue.put(command_event)
示例#4
0
    def send_first_message_command(self, event):
        command = ChatCommandEvent(self._sound_command,
                                   event.message,
                                   event.display_name,
                                   event.user_id,
                                   event.is_vip,
                                   event.is_mod,
                                   event.is_broadcaster,
                                   bypass_permissions=False,
                                   run_by_command=False)

        self.event_loop.event_queue.put(command)
示例#5
0
 def message_received(self, display_name, user_id, is_vip, is_mod,
                      is_broadcaster, message):
     match = re.search(r'^!([^ ]+)(.*)', message)
     if match:
         command = match.group(1)
         args = match.group(2).strip()
         event = ChatCommandEvent(command, args, display_name, user_id,
                                  is_vip, is_mod, is_broadcaster)
         self.event_queue.put(event)
     message_event = ChatMessageEvent(message, display_name, user_id,
                                      is_vip, is_mod, is_broadcaster)
     self.event_queue.put(message_event)
示例#6
0
    def command(self, event):
        if event.command not in self._module_data['commands']:
            return

        rand_command = random.choice(
            self._module_data['commands'][event.command])
        command_event = ChatCommandEvent(rand_command,
                                         event.message,
                                         event.display_name,
                                         event.user_id,
                                         False,
                                         False,
                                         False,
                                         bypass_permissions=True)
        self.event_loop.event_queue.put(command_event)
示例#7
0
	def host(self, event):
		message = f"Just hosted by {event.display_name}!"
		self.print(message)

		command_str = self._module_data['attachments'].get('host')
		if command_str is not None:
			command_args = command_str.split()
			message = ' '.join(command_args[1:])
			command_event = ChatCommandEvent(
				command_args[0],
				message,
				event.display_name,
				event.user_id,
				False,
				False,
				False,
				bypass_permissions = True
			)
			self.event_loop.event_queue.put(command_event)
示例#8
0
	def raid(self, event):
		message = f"Just raided by {event.display_name} with {event.viewer_count} viewers!"
		self.print(message)

		command_str = self._module_data['attachments'].get('raid')
		if command_str is not None:
			command_args = command_str.split()
			message = ' '.join(command_args[1:])
			command_event = ChatCommandEvent(
				command_args[0],
				message,
				event.display_name,
				event.user_id,
				False,
				False,
				False,
				bypass_permissions = True,
				viewer_count = event.viewer_count
			)
			self.event_loop.event_queue.put(command_event)
示例#9
0
	def subscription(self, event):
		message = None
		if event.is_anonymous:
			message = f"Anonymous sub ({event.sub_tier_name}) was gifted to {event.recipient_display_name}"
		elif event.is_gift:
			message = f"{event.display_name} gifted a {event.duration} month {event.sub_tier_name} sub to {event.recipient_display_name}"
		else:
			message = f"{event.display_name} just subscribed! ({event.sub_tier_name}, {event.cumulative_months} months)"

		if message is not None:
			self.print(message)

		if event.is_gift:
			command = self._module_data['attachments'].get('gift')
			tier_command = self._module_data['attachments'].get(f'gift{event.sub_tier}')
			if tier_command is not None:
				command = tier_command

			if command:
				## First item in the command str is the command name
				## followed by args. If there are no args pass the message
				## from the event.
				command_args = command.split()
				message = ' '.join(command_args[1:])
				#if not message:
				#	message = event.message
				command_event = ChatCommandEvent(
					command_args[0],
					message,
					event.display_name,
					event.user_id,
					False,
					False,
					False,
					bypass_permissions = True,
					context = event.context,
					sub_plan = event.sub_plan,
					sub_plan_name = event.sub_plan_name,
					cumulative_months = event.cumulative_months,
					streak_months = event.streak_months,
					recipient_display_name = event.recipient_display_name,
					recipient_id = event.recipient_id,
					duration = event.duration,
					sub_tier_name = event.sub_tier_name
				)
				self.event_loop.event_queue.put(command_event)
		else:
			command = self._module_data['attachments'].get('sub')
			tier_command = self._module_data['attachments'].get(f'sub{event.sub_tier}')
			if tier_command is not None:
				command = tier_command
			if command:
				## First item in the command str is the command name
				## followed by args. If there are no args pass the message
				## from the event.
				command_args = command.split()
				message = ' '.join(command_args[1:])
				#if not message:
				#	message = event.message
				command_event = ChatCommandEvent(
					command_args[0],
					message,
					event.display_name,
					event.user_id,
					False,
					False,
					False,
					bypass_permissions = True,
					context = event.context,
					sub_plan = event.sub_plan,
					sub_plan_name = event.sub_plan_name,
					cumulative_months = event.cumulative_months,
					streak_months = event.streak_months,
					sub_message = event.message,
					sub_tier_name = event.sub_tier_name,
					duration = 1
				)
				self.event_loop.event_queue.put(command_event)