Skip to main content

Async IRC Client

Project description

AsyncIRCClient

Async (Twitch-) IRC client

First async code so takee everything with a bit of caution

Installation

pip install AsyncIRCClient

Example usage

from loguru import logger

from async_irc_client.async_irc_client import TwitchIRCBot, Message


class MyBot(TwitchIRCBot):

    # subscribe to twitch's irc events
    async def on_client_ready(self, message: Message) -> None:
        logger.info("Bot is Ready")

    # create commands
    @TwitchIRCBot.command("test")
    async def test_command(self, message: Message) -> None:
        self.send_chat_message(f"Hello World {message.source.nick}")

    # mod only command
    @TwitchIRCBot.command("mod_test", mod_only=True)
    async def mod_test_command(self, message: Message) -> None:
        self.send_chat_message(f"Hello World mod {message.source.nick}")

    @TwitchIRCBot.command("alias_test", aliases=["alias_1", "alias_2"])
    async def alias_test_command(self, message: Message) -> None:
        self.send_chat_message("Call as alias!")

    # when using case-insensitive commands you may not use
    # any other command with the same name as any case-insensitive combination
    # works with aliases
    @TwitchIRCBot.command("case_insensitive", case_sensitive=False)
    async def case_insensitive_command(self, message: Message) -> None:
        self.send_chat_message("Case insensitive")

    # repeat a task
    # runs once the client is ready and after the specified time interval
    # here 1000s
    @TwitchIRCBot.loop(1000)
    async def my_task(self):
        logger.info("Hello World")

    # repeat a task at given time
    # is 1 second delayed to prevent double trigger inaccuracies
    @TwitchIRCBot.loop(time="08:36")
    async def my_timed_task(self):
        logger.info("Hello World at 08:36")


if __name__ == "__main__":
    from async_irc_client import Proxy, ProxyType

    MyBot(
        oauth_token="YOURTOKEN",
        nick_name="BOTNAME",
        channel="CHANNELNAME",
        proxies=[
            Proxy(ProxyType.HTTP, "ip", 1234),
            Proxy(ProxyType.HTTP, "ip", 1234, password="password", username="username"),
            Proxy.from_url("proxy_url")
        ]
    ).mainloop() # alternatively use .run() to run the bot non blocking.

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

AsyncIRCClient-1.0.0.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

AsyncIRCClient-1.0.0-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file AsyncIRCClient-1.0.0.tar.gz.

File metadata

  • Download URL: AsyncIRCClient-1.0.0.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.18

File hashes

Hashes for AsyncIRCClient-1.0.0.tar.gz
Algorithm Hash digest
SHA256 33f960a443aa6e1ce6b3c8643f98bd8629221a1cbad99276602d2b7ee6640aa4
MD5 0be31740a2ad7a636bc1e0c45a869d77
BLAKE2b-256 5e94735111112898bb4f2e43f6f015bf8a89bf1f5225a83e891ab77f3dcd8d5c

See more details on using hashes here.

File details

Details for the file AsyncIRCClient-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: AsyncIRCClient-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.18

File hashes

Hashes for AsyncIRCClient-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 79b378a689540214d0235adfa4b2067693be3ed3d32fdb155d20414d1d544178
MD5 3d8a3abe315b4a5c401c710d2bd26a72
BLAKE2b-256 15bcf752183d0729a1a92c8c7293e02676f4b7a0e4fe8059673e115745528c9c

See more details on using hashes here.

Supported by

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