Skip to content

Commit 7eb7239

Browse files
committed
Merge branch 'master' into feature/ws-eventsub
# Conflicts: # .github/workflows/build.yml
2 parents 8c7e2a8 + 6c56cc0 commit 7eb7239

33 files changed

+900
-140
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ name: Build
33
on:
44
push:
55
pull_request:
6-
types: [opened, reopened, edited, synchronize]
6+
types: [opened, edited, synchronize]
77

88
jobs:
99
lib:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
python-version: ["3.8", "3.9", "3.10"]
14+
python-version: ["3.7", "3.10", "3.11"]
1515

1616
steps:
1717
- name: Checkout
@@ -44,7 +44,7 @@ jobs:
4444
- name: Install CPython
4545
uses: actions/setup-python@v2
4646
with:
47-
python-version: 3.x
47+
python-version: 3.7
4848

4949
- name: Install Deps
5050
run: |
@@ -68,7 +68,7 @@ jobs:
6868
- name: Setup Python
6969
uses: actions/setup-python@v2
7070
with:
71-
python-version: 3.8
71+
python-version: 3.7
7272

7373
- name: install black
7474
run: |

docs/changelog.rst

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,68 @@
11
:orphan:
22

3-
43
Master
54
======
5+
- TwitchIO
6+
- Bug fixes
7+
- Fix :func:`~twitchio.Client.search_categories` due to :attr:`~twitchio.Game.igdb_id` being added to :class:`~twitchio.Game`
8+
- Made Chatter :attr:`~twitchio.Chatter.id` property public
9+
10+
- Other
11+
- [speed] extra
12+
- Added wheels on external pypi index for cchardet and ciso8601
13+
- Bumped ciso8601 from >=2.2,<2.3 to >=2.2,<3
14+
- Bumped cchardet from >=2.1,<2.2 to >=2.1,<3
15+
16+
2.6.0
17+
======
618
- TwitchIO
719
- Additions
820
- Added optional ``started_at`` and ``ended_at`` arguments to :func:`~twitchio.PartialUser.fetch_clips`
921
- Updated docstring regarding new HypeTrain contribution method ``OTHER`` for :attr:`~twitchio.HypeTrainContribution.type`
22+
- Add support for ``ciso8601`` if installed
23+
- Added ``speed`` install flag (``pip install twitchio[speed]``) to install all available speedups
24+
- Added :attr:`~twitchio.Game.igdb_id` to :class:`~twitchio.Game`
25+
- Added ``igdb_ids`` argument to :func:`~twitchio.Client.fetch_games`
26+
- Added ``tags`` attribute to :class:`~twitchio.Stream`, :class:`~twitchio.ChannelInfo` and :class:`~twitchio.SearchUser`
27+
- Added :func:`~twitchio.PartialUser.fetch_shield_mode_status`
28+
- Added :func:`~twitchio.PartialUser.update_shield_mode_status`
29+
- Added :func:`~twitchio.PartialUser.fetch_followed_streams`
30+
- Added :func:`~twitchio.PartialUser.shoutout`
31+
- Added ``type`` arg to :func:`~twitchio.Client.fetch_streams`
1032

1133
- Bug fixes
1234
- Fix :func:`~twitchio.PartialUser.fetch_bits_leaderboard` not handling ``started_at`` and :class:`~twitchio.BitsLeaderboard` not correctly parsing
35+
- Fix parsing :class:`~twitchio.ScheduleSegment` where :attr:`~twitchio.ScheduleSegment.end_time` is None
36+
- Fix auto reconnect of websocket. Created tasks by asyncio.create_task() need to be referred to prevent task disappearing (garbage collection)
37+
- Strip newlines from message content when sending or replying to IRC websocket
38+
- Removed unnessecary assert from :func:`~twitchio.Client.fetch_streams`
1339

1440
- ext.eventsub
41+
- Documentation
42+
- Updated quickstart example to reflect proper usage of callback
1543
- Additions
1644
- Updated docs regarding new HypeTrain contribution method ``other`` for :attr:`~twitchio.ext.eventsub.HypeTrainContributor.type`
45+
- Added Shield Status events
46+
- :func:`~twitchio.ext.eventsub.EventSubClient.subscribe_channel_shield_mode_begin`
47+
- :func:`~twitchio.ext.eventsub.EventSubClient.subscribe_channel_shield_mode_end`
48+
- Added Shoutout events
49+
- :func:`~twitchio.ext.eventsub.EventSubClient.subscribe_channel_shoutout_create`
50+
- :func:`~twitchio.ext.eventsub.EventSubClient.subscribe_channel_shoutout_receive`
51+
- Added :func:`~twitchio.ext.eventsub.EventSubClient.subscribe_channel_follows_v2`
52+
- Added support for ``type`` and ``user_id`` queries on :func:`~twitchio.ext.eventsub.EventSubClient.get_subscriptions`
53+
54+
- Deprecations
55+
- :func:`~twitchio.ext.eventsub.EventSubClient.subscribe_channel_follows`, use :func:`~twitchio.ext.eventsub.EventSubClient.subscribe_channel_follows_v2`
56+
57+
58+
- ext.pubsub
59+
- Bug fixes
60+
- Fix forced RECONNECT messages
61+
62+
- Additions
63+
- Added proper message when wrong type is passed to a topic argument
64+
- Added auth failure hook: :func:`~twitchio.ext.pubsub.PubSubPool.auth_fail_hook`
65+
- Added reconnect hook: :func:`~twitchio.ext.pubsub.PubSubPool.reconnect_hook`
1766

1867
2.5.0
1968
======

docs/exts/eventsub.rst

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Twitch will send you an HTTP request containing information on the event. This e
1111
integrating seamlessly into the twitchio Client event dispatching system.
1212

1313
.. warning::
14-
This ext requires you to have a public facing ip, and to be able to receive inbound requests.
14+
This ext requires you to have a public facing ip AND domain, and to be able to receive inbound requests.
1515

1616
.. note::
1717
Twitch requires EventSub targets to have TLS/SSL enabled (https). TwitchIO does not support this, as such you should
@@ -26,7 +26,7 @@ A Quick Example
2626
import twitchio
2727
from twitchio.ext import eventsub, commands
2828
bot = commands.Bot(token="...")
29-
eventsub_client = eventsub.EventSubClient(bot, "some_secret_string", "/callback")
29+
eventsub_client = eventsub.EventSubClient(bot, "some_secret_string", "https://your-url.here/callback")
3030
# when subscribing (you can only await inside coroutines)
3131
3232
await eventsub_client.subscribe_channel_subscriptions(channel_ID)
@@ -64,7 +64,7 @@ Running Eventsub Inside a Commands Bot
6464
self.loop.create_task(esclient.listen(port=4000))
6565
6666
try:
67-
await esclient.subscribe_channel_follows(broadcaster=channel_ID)
67+
await esclient.subscribe_channel_follows_v2(broadcaster=some_channel_ID, moderator=a_channel_mod_ID)
6868
except twitchio.HTTPException:
6969
pass
7070
@@ -77,7 +77,7 @@ Running Eventsub Inside a Commands Bot
7777
7878
7979
@esbot.event()
80-
async def event_eventsub_notification_follow(payload: eventsub.ChannelFollowData) -> None:
80+
async def event_eventsub_notification_followV2(payload: eventsub.ChannelFollowData) -> None:
8181
print('Received event!')
8282
channel = bot.get_channel('channel')
8383
await channel.send(f'{payload.data.user.name} followed woohoo!')
@@ -192,6 +192,22 @@ This is a list of events dispatched by the eventsub ext.
192192

193193
Called when a hype train ends on their channel.
194194

195+
.. function:: event_eventsub_notification_channel_shield_mode_begin(event: ChannelShieldModeBeginData)
196+
197+
Called when a channel's Shield Mode status is activated.
198+
199+
.. function:: event_eventsub_notification_channel_shield_mode_end(event: ChannelShieldModeEndData)
200+
201+
Called when a channel's Shield Mode status is deactivated.
202+
203+
.. function:: event_eventsub_notification_channel_shoutout_create(event: ChannelShoutoutCreateData)
204+
205+
Called when a channel sends a shoutout.
206+
207+
.. function:: event_eventsub_notification_channel_shoutout_receive(event: ChannelShoutoutReceiveData)
208+
209+
Called when a channel receives a shoutout.
210+
195211
API Reference
196212
--------------
197213

@@ -219,6 +235,30 @@ API Reference
219235
:members:
220236
:inherited-members:
221237

238+
.. attributetable::: ChannelShieldModeBeginData
239+
240+
.. autoclass:: ChannelShieldModeBeginData
241+
:members:
242+
:inherited-members:
243+
244+
.. attributetable::: ChannelShieldModeEndData
245+
246+
.. autoclass:: ChannelShieldModeEndData
247+
:members:
248+
:inherited-members:
249+
250+
.. attributetable::: ChannelShoutoutCreateData
251+
252+
.. autoclass:: ChannelShoutoutCreateData
253+
:members:
254+
:inherited-members:
255+
256+
.. attributetable::: ChannelShoutoutReceiveData
257+
258+
.. autoclass:: ChannelShoutoutReceiveData
259+
:members:
260+
:inherited-members:
261+
222262
.. attributetable::: ChannelSubscribeData
223263
224264
.. autoclass:: ChannelSubscribeData

docs/exts/pubsub.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,32 @@ If the topic requires multiple channel ids, they should be passed as such:
212212
listen_to_id = 12345
213213
topic = pubsub.whispers(user_token)[listen_to_id]
214214
215+
Hooks
216+
------
217+
218+
There are two hooks available in the PubSubPool class. To access these hooks, subclass the PubSubPool.
219+
After subclassing, use the subclass like normal.
220+
221+
The ``auth_fail_hook`` is called whenever you attempt to subscribe to a topic and the auth token is invalid.
222+
From the hook, you are able to fix your token (maybe you need to prompt the user for a new token), and then subscribe again.
223+
224+
The ``reconnect_hook`` is called whenevever a node has to reconnect to twitch, for any reason. The node will wait for you to
225+
return a list of topics before reconnecting. Any modifications to the topics will be applied to the node.
226+
227+
.. code-block:: python3
228+
229+
from typing import List
230+
from twitchio.ext import pubsub
231+
232+
class MyPool(pubsub.PubSubPool):
233+
async def auth_fail_hook(self, topics: List[pubsub.Topic]) -> None:
234+
fixed_topics = fix_my_auth_tokens(topics) # somehow fix your auth tokens
235+
await self.subscribe_topics(topics)
236+
237+
async def reconnect_hook(self, node: pubsub.PubSubWebsocket, topics: List[pubsub.Topic]) -> List[pubsub.Topic]:
238+
return topics
239+
240+
215241
Api Reference
216242
--------------
217243

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
Consider joining the Official Discord server for a fast response to help.<br>
6868
<a href="https://discord.gg/RAKc3HF"><img src="https://discordapp.com/api/guilds/490948346773635102/widget.png?style=banner2"></a><br><br>
6969

70-
<b>For issues and contributing with the library, visit:</b> <a href"https://github.com/TwitchIO/TwitchIO">GitHub</a>
70+
<b>For issues and contributing with the library, visit:</b> <a href="https://github.com/TwitchIO/TwitchIO">GitHub</a>
7171

7272

7373
.. rst-class:: index-display-none

docs/installing.rst

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,55 @@ Make sure you have the latest version of Python installed, or if you prefer, a P
2525

2626
If you have have any other issues feel free to search for duplicates and then create a new issue on GitHub with as much detail as
2727
possible. Including providing the output of pip, your OS details and Python version.
28+
29+
30+
Extras
31+
-------
32+
Twitchio has some extra downloaders available to modify the library.
33+
Due to some outdated binaries on the pypi package index, when using Python 3.11+, you'll want to make use of our custom pypi
34+
index for these extras. You can access this index by doing the following (replace your-extra with the extra you want to use):
35+
36+
.. code:: sh
37+
38+
python3 -m pip install -U twitchio[your-extra] --extra-index-url https://pip.twitchio.dev/
39+
40+
Or, on windows:
41+
42+
.. code:: sh
43+
44+
py -3.11 -m pip install -U twitchio[your-extra] --extra-index-url https://pip.twitchio.dev/
45+
46+
47+
If you do not wish to use our custom index, you can build the wheels yourself by installing cython through pip prior to installing the extra.
48+
Note that you will need C build tools installed to be able to do this.
49+
50+
Extra: speed
51+
++++++++++++++
52+
The speed extra will install dependancies built in C that are considerably faster than their pure-python equivalents.
53+
You can install the speed extra by doing:
54+
55+
.. code:: sh
56+
57+
python3 -m pip install -U twitchio[speed] --extra-index-url https://pip.twitchio.dev/
58+
59+
Or, on windows:
60+
61+
.. code:: sh
62+
63+
py -3.11 -m pip install -U twitchio[speed] --extra-index-url https://pip.twitchio.dev/
64+
65+
Extra: sounds
66+
+++++++++++++++
67+
The sounds extra installs extra dependancies for using the sounds ext.
68+
If you wish to use the sounds ext, you will need to install this extra, which you can do by doing the following:
69+
70+
71+
.. code:: sh
72+
73+
python3 -m pip install -U twitchio[sounds] --extra-index-url https://pip.twitchio.dev/
74+
75+
Or, on windows:
76+
77+
.. code:: sh
78+
79+
py -3.11 -m pip install -U twitchio[sounds] --extra-index-url https://pip.twitchio.dev/

docs/reference.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,13 @@ SearchUser
324324
.. autoclass:: SearchUser
325325
:members:
326326

327+
ShieldStatus
328+
------------
329+
.. attributetable:: ShieldStatus
330+
331+
.. autoclass:: ShieldStatus
332+
:members:
333+
327334
Stream
328335
----------
329336
.. attributetable:: Stream

examples/eventsub.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def __init__(self):
1212
async def __ainit__(self) -> None:
1313
self.loop.create_task(esclient.listen(port=4000))
1414
try:
15-
await esclient.subscribe_channel_follows(broadcaster=channel_ID)
15+
await esclient.subscribe_channel_follows_v2(broadcaster=channel_id, moderator=moderator_id)
1616
except twitchio.HTTPException:
1717
pass
1818

@@ -25,7 +25,7 @@ async def event_ready(self):
2525

2626

2727
@esbot.event()
28-
async def event_eventsub_notification_follow(payload: eventsub.ChannelFollowData) -> None:
28+
async def event_eventsub_notification_followV2(payload: eventsub.ChannelFollowData) -> None:
2929
print("Received event!")
3030
channel = bot.get_channel("channel")
3131
await channel.send(f"{payload.data.user.name} followed woohoo!")

setup.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@
5252
"yt-dlp>=2022.2.4",
5353
'pyaudio==0.2.11; platform_system!="Windows"',
5454
]
55-
extras_require = {"sounds": sounds}
55+
speed = [
56+
"ujson>=5.2,<6",
57+
"ciso8601>=2.2,<3",
58+
"cchardet>=2.1,<3"
59+
]
60+
extras_require = {"sounds": sounds, "speed": speed}
5661

5762
setup(
5863
name="twitchio",
@@ -81,6 +86,8 @@
8186
"Programming Language :: Python :: 3.7",
8287
"Programming Language :: Python :: 3.8",
8388
"Programming Language :: Python :: 3.9",
89+
"Programming Language :: Python :: 3.10",
90+
"Programming Language :: Python :: 3.11",
8491
"Topic :: Internet",
8592
"Topic :: Software Development :: Libraries",
8693
"Topic :: Software Development :: Libraries :: Python Modules",

twitchio/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
__author__ = "TwitchIO, PythonistaGuild"
2929
__license__ = "MIT"
3030
__copyright__ = "Copyright 2017-2022 (c) TwitchIO"
31-
__version__ = "2.5.0"
31+
__version__ = "2.6.0"
3232

3333
from .client import Client
3434
from .user import *

0 commit comments

Comments
 (0)