cleverbot

package module
v0.0.0-...-d249267 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2017 License: MIT Imports: 5 Imported by: 8

README

Go Report Card GoDoc

cleverbot.io

A Go wrapper for Cleverbot.io.

Installation

go get github.com/CleverbotIO/go-cleverbot.io

Usage

// Package main provides a basic example of using go-cleverbot.io.
package main

import (
	"fmt"
	"log"

	"github.com/CleverbotIO/go-cleverbot.io"
)

func main() {
	// The api key is given to you at https://cleverbot.io/keys.
	apiUser := "YOUR_API_USER"
	apiKey := "YOUR_API_KEY"

	// apiNick is optional.
	apiNick := ""

	// Initialize Cleverbot
	bot, err := cleverbot.New(apiUser, apiKey, apiNick)
	if err != nil {
		log.Fatal(err)
	}

	// Send Cleverbot a message.
	response, err := bot.Ask("hello world")
	if err != nil {
		log.Fatal(err)
	}

	// Print the response.
	fmt.Println(response)
	// "World? Who is world? My name is Timmy."
}

Documentation

Overview

Package cleverbot implements wrapper for the cleverbot.io API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Session

type Session struct {
	User string `json:"user"`
	Key  string `json:"key"`
	Nick string `json:"nick"`
	Text string `json:"text"`
}

Session ...

func New

func New(user, key string, nick ...string) (s *Session, err error)

New bot instance. "nick" is optional if you did not specify it, a random one is generated for you. A successful call returns err == nil.

func (*Session) Ask

func (s *Session) Ask(text string) (output string, err error)

Ask Cleverbot a question, returns Cleverbots response. A successful call returns err == nil.

Directories

Path Synopsis
_examples
chat
Package main provides a basic example of using go-cleverbot.io.
Package main provides a basic example of using go-cleverbot.io.
simple
Package main provides a basic example of using go-cleverbot.io.
Package main provides a basic example of using go-cleverbot.io.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL