server module#

class Formatter[source]#

Bases: Formatter

parse(format_string: str) Generator[tuple[str, str | None, str | None, None]][source]#
format_field(value: Callable, call_args: str) str[source]#
readline(file: str) str[source]#
load(loop: AbstractEventLoop)[source]#
add_cmd(name: str, *, aliases: list[str] = None, source: str = None, flag: str = None, burst: int = None, rate: float = None, output: str)[source]#
command(name: str, *aliases: str, flag: str = '', force_argcount: bool = False, burst: int = 1, rate: float = 3.0, twitch: bool = True, discord: bool = True)[source]#

This decorator builds TwitchCommand and DiscordCommand versions of commands while leaving the original functions untouched.

with_savefile(name: str, *aliases: str, optional_save: bool = False, **kwargs)[source]#

Decorator for commands that require a save.

slice_command(name: str, *aliases: str, **kwargs)[source]#
mt_command(name: str, *aliases: str, **kwargs)[source]#
class TwitchConn(*args, **kwargs)[source]#

Bases: AutoBot

load_tokens(path=None)[source]#

|coro|

Method used to load tokens when the Client starts.

Note

This method is called by the client during login() but before setup_hook() when the load_tokens keyword-argument is True in either, run(), start() or login() (Default).

You can override this method to implement your own token loading logic into the client, such as from a database.

By default this method loads tokens from a file named “.tio.tokens.json” if it is present; always present if you use the default method of saving tokens.

However, it is preferred you would override this function to load your tokens from a database, as this has far less chance of being corrupted, damaged or lost.

Parameters#

path: str | None

The path to load tokens from, if this is None and the method has not been overriden, this will default to .tio.tokens.json. Defaults to None.

Examples#

class Client(twitchio.Client):

    async def load_tokens(self, path: str | None = None) -> None:
        # Code to fetch all tokens from the database here...
        ...

        for row in tokens:
            await self.add_token(row["token"], row["refresh"])
save_tokens(path=None)[source]#

|coro|

Method which saves all the added OAuth tokens currently managed by this Client.

Note

This method is called by the client when it is gracefully closed and the save_tokens keyword-argument is True in either, run(), start() or login() (Default).

Note

By default this method saves to a JSON file named “.tio.tokens.json”.

You can override this method to implement your own custom logic, such as saving tokens to a database, however it is preferred to use add_token() to ensure the tokens are handled as they are added.

Parameters#

path: str | None

The path of the file to save to. Defaults to .tio.tokens.json.

async setup_hook()[source]#

Set-up the bot’s hooks.

async refresh_spotify_token()[source]#
async spotify_call()[source]#
async event_ready()[source]#
async event_raid(payload: ChannelRaid)[source]#
class DiscordConn(command_prefix: PrefixType[BotT], *, help_command: Optional[HelpCommand] = <default-help-command>, tree_cls: Type[app_commands.CommandTree[Any]] = <class 'discord.app_commands.tree.CommandTree'>, description: Optional[str] = None, allowed_contexts: app_commands.AppCommandContext = ..., allowed_installs: app_commands.AppInstallationType = ..., intents: discord.Intents, **options: Unpack[_BotOptions])[source]#

Bases: Bot

async on_message(message: Message)[source]#
dispatch(name, /, *args, **kwargs)[source]#
class Timer(name: str, interval: int, *, loop=None)[source]#

Bases: object

set_routine()[source]#
async before_ready()[source]#
async on_error(error: Exception)[source]#
start()[source]#
stop()[source]#
async timers_list(ctx: Context | Context)[source]#
async timer_cmd(ctx: Context | Context, action: str, name: str, *args: str)[source]#

Manipulate the timers. Syntax:

  • create <name> [interval]

    will create a new timer with the name and the given interval, if specified. It has no other effect.

  • add <name> <commands>

    will add all of the commands (space-separated) to the timer name - it does not start the timer. If it is running, it will seamlessly integrate the new command at the current point in the rotation.

  • remove <name> <commands>

    will remove all of the commands (space-separated) to the timer name - it does not stop or delete the timer.

  • delete <name> completely removes a timer and associated commands.

    This cannot be undone.

  • auto <name> [interval]

    creates a new timer with the given interval, if specified, and exactly one command name. It immediately starts it. This is basically used for single-command sponsored timers and the like. The internal timer name will start with auto_, followed by the command name, and can be edited normally afterwards. It will automatically delete itself when the stream ends.

  • status <name>

    outputs the commands and interval tied to this timer.

  • start <name>

    starts the given timer.

  • stop <name>

    stops the given timer.

  • interval <name> <interval>

    changes the interval of an existing timer. This will have some weird double-send glitch if editing the interval of a running timer, but is mostly fine otherwise.

async command_cmd(ctx: Context | Context, action: str, name: str, *args: str)[source]#

Syntax: command <action> <name> [+flag] <output>

class Quote(line: str, author: str | None, added_by: str, ts: datetime)[source]#

Bases: object

to_json()[source]#
async get_raw_quotes(req: Request)[source]#
async quote_stuff(ctx: Context | Context, arg: str = 'random', *rest)[source]#

Edit the quote database or pull a specific or random quote.

async setup_clips()[source]#
class Clip(data: Clip, added_by: str, tags: Iterable[str])[source]#

Bases: object

property cf_tags#
to_json()[source]#
async get_clip_info(url: str) Clip[source]#
async clip_cmd(ctx: Context | Context, arg: str = 'random', *rest: str)[source]#

Add a new clip or find a clip.

async bot_cmd(ctx: Context | Context)[source]#

Give general information on the bot itself.

async help_cmd(ctx: Context | Context, name: str = '')[source]#

Find help on the various commands in the bot.

async shoutout(ctx: Context | Context, name: str)[source]#

Give a shoutout to a fellow streamer.

async stream_title(ctx: Context | Context)[source]#

Display the current stream title.

async stream_uptime(ctx: Context | Context)[source]#

Display the stream uptime.

async fetch_run_offset(run: RunParser)[source]#

Fetch and store the run start offset.

async start_prediction(ctx: Context, title: str, outcomes: list[str], duration: int)[source]#
async resolve_prediction(index: int)[source]#
async auto_resolve_pred(run: RunParser)[source]#
async handle_prediction(ctx: Context, type: str = 'info', *args: str)[source]#
async now_playing(ctx: Context | Context)[source]#

Return the currently-playing song on Spotify (if any).

async now_playing_client(req: Request)[source]#
async giveaway_handle(ctx: Context | Context, count: int = 1)[source]#

Manage a giveaway.

async giveaway_enter(ctx: Context | Context)[source]#

Enter into the current giveaway.

async card_info(ctx: Context | Context, *line: str, _cache={})[source]#
async mt_info(ctx: Context | Context, *line: str)[source]#
async card_with_art(ctx: Context | Context, *line: str)[source]#
async bluekey(ctx: Context | Context, save: Savefile | Save2)[source]#

Display what was skipped for the Sapphire key.

async cards_removed(ctx: Context | Context, save: Savefile | Save2)[source]#

Display which cards were removed.

async neowbonus(ctx: Context | Context, save: Savefile | Save2)[source]#

Display what the Neow bonus was.

async neow_skipped(ctx: Context | Context, save: Savefile | Save2)[source]#
async what_if_box(ctx: Context | Context, save: Savefile | Save2)[source]#

Tell us what the Pandora’s Box gave us.

async seed_cmd(ctx: Context | Context, save: Savefile | Save2)[source]#

Display the run’s current seed.

async is_seeded(ctx: Context | Context, save: Savefile | Save2)[source]#

Display whether the current run is seeded.

async run_playtime(ctx: Context | Context, save: Savefile | Save2)[source]#

Display the current playtime for the run.

async shop_removal_cost(ctx: Context | Context, save: Savefile | Save2)[source]#

Display the current shop removal cost.

async shop_prices(ctx: Context | Context, save: Savefile | Save2)[source]#

Display the current shop price ranges.

async campfire_heal(ctx: Context | Context, save: Savefile | Save2)[source]#

Display the current heal at campfires.

async nloth_traded(ctx: Context | Context, save: Savefile | Save2)[source]#

Display which relic was traded for N’loth’s Gift.

async event_likelihood(ctx: Context | Context, save: Savefile | Save2)[source]#

Display current event chances for the various possibilities in ? rooms.

async rare_card_chances(ctx: Context | Context, save: Savefile | Save2)[source]#

Display the current chance to see rare cards in rewards and shops.

async relic_info(ctx: Context | Context, save: Savefile | Save2, index: int = 0)[source]#

Display information about the current relics.

async relics_page2(ctx: Context | Context, save: Savefile | Save2)[source]#

Display the relics on page 2.

async seen_relic(ctx: Context | Context, save: Savefile | Save2, *item: str)[source]#

Output whether a given relic or card has been seen.

async skipped_boss_relics(ctx: Context | Context, save: Savefile | Save2)[source]#

Display the boss relics that were taken and skipped.

async bottled_cards(ctx: Context | Context, save: Savefile | Save2)[source]#

List all bottled cards.

async dagger_scaling(ctx: Context | Context, save: Savefile | Save2)[source]#

Get the damage value of Ritual Dagger.

async algo_scaling(ctx: Context | Context, save: Savefile | Save2)[source]#

Get the block value of Genetic Algorithm.

async modifiers(ctx: Context | Context, save: Savefile | Save2)[source]#

List all custom modifiers for the run.

async score(ctx: Context | Context, save: Savefile | Save2)[source]#

Display the current score of the run

async mt_clans(ctx: Context | Context, save: MonsterSave)[source]#
async mt_mutators(ctx: Context | Context, save: MonsterSave)[source]#
async mt_challenge(ctx: Context | Context, save: MonsterSave)[source]#
async mt_artifact(ctx: Context | Context, save: MonsterSave, index: int = 0)[source]#
async mt_pyre(ctx: Context | Context, save: MonsterSave)[source]#
async curses(ctx: Context | Context, save: CurrentRun)[source]#

Display the current run’s curses.

async items(ctx: Context | Context, save: CurrentRun)[source]#

Display the current run’s unequipped items.

async get_last(ctx: Context | Context, arg1: str = '', arg2: str = '')[source]#

Get the last run/win/loss.

async get_last_run(ctx: Context | Context)[source]#

Get the last run.

async get_last_win(ctx: Context | Context)[source]#

Get the last win.

async get_last_loss(ctx: Context | Context)[source]#

Get the last loss.

async next_run(ctx: Context | Context)[source]#

Return which character is next in the rotation.

async wall_card(ctx: Context | Context)[source]#

Fetch the card in the wall for the ladder savefile.

async set_run_stats_by_date(ctx: Context | Context, date_string: str)[source]#

Update the default range for the run stats by date, this is separate from the all-time stats run cache.

async calculate_wins_cmd(ctx: Context | Context, date_string: str | None = None)[source]#

Display the cumulative number of wins for an optional date range.

async calculate_losses_cmd(ctx: Context | Context, date_string: str | None = None)[source]#

Display the cumulative number of losses for an optional date range.

async streak_display(ctx: Context | Context, new: str)[source]#

Change the !streak command display.

async calculate_streak_cmd(ctx: Context | Context)[source]#

Display Baalor’s current streak for Ascension 20 Heart kills.

async calculate_pb_cmd(ctx: Context | Context, date_string: str | None = None)[source]#

Display Baalor’s Personal Best streaks for Ascension 20 Heart kills for an optional date range.

async get_wrs(ctx: Context | Context, *, _cache={'data': None, 'text': None})[source]#
async architect_total_damage(ctx: Context | Context)[source]#

Return the total damage that The Architect has sustained.

async calculate_winrate_cmd(ctx: Context | Context, date_string: str | None = None)[source]#

Display the winrate for Baalor’s A20 Heart kills for an optional date range.

async unmastered(ctx: Context | Context, save: Savefile | Save2)[source]#
async mastered_stuff(ctx: Context | Context, *card: str)[source]#

Tell us whether a certain card or relic is mastered.

async current_mastery_check(ctx: Context | Context, save: Savefile | Save2)[source]#

Output what cards in the current run can be mastered if won.

async calipers(ctx: Context | Context, save: Savefile | Save2 | None)[source]#
async active_mods(ctx: Context | Context, save: Savefile | Save2)[source]#
async active_mod_info(ctx: Context | Context, save: Savefile | Save2, *modname)[source]#
async commands_page(req: Request)[source]#
async individual_cmd(req: Request)[source]#
async automatic_client_report(req: Request)[source]#
async check_token_validity(req: Request)[source]#
async get_new_token(req: Request)[source]#
async Twitch_startup()[source]#
async Twitch_cleanup()[source]#
async Discord_startup()[source]#
async Discord_cleanup()[source]#
async Youtube_startup()[source]#
async Archive_startup()[source]#