Skip to main content

Allows you to connect to Twitch IRC and send and receive messages.

Project description

Python Twitch IRC Library

This is a simple Python library for connecting to the Twitch IRC chat and sending/receiving messages.

Twitch

This is the main class for the Twitch IRC client and has the following methods:

  • __init__(self, user: str = "justinfan12345", token: str = "oauth:1234567890"): Initializes the client with the given username and OAuth token.
  • join(self, channel: str) -> None: Joins the given channel.
  • part(self, channel: str) -> None: Leaves the given channel.
  • connect(self) -> None: Connects to the Twitch IRC server.
  • close(self) -> None: Closes the connection to the Twitch IRC server.
  • send_message(self, channel: str, message: str) -> None: Sends a message to the given channel.
  • send_reply(self, message_id: str, channel: str, reply: str) -> None: Sends a reply to the given message.
  • read(self) -> Generator[TwitchPrivateMessage, None, None]: Reads messages from the Twitch IRC server.

TwitchPrivateMessage

This class represents a Twitch private message and has the following attributes:

  • badges (set): A set of strings representing the badges the user has.
  • color (str): The color of the user's username in the chat.
  • display_name (str): The user's display name.
  • first_message (bool): Whether this is the user's first message in the chat.
  • message_id (str): The ID of the message.
  • mod (bool): Whether the user is a moderator.
  • broadcaster (bool): Whether the user is the broadcaster.
  • returning_chatter (bool): Whether the user has been in the chat before.
  • room_id (int): The ID of the room.
  • subscriber (bool): Whether the user is a subscriber.
  • turbo (bool): Whether the user has Twitch Turbo.
  • user_id (int): The ID of the user.
  • name (str): The user's name.
  • channel (str): The channel the message was sent to.
  • message (str): The contents of the message.

Usage

To use this library, create a Twitch instance and call its methods to connect to the Twitch IRC chat and send/receive messages.

from twitch import Twitch

client = Twitch(user="your_username", token="your_oauth_token")
client.connect()
client.join("your_channel")
client.send_message("your_channel", "Hello, world!")
for message in client.read():
    print(message)
client.close()

Contributing

All contributions are welcome! Please open an issue or pull request if you have any suggestions or find any bugs.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

twitchypy_irc-0.1.1.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

twitchypy_irc-0.1.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file twitchypy_irc-0.1.1.tar.gz.

File metadata

  • Download URL: twitchypy_irc-0.1.1.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.11.1 Windows/10

File hashes

Hashes for twitchypy_irc-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e0c80217b0f0d47f8240dbcc899b5ec4bedf118ac5185441bfeba703cd2f5e32
MD5 e86f39984921310e7ea4460575239fec
BLAKE2b-256 40799a9076f2c29f37ca230b0d73891fe5842a0aaa89063b466d0643888e0004

See more details on using hashes here.

File details

Details for the file twitchypy_irc-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: twitchypy_irc-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.11.1 Windows/10

File hashes

Hashes for twitchypy_irc-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fe06931116d244041ca1cb0ce4cbe3a558fbfbb6f3689b6472ea3f5982aa45fd
MD5 017aec064a0f0593331ab8c6babcf842
BLAKE2b-256 d7d991e8be6a32b4bee1cc29dd719bd8e21c013d7eabd60d848224acfffd6d4d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page