Data classes¶
For convenience, pyBotB provides some data classes that abstract away the basic data structures of BotB. These classes are returned by the BotB API functions.
Dataclasses representing available object types and related enums.
- enum pybotb.types.BadgeLevel(value)¶
Enum for BotBr badge_levels values.
- Member Type:
Valid values are as follows:
- NOT_UNLOCKED = <BadgeLevel.NOT_UNLOCKED: 0>¶
- REGULAR = <BadgeLevel.REGULAR: 1>¶
- BRONZE = <BadgeLevel.BRONZE: 2>¶
- SILVER = <BadgeLevel.SILVER: 3>¶
- GOLD = <BadgeLevel.GOLD: 4>¶
- class pybotb.types.BotBr(aura, aura_color, avatar_url, badge_levels, boons, botbr_class, class_icon, create_date_str, id, laston_date_str, level, name, palette_id, points, points_array, profile_url, _raw_payload=None)¶
Represents a BotBr.
Properties directly match API data, except where noted otherwise.
- Parameters:
-
aura:
str¶ String representing the aura PNG name for this BotBr; usually the BotBr ID zero- padded to 8 characters.
This is used to calculate the aura URL in
BotBr.aura_url.
- property aura_url: str¶
URL to the aura PNG; calculated from
BotBr.aura.This is a pyBotB-specific property.
-
badge_levels:
Dict[str,BadgeLevel]¶ Dictionary where the key is the format name and the value is the badge level (i.e. regular, bronze, silver, gold); see
BadgeLevelfor possible values.This lists unlocked badges, and is not to be confused with badge progress (badge progress points are what unlocks badges). Badge progress is not exposed through the official API and can only be fetched through the TODO method.
-
botbr_class:
str¶ The BotBr’s class; i.e., the class that appears next to the level on-site. This class is derived from the highest points in the points array at level-up time.
In the BotB API, this field is named “class”; however, it is renamed here to avoid collisions with the class keyword used by Python.
-
class_icon:
str¶ String containing HTML div representing the icon. This is BotB-specific and likely of not much use to implementations.
-
create_date_str:
str¶ String representing the creation date of the BotBr’s account, in YYYY-MM-DD format, in the US East Coast timezone (same as all other dates on-site).
The creation date is also converted to a datetime for developer convenience; see
BotBr.create_date.
- property create_date: datetime¶
Account creation date as a datetime object.
For the raw string, see
BotBr.create_date_str.
-
laston_date_str:
str¶ String representing the date on which the BotBr was last seen on the site, in YYYY-MM-DD format, in the US East Coast timezone (same as all other dates on- site).
The last-on date is also converted to a datetime for developer convenience; see
BotBr.laston_date.
- property laston_date: datetime¶
Last seen date as a datetime object.
For the raw string, see
BotBr.laston_date_str.
-
points_array:
Dict[str,int]¶ Dictionary with class name as the key and the amount of points as the value. See https://battleofthebits.com/lyceum/View/BotBr%20Classes for an overview of classes.
Notes:
Some old BotBrs might have lowercase class points - these are counted separately.
There is also a bugged out empty point class, which is also counted separately (see https://battleofthebits.com/barracks/Profile/atropine/) - this might break if you do a boolean comparison against the class name!
Individual point counts may be negative numbers (e.g. latist points which are always below 0, but also e.g. -5 class points for having an entry with no votes) - however, these do not sum up into the score in the points variable.
- class pybotb.types.BotBrPoints(amount, botbr_id, id, type, _raw_payload=None)¶
Represents the point stats for a single BotBr, for a specific class.
- enum pybotb.types.Medium(value)¶
Enum for different medium types; not to be confused with formats.
The numerical values are pyBotB-specific; on the Entry, object, this value is derived from “medium_audio”, “medium_visual”, etc. properties of the API.
- Member Type:
Valid values are as follows:
- OTHER = <Medium.OTHER: 'other'>¶
- AUDIO = <Medium.AUDIO: 'audio'>¶
- VISUAL = <Medium.VISUAL: 'visual'>¶
- class pybotb.types.Format(description, icon, icon_url, id, medium, maxfilesize, maxfilesize_human, point_class, title, token, _raw_payload=None)¶
Represents a format.
- Parameters:
-
icon_url:
str¶ The direct URL to the icon for this format (with https://battleofthebits.com prefix).
- enum pybotb.types.BattlePeriod(value)¶
String enum containing battle period values.
- Member Type:
Valid values are as follows:
- WARMUP = <BattlePeriod.WARMUP: 'warmup'>¶
- ENTRY = <BattlePeriod.ENTRY: 'entry'>¶
- VOTE = <BattlePeriod.VOTE: 'vote'>¶
- TALLY = <BattlePeriod.TALLY: 'tally'>¶
- END = <BattlePeriod.END: 'end'>¶
- class pybotb.types.Battle(id, title, url, profile_url, cover_art_url, botbr_id, hosts_names, type, entry_count, start_str, end_str, format_tokens, period=None, period_end_str=None, _raw_payload=None)¶
Represents a battle.
- Parameters:
-
cover_art_url:
str¶ Full URL to the battle cover art (with https://battleofthebits.com prefix).
-
botbr_id:
int¶ ID of the BotBr hosting this battle. In the case of battles with multiple hosts (some majors do this), this is set to 1 (TODO verify?).
-
type:
int¶ The battle’s “type” attribute.
The value is set to 3 for XHBs; all other values are majors. Known non-XHB type values:
0 and 1 are used for various majors
2 was used for some “3xTheme Battle” majors and the “48 Hour Game Jam I” major
4 was used for the “Doom” major
25 was used for the “BotB Advent Calendar 2020” major
In any case, it is safe to assume that any type value other than 3 means it’s not an XHB.
- property is_xhb: bool¶
Whether or not this battle is an X Hour Battle/minor battle.
- Returns:
True if the battle is an XHB, False otherwise.
- property is_major: bool¶
Whether or not this battle is a major battle.
- Returns:
True if the battle is a major, False otherwise.
-
start_str:
str¶ String representing the date and time at which the battle starts, in YYYY-MM-DD HH:MM:SS format, in the US East Coast timezone (same as all other dates on the site).
The start date is also converted to a datetime for developer convenience; see
start.
-
end_str:
str¶ String representing the date and time at which the battle ends, in YYYY-MM-DD HH:MM:SS format, in the US East Coast timezone (same as all other dates on the site).
If
periodis “vote”, this signifies the end of the voting period.The end date is also converted to a datetime for developer convenience; see
Battle.end.
- property end: datetime¶
Date and time at which the battle ends.
If
periodis “vote”, this signifies the end of the voting period.For the raw string, see
end_str.
-
format_tokens:
List[str]¶ List of format tokens for this battle. For XHBs, this will contain one item; for majors, there may be more formats.
-
period:
Optional[BattlePeriod] = None¶ Current battle period. “warmup” for upcoming battles, “entry” for entry period, “vote” for voting period, “end” for end period.
Some endpoints (e.g. Battle objects in
Entry.battle) do not return this value; in this case, usepybotb.botb.BotB.battle_load()to get the full battle info.
-
period_end_str:
Optional[str] = None¶ String representing the date and time at which the battle ends, in YYYY-MM-DD HH:MM:SS format, in the US East Coast timezone (same as all other dates on the site).
For major battles, this signifies the “final results” datetime; for the current battle period’s end date, see
period_end.The end date is also converted to a datetime for developer convenience; see
end.
- property period_end: datetime | None¶
Date and time at which the current battle period ends.
If
periodis “vote”, this signifies the period_end of the voting period.For the raw string, see
period_end_str.
- class pybotb.types.EntryAuthor(aura, aura_color, avatar, avatar_from_time, botbr_class, class_icon, country_code, country_name, id, level, name, profile_url, _raw_payload=None)¶
Represents an entry author, as returned in the “authors” field of the entry API.
- Parameters:
-
aura:
str¶ String representing the aura PNG name for this BotBr; usually the BotBr ID zero- padded to 8 characters.
This is used to calculate the aura URL in
aura_url.
- property aura_url: str¶
URL to the aura PNG; calculated from
aura.This is a pyBotB-specific property.
-
avatar_from_time:
str¶ Relative URL to the BotBr’s avatar at the time of the entry’s submission (/disk/…)
-
botbr_class:
str¶ The BotBr’s class; i.e., the class that appears next to the level on-site. This class is derived from the highest points in the points array at level-up time.
In the BotB API, this field is named “class”; however, it is renamed here to avoid collisions with the class keyword used by Python.
- class pybotb.types.Entry(authors, authors_display, botbr_id, botbr, battle_id, battle, datetime_str, datetime_display, donloads, donload_url, favs, format_token, format, gov, id, late, medium, plays, posts, q, title, thumbnail_url, votes, view_url, preview_url, length=0, profile_url=None, listen_url=None, play_url=None, youtube_url=None, rank=None, rank_suffix='', rank_display='', score=None, score_display='', trophy_display=None, _raw_payload=None)¶
Represents a battle entry.
- Parameters:
authors (List[EntryAuthor])
authors_display (str)
botbr_id (int)
botbr (BotBr)
battle_id (int)
battle (Battle)
datetime_str (str)
datetime_display (str)
donloads (int)
donload_url (str)
favs (int)
format_token (str)
format (Format)
gov (float)
id (int)
late (bool)
medium (Medium)
plays (int)
posts (int)
q (int)
title (str)
thumbnail_url (str)
votes (int)
view_url (str)
preview_url (str)
length (float)
profile_url (str | None)
listen_url (str | None)
play_url (str | None)
youtube_url (str | None)
rank (int | None)
rank_suffix (str)
rank_display (str)
score (float | None)
score_display (str)
trophy_display (str | None)
_raw_payload (dict | None)
-
authors:
List[EntryAuthor]¶ List of authors for the entry.
-
datetime_str:
str¶ String representing the submission date of this entry in YYYY-MM-DD HH:MM:SS format, in the US East Coast timezone (same as all other dates on the site).
The creation date is also converted to a datetime for developer convenience; see
Entry.datetime.
- property datetime: datetime¶
Account creation date as a datetime object.
For the raw string, see
Entry.datetime_str.
-
datetime_display:
str¶ The submission date in a human-readable format, as displayed on BotB.
Like the datetime string, this is stored in the US East Coast timezone; implementations will likely want to create their own string based on the
Entry.datetimeproperty.
-
donload_url:
str¶ Relative URL to the entry source file, for downloading (note the deliberate typo).
-
medium:
Medium¶ Medium of the entry; see
Mediumfor possible values.This is consolidated from “medium_*” variables (“medium_audio”, “medium_visual”, etc.)
-
thumbnail_url:
str¶ Relative URL to the entry thumbnail; empty for entries without a thumbnail (i.e. non-visual entries).
-
profile_url:
Optional[str] = None¶ URL to the entry’s page on the site.
Not present (None) for entries that have been removed from the site.
-
listen_url:
Optional[str] = None¶ Relative player URL for the entry (“/player/Entry/{id}” format).
Present for audio and visual entries, except for some non-audio entries with archives or other filetypes. Also not present for non-rendered entries, and not present for entries that have been removed from the site.
-
play_url:
Optional[str] = None¶ Direct URL to the source file of an audio entry.
None for non-audio entries. (The API returns False for non-audio entries; we turn it to None for API convenience.)
-
rank:
Optional[int] = None¶ Rank of the entry.
Only present once the battle is over; returns None otherwise.
-
rank_suffix:
str= ''¶ English plural suffix for the rank (e.g “st” for 1st, “nd” for 2nd, etc.)
If the battle is not over yet, this is an empty string.
-
rank_display:
str= ''¶ HTML representation of rank; likely not of use to implementations.
If the battle is not over yet, this is “?/{entry count}”.
-
score:
Optional[float] = None¶ Score of the entry.
Only present once the battle is over; returns None otherwise.
-
score_display:
str= ''¶ HTML representation of score; likely not of use to implementations.
If the battle is not over yet, this is an empty string.
- class pybotb.types.Favorite(id, botbr_id, entry_id, much, _raw_payload=None)¶
A favorite on an entry.
- enum pybotb.types.GroupID(value)¶
Forum group IDs.
- Member Type:
Valid values are as follows:
- BULLETINS = <GroupID.BULLETINS: 1>¶
- NEWS = <GroupID.NEWS: 2>¶
- INTERNAL = <GroupID.INTERNAL: 3>¶
- ENTRIES = <GroupID.ENTRIES: 4>¶
- BATTLES = <GroupID.BATTLES: 5>¶
- PHOTOS = <GroupID.PHOTOS: 6>¶
- UPDATE_LOG = <GroupID.UPDATE_LOG: 7>¶
- N00B_S0Z = <GroupID.N00B_S0Z: 8>¶
- MAIL = <GroupID.MAIL: 9>¶
- BUG_REPORTS_AND_FEATURE_REQUESTS = <GroupID.BUG_REPORTS_AND_FEATURE_REQUESTS: 10>¶
- SMEESH = <GroupID.SMEESH: 11>¶
- PROJECT_DEV = <GroupID.PROJECT_DEV: 12>¶
- BOTBRS = <GroupID.BOTBRS: 13>¶
- LYCEUM = <GroupID.LYCEUM: 14>¶
- class pybotb.types.GroupThread(id, group_id, title, first_post_timestamp_str, last_post_timestamp_str=None, _raw_payload=None)¶
A group thread - i.e. a thread in a forum group, containing posts.
Forum threads and BotBr/entry/battle comment threads are all group threads.
- Parameters:
-
group_id:
GroupID¶ ID of the forum group this thread belongs to; see :enum:.GroupID for possible values.
-
first_post_timestamp_str:
str¶ Timestamp of the first post in the thread, in YYYY-MM-DD HH:MM:SS format, in the US East Coast timezone (same as all other dates on the site).
- property first_post_timestamp: datetime¶
First post’s timestamp as a datetime object.
For the raw string, see
first_post_timestamp_str.
-
last_post_timestamp_str:
Optional[str] = None¶ Timestamp of the last post in the thread, in YYYY-MM-DD HH:MM:SS format, in the US East Coast timezone (same as all other dates on the site).
None if the thread only contains one post.
- property last_post_timestamp: datetime | None¶
Last post’s timestamp as a datetime object.
None if the thread only contains one post.
For the raw string, see
last_post_timestamp_str.
- class pybotb.types.LyceumArticle(id, title, profile_url, text_firki, text_stripped, views)¶
Represents an article on the Lyceum.
- class pybotb.types.Tag(id, entry_id, tag, _raw_payload=None)¶
A tag on an entry.
- class pybotb.types.Palette(id, title, botbr_id, color1, color2, color3, color4, color5, _raw_payload=None)¶
Color palette.
- Parameters:
- property css_url¶
URL to the palette CSS.
This is a CSS file hosted on battleofthebits.com which contains a :root directive with the colors as CSS variables. Each color has its hex code stored in the –colorX variable, with the individual RGB components stored in –colorX_r, –colorX_g and –colorX_b for red, green and blue respectively.
This variable is derived from the ID.
- class pybotb.types.Playlist(id, botbr_id, title, count, runtime, date_create_str, date_modify_str, description=None, thumbnail_id=None, _raw_payload=None)¶
A playlist containing entries.
- Parameters:
-
date_create_str:
str¶ String representing the date on which the BotBr was last seen on the site, in YYYY-MM-DD format, in the US East Coast timezone (same as all other dates on- site).
The last-on date is also converted to a datetime for developer convenience; see
date_create.
- property date_create: datetime¶
Last seen date as a datetime object.
For the raw string, see
date_create_str.
-
date_modify_str:
str¶ String representing the date on which the BotBr was last seen on the site, in YYYY-MM-DD format, in the US East Coast timezone (same as all other dates on- site).
The last-on date is also converted to a datetime for developer convenience; see
date_modify.
- property date_modify: datetime¶
Last seen date as a datetime object.
For the raw string, see
date_modify_str.
-
thumbnail_id:
Optional[int] = None¶ ID of the entry used as the thumbnail, or None if none is set.
- To get the Entry object for the thumbnail, use
BotBr.entry_load(playlist.thumbnail_id).
To get the URL of the thumbnail, get the :prop:.Entry.thumbnail_property property of the entry object fetched with the function above.
- class pybotb.types.PlaylistToEntry(playlist_id, entry_id)¶
Link between playlist and entry returned by the playlist_to_entry API.
- class pybotb.types.DailyStats(id, date_str, page_views, plays, donloads, ip_count, entry_count, botbr_count, user_count, post_count, economic_pool, avg_debit, bank_debit, bank_credit, total_points, _raw_payload=None)¶
A single entry in the BotB daily site stats table.
Note that statistics apply to the given date in the US East Coast timezone; if you want to get statistics for a date in your timezone, you will have to aggregate data from multiple days.
- Parameters:
-
date_str:
str¶ String representing the date of the statistic, in YYYY-MM-DD format, in the US East Coast timezone (same as all other dates on-site).
This date is also converted to a datetime for developer convenience; see
date.
-
user_count:
int¶ Amount of users seen on the site; same as
botbr_count.
-
economic_pool:
int¶ Total amount of boons owned by BotBrs, including the bank value, rounded to an integer.
- class pybotb.types.BotBrStats(botbr_id, label, val, date_str, _raw_payload=None)¶
A single entry in the BotBr stats table.
Note that statistics apply to the given date in the US East Coast timezone; if you want to get statistics for a date in your timezone, you will have to aggregate data from multiple days.
-
label:
str¶ Label of the statistic.
“level” for level, “boons” for boon count, “a_light” for aura light points, “a_ack” for aura ack points, “a_dark” for aura dark points, class name for class point amount.
-
label: