def channels(self, query, limit=25, offset=0): if limit > 100: raise TwitchAttributeException( "Maximum number of objects returned in one request is 100") params = {"query": query, "limit": limit, "offset": offset} response = self._request_get("search/channels", params=params) return [Channel.construct_from(x) for x in response["channels"] or []]
def channels(self, query, limit=25, offset=0): if limit > 100: raise TwitchAttributeException( 'Maximum number of objects returned in one request is 100') params = {'query': query, 'limit': limit, 'offset': offset} response = self._request_get('search/channels', params=params) return [Channel.construct_from(x) for x in response['channels'] or []]
def update(self, channel_id, status=None, game=None, delay=None, channel_feed_enabled=None): data = {} if status is not None: data['status'] = status if game is not None: data['game'] = game if delay is not None: data['delay'] = delay if channel_feed_enabled is not None: data['channel_feed_enabled'] = channel_feed_enabled post_data = { 'channel': data } response = self._request_put('channels/{}'.format(channel_id), post_data) return Channel.construct_from(response)
def update( self, channel_id, status=None, game=None, delay=None, channel_feed_enabled=None ): data = {} if status is not None: data["status"] = status if game is not None: data["game"] = game if delay is not None: data["delay"] = delay if channel_feed_enabled is not None: data["channel_feed_enabled"] = channel_feed_enabled post_data = {"channel": data} response = self._request_put("channels/{}".format(channel_id), post_data) return Channel.construct_from(response)
def test_announce_raid(self): with mock.patch( "dragonmanbot.twitchuser.TwitchUserRepository.findByUsername" ) as mocked_return: with mock.patch( 'dragonmanbot.twitch_http_client.channels.get_by_id' ) as mocked_http_return: mocked_return.return_value = twitchuser.TwitchUser( username="******", gold=100) mocked_http_return.return_value = Channel.construct_from( json.loads( '{"display_name": "testuser", "game": "Cool Game"}')) message = "@badges=premium/1;color=#00FF7F;display-name=testuser;emotes=;flags=;id=7532d5b2-ddeb-4e85-992a-999999999999;login=testuser;mod=0;msg-id=raid;msg-param-displayName=testuser;msg-param-login=testuser;msg-param-profileImageURL=https://static-cdn.jtvnw.net/jtv_user_pictures/85896964-219d-4a32-837e-999999999999-profile_image-70x70.jpg;msg-param-viewerCount=7;room-id=68573026;subscriber=0;system-msg=7\sraiders\sfrom\testuser\shave\sjoined\n!;tmi-sent-ts=1547441871162;turbo=0;user-id=999999;user-type= :tmi.twitch.tv USERNOTICE #dragonmantank" response = listener.announce_raid({ "username": "", "message": "", "raw": message }) self.assertEqual( "testuser was playing \"Cool Game\" and is raiding with 7 viewers! Show some love and check them out some time! https://twitch.tv/testuser", response)
def get_by_id(self, channel_id): response = self._request_get('channels/{}'.format(channel_id)) return Channel.construct_from(response)
def reset_stream_key(self, channel_id): response = self._request_delete('channels/{}/stream_key'.format(channel_id)) return Channel.construct_from(response)
def get(self): response = self._request_get('channel') return Channel.construct_from(response)
def get_by_id(self, channel_id): response = self._request_get('channels/%s' % channel_id) return Channel.construct_from(response)
def reset_stream_key(self, channel_id): response = self._request_delete('channels/%s/stream_key' % channel_id) return Channel.construct_from(response)