Skip to main content

TMI (Twitch Messaging Interface) library for Python.

Project description

pytmi

package_version license python_version wheel

TMI (Twitch Messaging Interface) library for Python.

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: ").lstrip()
    token = input("Insert your Twitch OAuth token: ").lstrip()
    channel = input("Insert the channel to join: ").lstrip()

    client = pytmi.TmiClient()
    await client.login_oauth(token, nick)

    await client.join(channel)
    await client.send_privmsg("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 another find a usage example inside the docs directory.

Todos

  • Create a subclass of TmiMessage for each message type.

  • TmiClient respond to server ping only when constantly reading messages. Consider using a scheduler or asyncio.Tasks for the moment.

  • Initial connection to Twitch server is a little bit slow now.

Changelog

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.

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

pytmi-0.2.1.tar.gz (5.4 kB view hashes)

Uploaded Source

Built Distribution

pytmi-0.2.1-py3-none-any.whl (7.2 kB view hashes)

Uploaded Python 3

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