Skip to content

Commit 3267c90

Browse files
authored
Merge pull request #116 from anxdpanic/pr_isengard
add follow/unfollow to helix
2 parents 283ef74 + fabe8af commit 3267c90

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

resources/lib/twitch/api/helix/users.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
from ... import keys, methods
1414
from ...api.parameters import Cursor, IntRange, ItemCount
15+
from ...queries import GQLQuery as GQLQry
1516
from ...queries import HelixQuery as Qry
1617
from ...queries import query
1718

@@ -73,3 +74,46 @@ def update_extensions():
7374
q = Qry('users/extensions', method=methods.PUT)
7475

7576
return q
77+
78+
79+
# required scope: user_follows_edit
80+
@query
81+
def _follow_channel(channel_id, headers={}, notifications=False):
82+
data = [{
83+
"operationName": "FollowButton_FollowUser",
84+
"variables": {
85+
"input": {
86+
"disableNotifications": notifications,
87+
"targetID": str(channel_id)
88+
}
89+
},
90+
"extensions": {
91+
"persistedQuery": {
92+
"version": 1,
93+
"sha256Hash": "14319edb840c1dfce880dc64fa28a1f4eb69d821901e9e96eb9610d2e52b54f2"
94+
}
95+
}
96+
}]
97+
q = GQLQry('', headers=headers, data=data, use_token=False)
98+
return q
99+
100+
101+
# required scope: user_follows_edit
102+
@query
103+
def _unfollow_channel(channel_id, headers={}):
104+
data = [{
105+
"operationName": "FollowButton_UnfollowUser",
106+
"variables": {
107+
"input": {
108+
"targetID": str(channel_id)
109+
}
110+
},
111+
"extensions": {
112+
"persistedQuery": {
113+
"version": 1,
114+
"sha256Hash": "29783a1dac24124e02f7295526241a9f1476cd2f5ce1e394f93ea50c253d8628"
115+
}
116+
}
117+
}]
118+
q = GQLQry('', headers=headers, data=data, use_token=False)
119+
return q

0 commit comments

Comments
 (0)