pub struct Bot { /* private fields */ }
Expand description
Main bot class
Implementations§
Source§impl Bot
impl Bot
Sourcepub fn builder(wiki_url: String) -> Builder
pub fn builder(wiki_url: String) -> Builder
Build a Bot
instance programmatically.
The wiki’s URL should be the path where api.php and rest.php can be
found (aka the “script path”). By default it is usually something
like https://wiki.example.org/w/
.
Sourcepub fn builder_with_legacy_rest(api_url: String, rest_url: String) -> Builder
pub fn builder_with_legacy_rest(api_url: String, rest_url: String) -> Builder
For older wikis (pre-1.42) that use RESTBase or the old Parsoid rest.php API.
Sourcepub async fn from_default_config() -> Result<Self, ConfigError>
pub async fn from_default_config() -> Result<Self, ConfigError>
Load Bot configuration from a default location, first look at
mwbot.toml
in the current directory, otherwise look in the
platform’s config directory:
- Linux:
$XDG_CONFIG_HOME
or$HOME/.config
- macOS:
$HOME/Library/Application Support
- Windows:
{FOLDERID_RoamingAppData}
Sourcepub async fn from_path(path: &Path) -> Result<Self, ConfigError>
pub async fn from_path(path: &Path) -> Result<Self, ConfigError>
Load Bot configuration from the specified path.
Sourcepub fn api(&self) -> &ApiClient
pub fn api(&self) -> &ApiClient
Get a reference to the underlying mwapi::Client
to make arbitrary API requests
Sourcepub fn parsoid(&self) -> &ParsoidClient
pub fn parsoid(&self) -> &ParsoidClient
Get a reference to the underlying parsoid::Client
to make arbitrary Parsoid API requests
Sourcepub fn title_codec(&self) -> &TitleCodec
pub fn title_codec(&self) -> &TitleCodec
Get a reference to the internal mwtitle::TitleCodec
to parse and construct arbitrary titles.
Sourcepub fn page(&self, title: &str) -> Result<Page>
pub fn page(&self, title: &str) -> Result<Page>
Get a Page
on this wiki. The specified title should be a full title,
including namespace. This does some validation on the
provided input.
Sourcepub fn page_from_database(&self, namespace: i32, dbkey: &str) -> Result<Page>
pub fn page_from_database(&self, namespace: i32, dbkey: &str) -> Result<Page>
Get a Page
on this wiki using information from a database row.
The provided input will be validated and may return an error if invalid.
Sourcepub async fn page_from_id(&self, page_id: u64) -> Result<Page>
pub async fn page_from_id(&self, page_id: u64) -> Result<Page>
Get a Page
on this wiki using page id.
The provided input will be validated and may return an error if invalid.