twitterbot

package module
v0.0.0-...-4cc944b Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2014 License: MIT Imports: 7 Imported by: 0

README

twitterbot

Twitterbot is a wrapper around the Anaconda Go package for accessing the Twitter API.

Config

After generating the appropriate tokens through the Twitter developer portal copy them into a local file somewhere that follows the format in sample/sample_config.

Creating a Bot

All bots are created by passing in the location of the keys config to New.

bot, err := twitterbot.New("path/to/config")

Once run, the bot will loop forever posting and sleeping for 10 minutes. The content of each tweet is defined by the argument to Run, which is a struct with a NextTweet method. The output of this method is automatically de-duped within Run, so the same content is not posted consecutively.

A very simple example that just tries to post "Hello" over and over again would look like:


// Read config location and create bot above...

type Hello struct {}

func (h Hello) NextTweet() string {
    return "Hello"
}

tweetMaker := Hello{}
bot.Run(tweetMaker)

An example of a full script that tweets out the top post on the Reddit front page can be found in samples.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Keys

type Keys struct {
	// contains filtered or unexported fields
}

func ReadConfig

func ReadConfig(config string) (*Keys, error)

type TBot

type TBot struct {
	// contains filtered or unexported fields
}

func New

func New(config string) (*TBot, error)

func (*TBot) Run

func (t *TBot) Run(creator TweetCreator)

type TweetCreator

type TweetCreator interface {
	NextTweet() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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