cleverbot.io
Installation
To install this package, you must use Cargo. To install it, add it to the project's Cargo.toml file.
[dependencies]
cleverbot_io = "*"
Before using this module, please get your API keys at http://cleverbot.io/keys.
Usage
To initialize the Cleverbot, create a new instance. The instance must be mutable, otherwise the say
function will not be accessible. Additionally, new
takes three parameters: String
, String
, and Option<String>
; you cannot use str
values.
extern crate cleverbot_io;
use cleverbot_io::{Cleverbot};
fn main() {
// Use an automatically generated reference nick by using None for the third parameter.
let mut bot = Cleverbot::new(String::from("YOUR_API_KEY"), String::from("YOUR_API_USER"), None).unwrap();
}
cleverbot.io allows you to save cleverbot sessions to access later. To utilize this feature, you can create a new instance by setting the third parameter to a Some
value.
extern crate cleverbot_io;
use cleverbot_io::{Cleverbot};
fn main() {
let mut bot = Cleverbot::new(String::from("YOUR_API_KEY"), String::from("YOUR_API_USER"), Some(String::from("Carlos"))).unwrap();
}
Now querying the cleverbot is simple, you pass the text to the #say
method.
println!("{}", bot.say("Why am I still talking to you?").unwrap());
Well, that's it for now! Happy hacking!