Bot API Reference

Bot

class pytmi.bot.TwitchBot(prefix=None)

A subclass of TwitchClient used to respond to bot commands.

add_command(command: pytmi.bot.commands.Command)

Adds a command to the bot. You’ll usually use the command decorator instead

command(name=None)

A decorator used to register a function as a command to the bot. The name of the command is set with either the name argument, or the name of the given function

Creates a bot, with a !hello command

bot = TwitchBot(prefix='!')

@bot.command()
async def hello(ctx):
    await ctx.reply("Hello " + ctx.author.name)
coroutine on_message(message: pytmi.message.Message)

Internal async event which calls process_message.

coroutine process_message(message: pytmi.message.Message)

This function is a coroutine.

Internal method that examines the message object for commands.

Data Structures

Context

class pytmi.bot.Context(bot, message: pytmi.message.Message)

Defines an object containing information about a bot command invocation.

author

The author that invoked this command

channel

The channel the command was invoced from

coroutine reply(message_content: str)

A coroutine used to reply in the channel the command was invoked from