项目作者: DaCasBe

项目描述 :
This is a package you can use to connect with the Twitch API, manage a channel, create bots, etc
高级语言: Python
项目地址: git://github.com/DaCasBe/TwitchPy.git
创建时间: 2020-10-31T19:36:32Z
项目社区:https://github.com/DaCasBe/TwitchPy

开源协议:GNU General Public License v3.0

下载


TwitchPy

License: GPL v3
Formatter: black
Pypi downloads

TwitchPy is a Python package for using the Twitch’s API and create bots for interacting with their IRC chats.

Documentation

Click here to see the official documentation.

Installation

TwitchPy requires Python 3.10 or higher. You can download the latest version of Python here.

  1. pip install twitchpy

Getting started

A basic bot.

  1. from datetime import datetime
  2. from twitchpy.bot import Bot
  3. bot = Bot(
  4. "your_oauth_token",
  5. "your_client_id",
  6. "your_client_secret",
  7. "your_redirect_uri",
  8. "tokens_file_path",
  9. "login_of_your_bot",
  10. ["channels_list_to_read_from"],
  11. "!",
  12. )
  13. time = datetime.now()
  14. def example_check():
  15. global time
  16. time_diff = datetime.now() - time
  17. if time_diff.seconds >= 5:
  18. bot.me("any_channel_login", "This message is sent every 5 seconds")
  19. time = datetime.now()
  20. def example_listener(message):
  21. if message.user is not None:
  22. bot.me("any_channel_login", f"{message.user} said: {message.text}")
  23. def example_command(message):
  24. bot.me("any_channel_login", f"{message.user} is who called me")
  25. bot.add_check("example_check", example_check)
  26. bot.add_listener("example_listener", example_listener)
  27. bot.add_command("example_command", example_command)
  28. bot.run()

Contributing

TwitchPy currently uses the Black formatter to enforce sensible style formatting.

Before creating a pull request it is encouraged you install and run black on your code.

The line length limit for TwitchPy is 88.

For installation and usage of Black visit: Black Formatter

For integrating Black into your IDE visit: Black IDE Usage

Contact

You can contact me through my e-mail.