Skip to content

Commit 01c7710

Browse files
committed
update blocks
1 parent 4f87ee7 commit 01c7710

3 files changed

Lines changed: 20 additions & 8 deletions

File tree

addon.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
- update m3u_pattern
2121
- add initial v5 (wip)
2222
- add support for additional methods in queries (PUT/DELETE/POST)
23-
- v5 add communities, update follow/unfollow
23+
- v5 add communities, update follow/unfollow/blocks
2424
- add basics for implicit oauth2
2525
- update usher base url
2626
</news>

changelog.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
- update m3u_pattern
1111
- add initial v5 (wip)
1212
- add support for additional methods in queries (PUT/DELETE/POST)
13-
- v5 add communities, update follow/unfollow
13+
- v5 add communities, update follow/unfollow/blocks
1414
- add basics for implicit oauth2
1515
- update usher base url
Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,34 @@
11
# -*- encoding: utf-8 -*-
22
# https://github.com/justintv/Twitch-API/blob/master/v3_resources/blocks.md
33

4+
from twitch import keys
5+
from twitch.queries import V5Query as Qry
46
from twitch.queries import query
57

68

79
# Needs Authentification
810
@query
9-
def by_name(user):
10-
raise NotImplementedError
11+
def by_id(identification, limit=25, offset=0):
12+
q = Qry('users/{id}/blocks')
13+
q.add_urlkw(keys.ID, identification)
14+
q.add_param(keys.LIMIT, limit, 25)
15+
q.add_param(keys.OFFSET, offset, 0)
16+
return q
1117

1218

1319
# Needs Authentification, needs PUT
1420
@query
15-
def add_block(user, target):
16-
raise NotImplementedError
21+
def add_block(identification, target):
22+
q = Qry('users/{id}/blocks/{target}', method='PUT')
23+
q.add_urlkw(keys.ID, identification)
24+
q.add_urlkw(keys.TARGET, target)
25+
return q
1726

1827

1928
# Needs Authentification, needs DELETE
2029
@query
21-
def del_block(user, target):
22-
raise NotImplementedError
30+
def del_block(identification, target):
31+
q = Qry('users/{id}/blocks/{target}', method='DELETE')
32+
q.add_urlkw(keys.ID, identification)
33+
q.add_urlkw(keys.TARGET, target)
34+
return q

0 commit comments

Comments
 (0)