Skip to main content

pytmi

package_version license python_version wheel

TMI (Twitch Messaging Interface) library for Python.

You can get your OAuth token with the site https://twitchapps.com/tmi/.

Example

Here's a little application that logs in the user using OAuth, joins the Twitch channel requested by the user, sends the message Hello, Twitch! to the chat and then leaves the channel.

import asyncio
import pytmi

async def main() -> None:
    nick = input("Insert your Twitch nickname: ").strip()
    token = input("Insert your Twitch OAuth token: ").strip()
    channel = input("Insert the channel to join: ").strip()

    async with pytmi.Client() as client:
        await client.login_oauth(token, nick, channel)

        await client.join(channel)
        await client.send_message("Hello, Twitch!")

        await client.part(channel)
        await client.logout()

if __name__ == "__main__":
    try:
        loop = asyncio.new_event_loop()
        loop.run_until_complete(main())
    except:
        print("Something went wrong.")

You can find others usage example inside the test directory.

Known bugs

  • Spurious errors when using SSL.

  • Possible problems with pending tasks (if you don't cleanup them properly).

Todos

  • Handle connection and login error in a better way.

  • Handle messages that are not correctly encoded in UTF8.

Changelog

v1.0.0

  • Major version bump.

  • Add a background task that collects messages in a buffer and sends pong as needed.

  • Rewrite Client code.

  • Change methods name (part -> leave, privmsg -> send_message).

  • Add async context manager (async with) support for Client.

v0.3.0

  • Major library simplification and rewriting.

  • Removed buggy background task.

  • Add library logging.

v0.2.3

  • Add background task to collect messages (removed in v0.3.0).

  • Refactor code.

v0.2.2

  • Add message buffer abstraction.

  • Major code refactoring.

v0.2.1

  • Minor code refactoring.

v0.2.0

  • Rewrite library to be asynchronous.

  • Add SSL support (enabled by default).

  • Reorganize project structure.

v0.1.1

  • Minor code refactoring.

  • Improve message handling and parsing.

v0.1.0

  • Initial version.

Metadata

Release files for pytmi 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytmi 1.0.0
File Size Uploaded Provenance
pytmi-1.0.0.tar.gz 7.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pytmi 1.0.0
File Interpreter ABI Platform
pytmi-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 15.3 kB

Release files / pytmi-1.0.0.tar.gz

Download URL pytmi-1.0.0.tar.gz
Size 7.6 kB
Tags Source
SHA-256 checksum
How to use checksums
214491afa7b51fba9635452b51d5a5d6294d63283cb313aa51ed8a359309494a
BLAKE2b-256 checksum
How to use checksums
cfde2752a3b5c9aaddb0b1eb29a61ea07b081fb385276ed1f114f9287d810ecd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.9

Release files / pytmi-1.0.0-py3-none-any.whl

Download URL pytmi-1.0.0-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6c9a018c89af0fa9857dc5837819b6ba448d85bc5ee45d78c8c468730ad96680
BLAKE2b-256 checksum
How to use checksums
b91740aa121351d63dfe10b65ed7886f3b8359cf6796761b0df2af8bf40665a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.9

Security for pytmi 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page