responses

package
v0.0.0-...-d150683 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2018 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllCryptos

AllCryptos wraps allCryptos with results

func BitcoinTicker

BitcoinTicker will return a string containing the current rate in USD

func Build

Build will pull the latest git master and rebuild. It will then restart puddlebot Syntax: `!build <branch-name>` Example: `!build master`

func Checkout

Checkout pulls & checks out a branch

func Define

Define fetches the dictionary definition of a word

func EthTicker

EthTicker will return a string containing the current rate in USD

func Handle

func Handle(key string, h messagerouter.MessageHandler)

Handle stores commands before initialisation

func Init

func Init(msgr *messagerouter.MessageRouter)

Init initialises responses

func Insult

Insult will insult someone

func MemeGenerator

MemeGenerator will post the latest meme from imgur meme gallery

func Ping

Ping responds to !ping with a pong!

func Restart

Restart restarts Puddlebot.

func Weather

Weather prints out the current temperature & forecast. Usage: !weather

Types

type BokBok

type BokBok struct {
	Channel string
	// contains filtered or unexported fields
}

BokBok is a smart chat bot

func NewBokBok

func NewBokBok(prefixLen int) *BokBok

NewBokBok makes a BoKBok and opens the bolt database

func (*BokBok) Chain

func (bkbk *BokBok) Chain(username string) *Chain

Chain retreives chain from bkbk.db. Creates username bucket if it doesn't exist

func (*BokBok) MaybeRespond

MaybeRespond might respond, or it might not, for top kek

func (*BokBok) NewChain

func (bkbk *BokBok) NewChain(username string) *Chain

NewChain returns a new Chain with prefixes of prefixLen words.

func (*BokBok) ProcessMessage

Processes Message builds or amends the Markov Chain for "all" and the individual user

func (*BokBok) Respond

Respond reponds to message

func (*BokBok) RespondHere

RespondHere allows the user to apply a channel to respond to Triggered by !bokbok <channel>

func (*BokBok) SaveChains

func (bkbk *BokBok) SaveChains(chains ...*Chain) error

SaveChains saves chains to the database

func (*BokBok) YesNo

func (bkbk *BokBok) YesNo() bool

type Chain

type Chain struct {
	Username  string
	Chain     map[string][]string
	PrefixLen int
}

Chain contains a map ("chain") of prefixes to a list of suffixes. A prefix is a string of prefixLen words joined with spaces. A suffix is a single word. A prefix can have multiple suffixes.

func (*Chain) Build

func (c *Chain) Build(r io.Reader)

Build reads text from the provided Reader and parses it into prefixes and suffixes that are stored in Chain.

func (*Chain) BuildFromString

func (c *Chain) BuildFromString(s string)

BuildFromString ...

func (*Chain) Generate

func (c *Chain) Generate() string

Generate returns a string of at most n words generated from Chain.

func (*Chain) Marshal

func (c *Chain) Marshal() ([]byte, error)

Marshal encodes a chain to json.

func (*Chain) Unmarshal

func (c *Chain) Unmarshal(data []byte) error

Decode decodes json to Chain

type Definition

type Definition struct {
	Metadata struct {
		Provider string `json:"provider"`
	} `json:"metadata"`
	Results []struct {
		ID             string `json:"id"`
		Language       string `json:"language"`
		LexicalEntries []struct {
			Entries []struct {
				Etymologies         []string `json:"etymologies"`
				GrammaticalFeatures []struct {
					Text string `json:"text"`
					Type string `json:"type"`
				} `json:"grammaticalFeatures"`
				HomographNumber string `json:"homographNumber"`
				Senses          []struct {
					Definitions []string `json:"definitions"`
					Examples    []struct {
						Text string `json:"text"`
					} `json:"examples,omitempty"`
					ID      string   `json:"id"`
					Domains []string `json:"domains,omitempty"`
				} `json:"senses"`
			} `json:"entries"`
			Language        string `json:"language"`
			LexicalCategory string `json:"lexicalCategory"`
			Pronunciations  []struct {
				AudioFile        string   `json:"audioFile"`
				Dialects         []string `json:"dialects"`
				PhoneticNotation string   `json:"phoneticNotation"`
				PhoneticSpelling string   `json:"phoneticSpelling"`
			} `json:"pronunciations"`
			Text string `json:"text"`
		} `json:"lexicalEntries"`
		Type string `json:"type"`
		Word string `json:"word"`
	} `json:"results"`
}

type Portfolio

type Portfolio struct{}

Portfolio is the command handling portfolio commands

func (*Portfolio) PortfolioGet

func (p *Portfolio) PortfolioGet(c *cli.Context, r *messagerouter.CommandRequest, w messagerouter.ResponseWriter) error

PortfolioGet gets the current user's portfolio

func (*Portfolio) PortfolioRegister

func (p *Portfolio) PortfolioRegister(c *cli.Context, r *messagerouter.CommandRequest, w messagerouter.ResponseWriter) error

PortfolioRegister adds the current user to the DB (not implemented)

func (*Portfolio) Run

Run will return a string containing the current rate in USD

type Prefix

type Prefix []string

Prefix is a Markov chain prefix of one or more words.

func (Prefix) Shift

func (p Prefix) Shift(word string)

Shift removes the first word from the Prefix and appends the given word.

func (Prefix) String

func (p Prefix) String() string

String returns the Prefix as a string (for use as a map key).

type PuddleErrWriter

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

PuddleErrWriter implements io.Writer

func (*PuddleErrWriter) Write

func (pw *PuddleErrWriter) Write(p []byte) (int, error)

WriteError implements io.Writer for errors

type PuddleWriter

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

PuddleWriter implements io.Writer

func (*PuddleWriter) Write

func (pw *PuddleWriter) Write(p []byte) (int, error)

WriteError implements io.Writer for errors

type Ticker

type Ticker struct {
	ID               string `json:"id"`
	Name             string `json:"name"`
	Symbol           string `json:"symbol"`
	Rank             string `json:"rank"`
	PriceUsd         string `json:"price_usd"`
	PriceBtc         string `json:"price_btc"`
	Two4HVolumeUsd   string `json:"24h_volume_usd"`
	MarketCapUsd     string `json:"market_cap_usd"`
	AvailableSupply  string `json:"available_supply"`
	TotalSupply      string `json:"total_supply"`
	PercentChange1H  string `json:"percent_change_1h"`
	PercentChange24H string `json:"percent_change_24h"`
	PercentChange7D  string `json:"percent_change_7d"`
	LastUpdated      string `json:"last_updated"`
}

Ticker contains all the data for a single crypto

type Tickers

type Tickers []*Ticker

Tickers contain a slice of Ticker

func (Tickers) Get

func (ts Tickers) Get(name string) *Ticker

Get gets the ticker from a slice of tickers

func (Tickers) Symbol

func (ts Tickers) Symbol(sym string) *Ticker

Symbol gets the ticker from a slice of tickers

type WTEMP_amoc

type WTEMP_amoc struct {
	WTEMP_identifier       *WTEMP_identifier       `xml:" identifier,omitempty" json:"identifier,omitempty"`
	WTEMP_issue_time_local *WTEMP_issue_time_local `xml:" issue-time-local,omitempty" json:"issue-time-local,omitempty"`
	WTEMP_issue_time_utc   *WTEMP_issue_time_utc   `xml:" issue-time-utc,omitempty" json:"issue-time-utc,omitempty"`
	WTEMP_phase            *WTEMP_phase            `xml:" phase,omitempty" json:"phase,omitempty"`
	WTEMP_product_type     *WTEMP_product_type     `xml:" product-type,omitempty" json:"product-type,omitempty"`
	WTEMP_sent_time        *WTEMP_sent_time        `xml:" sent-time,omitempty" json:"sent-time,omitempty"`
	WTEMP_service          *WTEMP_service          `xml:" service,omitempty" json:"service,omitempty"`
	WTEMP_source           *WTEMP_source           `xml:" source,omitempty" json:"source,omitempty"`
	WTEMP_status           *WTEMP_status           `xml:" status,omitempty" json:"status,omitempty"`
}
type WTEMP_copyright struct {
	Text string `xml:",chardata" json:",omitempty"`
}

type WTEMP_disclaimer

type WTEMP_disclaimer struct {
	Text string `xml:",chardata" json:",omitempty"`
}

type WTEMP_element

type WTEMP_element struct {
	Attr_duration         string `xml:" duration,attr"  json:",omitempty"`
	Attr_end_time_local   string `xml:" end-time-local,attr"  json:",omitempty"`
	Attr_end_time_utc     string `xml:" end-time-utc,attr"  json:",omitempty"`
	Attr_instance         string `xml:" instance,attr"  json:",omitempty"`
	Attr_start_time_local string `xml:" start-time-local,attr"  json:",omitempty"`
	Attr_start_time_utc   string `xml:" start-time-utc,attr"  json:",omitempty"`
	Attr_time_local       string `xml:" time-local,attr"  json:",omitempty"`
	Attr_time_utc         string `xml:" time-utc,attr"  json:",omitempty"`
	Attr_type             string `xml:" type,attr"  json:",omitempty"`
	Attr_units            string `xml:" units,attr"  json:",omitempty"`
	Text                  string `xml:",chardata" json:",omitempty"`
}

type WTEMP_identifier

type WTEMP_identifier struct {
	Text string `xml:",chardata" json:",omitempty"`
}

type WTEMP_issue_time_local

type WTEMP_issue_time_local struct {
	Attr_tz string `xml:" tz,attr"  json:",omitempty"`
	Text    string `xml:",chardata" json:",omitempty"`
}

type WTEMP_issue_time_utc

type WTEMP_issue_time_utc struct {
	Text string `xml:",chardata" json:",omitempty"`
}

type WTEMP_level

type WTEMP_level struct {
	Attr_index    string           `xml:" index,attr"  json:",omitempty"`
	Attr_type     string           `xml:" type,attr"  json:",omitempty"`
	WTEMP_element []*WTEMP_element `xml:" element,omitempty" json:"element,omitempty"`
}

type WTEMP_observations

type WTEMP_observations struct {
	WTEMP_station []*WTEMP_station `xml:" station,omitempty" json:"station,omitempty"`
}

type WTEMP_office

type WTEMP_office struct {
	Text string `xml:",chardata" json:",omitempty"`
}

type WTEMP_period

type WTEMP_period struct {
	Attr_index      string       `xml:" index,attr"  json:",omitempty"`
	Attr_time_local string       `xml:" time-local,attr"  json:",omitempty"`
	Attr_time_utc   string       `xml:" time-utc,attr"  json:",omitempty"`
	Attr_wind_src   string       `xml:" wind-src,attr"  json:",omitempty"`
	WTEMP_level     *WTEMP_level `xml:" level,omitempty" json:"level,omitempty"`
}

type WTEMP_phase

type WTEMP_phase struct {
	Text string `xml:",chardata" json:",omitempty"`
}

type WTEMP_product

type WTEMP_product struct {
	Attr_xsi_noNamespaceSchemaLocation string              `xml:"http://www.w3.org/2001/XMLSchema-instance noNamespaceSchemaLocation,attr"  json:",omitempty"`
	Attr_version                       string              `xml:" version,attr"  json:",omitempty"`
	Attr_xsi                           string              `xml:"xmlns xsi,attr"  json:",omitempty"`
	WTEMP_amoc                         *WTEMP_amoc         `xml:" amoc,omitempty" json:"amoc,omitempty"`
	WTEMP_observations                 *WTEMP_observations `xml:" observations,omitempty" json:"observations,omitempty"`
}

type WTEMP_product_type

type WTEMP_product_type struct {
	Text string `xml:",chardata" json:",omitempty"`
}

type WTEMP_region

type WTEMP_region struct {
	Text string `xml:",chardata" json:",omitempty"`
}

type WTEMP_root

type WTEMP_root struct {
	WTEMP_product *WTEMP_product `xml:" product,omitempty" json:"product,omitempty"`
}

type WTEMP_sender

type WTEMP_sender struct {
	Text string `xml:",chardata" json:",omitempty"`
}

type WTEMP_sent_time

type WTEMP_sent_time struct {
	Text string `xml:",chardata" json:",omitempty"`
}

type WTEMP_service

type WTEMP_service struct {
	Text string `xml:",chardata" json:",omitempty"`
}

type WTEMP_source

type WTEMP_source struct {
	WTEMP_copyright  *WTEMP_copyright  `xml:" copyright,omitempty" json:"copyright,omitempty"`
	WTEMP_disclaimer *WTEMP_disclaimer `xml:" disclaimer,omitempty" json:"disclaimer,omitempty"`
	WTEMP_office     *WTEMP_office     `xml:" office,omitempty" json:"office,omitempty"`
	WTEMP_region     *WTEMP_region     `xml:" region,omitempty" json:"region,omitempty"`
	WTEMP_sender     *WTEMP_sender     `xml:" sender,omitempty" json:"sender,omitempty"`
}

type WTEMP_station

type WTEMP_station struct {
	Attr_bom_id               string        `xml:" bom-id,attr"  json:",omitempty"`
	Attr_description          string        `xml:" description,attr"  json:",omitempty"`
	Attr_forecast_district_id string        `xml:" forecast-district-id,attr"  json:",omitempty"`
	Attr_lat                  string        `xml:" lat,attr"  json:",omitempty"`
	Attr_lon                  string        `xml:" lon,attr"  json:",omitempty"`
	Attr_stn_height           string        `xml:" stn-height,attr"  json:",omitempty"`
	Attr_stn_name             string        `xml:" stn-name,attr"  json:",omitempty"`
	Attr_type                 string        `xml:" type,attr"  json:",omitempty"`
	Attr_tz                   string        `xml:" tz,attr"  json:",omitempty"`
	Attr_wmo_id               string        `xml:" wmo-id,attr"  json:",omitempty"`
	WTEMP_period              *WTEMP_period `xml:" period,omitempty" json:"period,omitempty"`
}

type WTEMP_status

type WTEMP_status struct {
	Text string `xml:",chardata" json:",omitempty"`
}

type W_amoc

type W_amoc struct {
	W_expiry_time                   *W_expiry_time                   `xml:" expiry-time,omitempty" json:"expiry-time,omitempty"`
	W_identifier                    *W_identifier                    `xml:" identifier,omitempty" json:"identifier,omitempty"`
	W_issue_time_local              *W_issue_time_local              `xml:" issue-time-local,omitempty" json:"issue-time-local,omitempty"`
	W_issue_time_utc                *W_issue_time_utc                `xml:" issue-time-utc,omitempty" json:"issue-time-utc,omitempty"`
	W_next_routine_issue_time_local *W_next_routine_issue_time_local `xml:" next-routine-issue-time-local,omitempty" json:"next-routine-issue-time-local,omitempty"`
	W_next_routine_issue_time_utc   *W_next_routine_issue_time_utc   `xml:" next-routine-issue-time-utc,omitempty" json:"next-routine-issue-time-utc,omitempty"`
	W_phase                         *W_phase                         `xml:" phase,omitempty" json:"phase,omitempty"`
	W_product_type                  *W_product_type                  `xml:" product-type,omitempty" json:"product-type,omitempty"`
	W_sent_time                     *W_sent_time                     `xml:" sent-time,omitempty" json:"sent-time,omitempty"`
	W_service                       *W_service                       `xml:" service,omitempty" json:"service,omitempty"`
	W_source                        *W_source                        `xml:" source,omitempty" json:"source,omitempty"`
	W_status                        *W_status                        `xml:" status,omitempty" json:"status,omitempty"`
	W_sub_service                   *W_sub_service                   `xml:" sub-service,omitempty" json:"sub-service,omitempty"`
	W_validity_bgn_time_local       *W_validity_bgn_time_local       `xml:" validity-bgn-time-local,omitempty" json:"validity-bgn-time-local,omitempty"`
	W_validity_end_time_local       *W_validity_end_time_local       `xml:" validity-end-time-local,omitempty" json:"validity-end-time-local,omitempty"`
}

type W_area

type W_area struct {
	Attr_aac          string               `xml:" aac,attr"  json:",omitempty"`
	Attr_description  string               `xml:" description,attr"  json:",omitempty"`
	Attr_parent_aac   string               `xml:" parent-aac,attr"  json:",omitempty"`
	Attr_type         string               `xml:" type,attr"  json:",omitempty"`
	W_forecast_period []*W_forecast_period `xml:" forecast-period,omitempty" json:"forecast-period,omitempty"`
}
type W_copyright struct {
	Text string `xml:",chardata" json:",omitempty"`
}

type W_disclaimer

type W_disclaimer struct {
	Text string `xml:",chardata" json:",omitempty"`
}

type W_expiry_time

type W_expiry_time struct {
	Text string `xml:",chardata" json:",omitempty"`
}

type W_forecast

type W_forecast struct {
	W_area []*W_area `xml:" area,omitempty" json:"area,omitempty"`
}

type W_forecast_period

type W_forecast_period struct {
	Attr_end_time_local   string    `xml:" end-time-local,attr"  json:",omitempty"`
	Attr_end_time_utc     string    `xml:" end-time-utc,attr"  json:",omitempty"`
	Attr_index            string    `xml:" index,attr"  json:",omitempty"`
	Attr_start_time_local string    `xml:" start-time-local,attr"  json:",omitempty"`
	Attr_start_time_utc   string    `xml:" start-time-utc,attr"  json:",omitempty"`
	W_text                []*W_text `xml:" text,omitempty" json:"text,omitempty"`
}

type W_identifier

type W_identifier struct {
	Text string `xml:",chardata" json:",omitempty"`
}

type W_issue_time_local

type W_issue_time_local struct {
	Attr_tz string `xml:" tz,attr"  json:",omitempty"`
	Text    string `xml:",chardata" json:",omitempty"`
}

type W_issue_time_utc

type W_issue_time_utc struct {
	Text string `xml:",chardata" json:",omitempty"`
}

type W_next_routine_issue_time_local

type W_next_routine_issue_time_local struct {
	Attr_tz string `xml:" tz,attr"  json:",omitempty"`
	Text    string `xml:",chardata" json:",omitempty"`
}

type W_next_routine_issue_time_utc

type W_next_routine_issue_time_utc struct {
	Text string `xml:",chardata" json:",omitempty"`
}

type W_office

type W_office struct {
	Text string `xml:",chardata" json:",omitempty"`
}

type W_p

type W_p struct {
	Text string `xml:",chardata" json:",omitempty"`
}

type W_phase

type W_phase struct {
	Text string `xml:",chardata" json:",omitempty"`
}

type W_product

type W_product struct {
	Attr_xsi_noNamespaceSchemaLocation string      `xml:"http://www.w3.org/2001/XMLSchema-instance noNamespaceSchemaLocation,attr"  json:",omitempty"`
	Attr_version                       string      `xml:" version,attr"  json:",omitempty"`
	Attr_xsi                           string      `xml:"xmlns xsi,attr"  json:",omitempty"`
	W_amoc                             *W_amoc     `xml:" amoc,omitempty" json:"amoc,omitempty"`
	W_forecast                         *W_forecast `xml:" forecast,omitempty" json:"forecast,omitempty"`
}

type W_product_type

type W_product_type struct {
	Text string `xml:",chardata" json:",omitempty"`
}

type W_region

type W_region struct {
	Text string `xml:",chardata" json:",omitempty"`
}

type W_root

type W_root struct {
	W_product *W_product `xml:" product,omitempty" json:"product,omitempty"`
}

type W_sender

type W_sender struct {
	Text string `xml:",chardata" json:",omitempty"`
}

type W_sent_time

type W_sent_time struct {
	Text string `xml:",chardata" json:",omitempty"`
}

type W_service

type W_service struct {
	Text string `xml:",chardata" json:",omitempty"`
}

type W_source

type W_source struct {
	W_copyright  *W_copyright  `xml:" copyright,omitempty" json:"copyright,omitempty"`
	W_disclaimer *W_disclaimer `xml:" disclaimer,omitempty" json:"disclaimer,omitempty"`
	W_office     *W_office     `xml:" office,omitempty" json:"office,omitempty"`
	W_region     *W_region     `xml:" region,omitempty" json:"region,omitempty"`
	W_sender     *W_sender     `xml:" sender,omitempty" json:"sender,omitempty"`
}

type W_status

type W_status struct {
	Text string `xml:",chardata" json:",omitempty"`
}

type W_sub_service

type W_sub_service struct {
	Text string `xml:",chardata" json:",omitempty"`
}

type W_text

type W_text struct {
	Attr_type string `xml:" type,attr"  json:",omitempty"`
	Text      string `xml:",chardata" json:",omitempty"`
	W_p       []*W_p `xml:" p,omitempty" json:"p,omitempty"`
}

type W_validity_bgn_time_local

type W_validity_bgn_time_local struct {
	Attr_tz string `xml:" tz,attr"  json:",omitempty"`
	Text    string `xml:",chardata" json:",omitempty"`
}

type W_validity_end_time_local

type W_validity_end_time_local struct {
	Attr_tz string `xml:" tz,attr"  json:",omitempty"`
	Text    string `xml:",chardata" json:",omitempty"`
}

Jump to

Keyboard shortcuts

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