Twitch的PythonIRC和API包装器。
twitchio的Python项目详细描述
一个异步IRC/API包装器目前正在为Twitchbots开发中,由Python制作!
文档
官方文件:Click Here!
支架
对于使用twitchio的支持,请加入Discord上的官方support server。
安装
以下命令是当前安装Twitchio的有效方法。
twitchio需要python 3.6或更高版本。
windows
py -version -m pip install twitchio
linux
python3 -m pip install twitchio
开始
Twitchio使用许多端点,这些端点可能需要不同的令牌和ID。
- 需要OAuth令牌的IRC终结点。
- 若要获取令牌,请使用机器人的帐户登录Twitch并访问: https://twitchapps.com/tmi/
- 需要客户端ID的HTTP终结点。
- 待记录。
- 需要OAuth令牌和特定作用域的HTTP终结点。
- 待记录。
所有3个端点可以同时使用。否则,您可以选择使用任何或某些终结点。
目前,Twitchio的开发正处于一个阶段,这个阶段的重点是IRC端点并围绕它创建一个框架。 一旦实现,其他两个端点将进一步开发。
一个简单快捷的机器人示例:
fromtwitchio.extimportcommandsclassBot(commands.Bot):def__init__(self):super().__init__(irc_token='...',client_id='...',nick='...',prefix='!',initial_channels=['...'])# Events don't need decorators when subclassedasyncdefevent_ready(self):print(f'Ready | {self.nick}')asyncdefevent_message(self,message):print(message.content)awaitself.handle_commands(message)# Commands use a different decorator@commands.command(name='test')asyncdefmy_command(self,ctx):awaitctx.send(f'Hello {ctx.author.name}!')bot=Bot()bot.run()