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.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Bot
impl !RefUnwindSafe for Bot
impl Send for Bot
impl Sync for Bot
impl Unpin for Bot
impl !UnwindSafe for Bot
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)