Esempio n. 1
0
    def parse_all_emotes(self, message, twitch_emotes_tag=None):
        # Twitch Emotes
        twitch_emote_instances = self.parse_twitch_emotes_tag(
            twitch_emotes_tag, message)
        twitch_emote_start_indices = {
            instance.start
            for instance in twitch_emote_instances
        }

        # for the other providers, split the message by spaces
        # and then, if word is not a twitch emote, consider ffz channel -> bttv channel ->
        # ffz global -> bttv global in that order.
        third_party_emote_instances = []

        for current_word_index, word in iterate_split_with_index(
                message.split(" ")):
            # ignore twitch emotes
            is_twitch_emote = current_word_index in twitch_emote_start_indices
            if is_twitch_emote:
                continue

            emote = self.match_word_to_emote(word)
            if emote is None:
                # this word is not an emote
                continue

            third_party_emote_instances.append(
                EmoteInstance(start=current_word_index,
                              end=current_word_index + len(word),
                              emote=emote))

        all_instances = twitch_emote_instances + third_party_emote_instances
        all_instances.sort(key=lambda instance: instance.start)

        return all_instances, compute_emote_counts(all_instances)
Esempio n. 2
0
 def twitch_emote_instance(emote_id, code, start, end):
     return EmoteInstance(start=start,
                          end=end,
                          emote=EmoteManager.twitch_emote(emote_id, code))
Esempio n. 3
0
 def twitch_emote_instance(emote_id: str, code: str, start: int, end: int) -> EmoteInstance:
     return EmoteInstance(start=start, end=end, emote=EmoteManager.twitch_emote(emote_id, code))