Example #1
0
File: clip.py Project: zneix/pajbot
    def clip(self, bot, source, **rest):
        if self.settings["subscribers_only"] and source.subscriber is False:
            return True

        if not self.bot.is_online:
            if self.settings["offline_response"] != "":
                self.bot.say(self.settings["offline_response"].format(
                    source=source, streamer=self.bot.streamer_display))
            return True

        try:
            if self.settings["delay_clip"] or (
                    source.name == StreamHelper.get_streamer()) is True:
                clip_id = self.bot.twitch_helix_api.create_clip(
                    StreamHelper.get_streamer_id(),
                    self.bot.bot_token_manager,
                    has_delay=True)
            else:
                clip_id = self.bot.twitch_helix_api.create_clip(
                    StreamHelper.get_streamer_id(), self.bot.bot_token_manager)
        except HTTPError as e:
            if e.response.status_code == 503:
                self.bot.say(
                    f"{source}, Failed to create clip! Does the streamer have clips disabled?"
                )
            elif e.response.status_code != 401:
                self.bot.say(
                    f"{source}, Failed to create clip! Please try again.")
            else:
                self.bot.say(
                    "Error: The bot token does not grant permission to create clips. The bot needs to be re-authenticated to fix this problem."
                )
            return True

        clip_url = "https://clips.twitch.tv/" + clip_id
        if self.settings["thumbnail_check"] is True:
            self.bot.execute_delayed(
                5,
                self.bot.say,
                self.settings["online_response"].format(
                    source=source,
                    streamer=self.bot.streamer_display,
                    clip=clip_url),
            )
        else:
            self.bot.say(self.settings["online_response"].format(
                source=source,
                streamer=self.bot.streamer_display,
                clip=clip_url))
Example #2
0
    def __init__(self):
        from pajbot.apiwrappers.bttv import BTTVAPI

        self.api = BTTVAPI(RedisManager.get())
        self.streamer = StreamHelper.get_streamer()
        self.streamer_id = StreamHelper.get_streamer_id()
        super().__init__()
Example #3
0
 def __init__(self):
     self._global_emotes = []
     self._channel_emotes = []
     self.streamer = StreamHelper.get_streamer()
     self.streamer_id = StreamHelper.get_streamer_id()
     self.global_lookup_table = {}
     self.channel_lookup_table = {}
Example #4
0
    def __init__(self, twitch_helix_api):
        self.twitch_helix_api = twitch_helix_api
        self.streamer = StreamHelper.get_streamer()
        self.streamer_id = StreamHelper.get_streamer_id()
        self.tier_one_emotes = []
        self.tier_two_emotes = []
        self.tier_three_emotes = []

        super().__init__()
Example #5
0
    def __init__(self, api: Optional[EmoteAPI]) -> None:
        self._global_emotes: List[Emote] = []
        self._channel_emotes: List[Emote] = []
        self.streamer = StreamHelper.get_streamer()
        self.streamer_id = StreamHelper.get_streamer_id()
        self.global_lookup_table: Dict[str, Emote] = {}
        self.channel_lookup_table: Dict[str, Emote] = {}

        self.api = api
Example #6
0
    def __init__(self, twitch_helix_api: TwitchHelixAPI) -> None:
        self.twitch_helix_api = twitch_helix_api
        self.streamer = StreamHelper.get_streamer()
        self.streamer_id = StreamHelper.get_streamer_id()
        self.tier_one_emotes: List[Emote] = []
        self.tier_two_emotes: List[Emote] = []
        self.tier_three_emotes: List[Emote] = []

        super().__init__(None)
Example #7
0
    def __init__(self, twitch_v5_api):
        self.api = TwitchEmotesAPI(RedisManager.get())
        self.twitch_v5_api = twitch_v5_api
        self.streamer = StreamHelper.get_streamer()
        self.streamer_id = StreamHelper.get_streamer_id()
        self.tier_one_emotes = []
        self.tier_two_emotes = []
        self.tier_three_emotes = []

        super().__init__()
Example #8
0
    def __init__(self, twitch_helix_api, action_queue) -> None:
        self.action_queue = action_queue
        self.streamer = StreamHelper.get_streamer()
        self.streamer_id = StreamHelper.get_streamer_id()
        self.twitch_emote_manager = TwitchEmoteManager(twitch_helix_api)
        self.ffz_emote_manager = FFZEmoteManager()
        self.bttv_emote_manager = BTTVEmoteManager()
        self.seventv_emote_manager = SevenTVEmoteManager()

        # every 1 hour
        # note: whenever emotes are refreshed (cache is saved to redis), the key is additionally set to expire
        # in one hour. This is to prevent emotes from never refreshing if the bot restarts in less than an hour.
        # (This also means that the bot will never have emotes older than 2 hours)
        ScheduleManager.execute_every(1 * 60 * 60, self.update_all_emotes)

        self.load_all_emotes()
Example #9
0
    def __init__(self, twitch_v5_api, action_queue):
        self.action_queue = action_queue
        self.streamer = StreamHelper.get_streamer()
        self.streamer_id = StreamHelper.get_streamer_id()
        self.twitch_emote_manager = TwitchEmoteManager(twitch_v5_api)
        self.ffz_emote_manager = FFZEmoteManager()
        self.bttv_emote_manager = BTTVEmoteManager()

        self.epm = {}

        try:
            # every 1 hour
            # note: whenever emotes are refreshed (cache is saved to redis), the key is additionally set to expire
            # in one hour. This is to prevent emotes from never refreshing if the bot restarts in less than an hour.
            # (This also means that the bot will never have emotes older than 2 hours)
            ScheduleManager.execute_every(1 * 60 * 60, self.update_all_emotes)
        except:
            log.exception("Something went wrong trying to initialize automatic emote refresh")

        self.load_all_emotes()
Example #10
0
 def update_channel_emotes(self):
     self.channel_emotes = self.api.get_channel_emotes(
         StreamHelper.get_streamer_id(), force_fetch=True)
Example #11
0
 def load_channel_emotes(self):
     """Load channel emotes from the cache if available, or else, query the API."""
     self.channel_emotes = self.api.get_channel_emotes(
         StreamHelper.get_streamer_id())