botUtils

package module
v0.0.0-...-2e7725e Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2017 License: AGPL-3.0 Imports: 9 Imported by: 1

README

Configuration

You'll need to configure these environment variables to ensure successful loading: DARKSKY_TOKEN, LATLONGITUDE, CHANNEL_SECRET, CHANNEL_TOKEN, PORT, MOVIE_TOKEN.

DARKSKY_TOKEN can be obtained from darksky.net/dev/.
LATLONGITUDE is "LATITUDE,LONGITUDE".
MOVIE_TOKEN can be obtained from themoviedb.org/.
PORT is without the : character.

All environment variables are in string.

You'll also need to install ImageMagick on your server.


Setting Up

Initialize first by doing botUtils.Initialize(randomNumberAsASeed), then you can use botUtils.Call.SetReplyToken(replyToken) and handler.HandleCommand(message.Text) accordingly.

You have to open a fileserver of the downloaded directory.

That's it.


Commands

  1. !<a question>? -> ball8
  2. !coin -> flip a coin
  3. !dice -> dice
  4. =<some math equation> -> latex
  5. !film <film name> -> movies
  6. !qod -> quote of the day
  7. !weather -> weather

An alternative word is also available (check commandHandler).


Contributing

Don't hesitate to ask a question regarding contributing. I'll try to answer them if I can.

Documentation

Overview

botUtils provides a quicker method of calling the command and initializing all of the command instead of doing it manually one by one.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Initialize

func Initialize(Seed int64, botClient *linebot.Client)

Initialize() assigns a linebot.Client pointer to a Bot variable, making it usable for the handler. It also initialize other things such as creating a new weather instance, setting a random seed, and reading ball8 choices text file. In this way, only this method of initialization is necessary to make the bot work.

Types

type Caller

type Caller struct {
	Bot        *linebot.Client
	ReplyToken string
}

Caller provides a list of executable command function which simplifies commandHandler's process.

var Call Caller

func Execute

func Execute() *Caller

Execute() returns a Caller, which then provides a list of executable command function.

func NewCaller

func NewCaller(Client *linebot.Client) Caller

Returns a Caller with Client argument as the pointer of the linebot.Client

func (*Caller) Ball8

func (c *Caller) Ball8(Message string)

Executes Ball8 command.

func (*Caller) Coin

func (c *Caller) Coin()

Executes Coin command.

func (*Caller) Dice

func (c *Caller) Dice()

Executes Dice command.

func (*Caller) Latex

func (c *Caller) Latex(Eqn string)

Executes Latex command.

func (*Caller) Movies

func (c *Caller) Movies(lookup, year string)

Executes Movies command.

func (*Caller) Quotes

func (c *Caller) Quotes()

Executes Quotes command.

func (*Caller) SetReplyToken

func (c *Caller) SetReplyToken(ReplyToken string)

Sets a replytoken to ensure proper replying. NOTICE: This token must be refreshed everytime it is possible to ensure proper replying.

func (*Caller) Weather

func (c *Caller) Weather(arg string)

Executes Weather command.

Directories

Path Synopsis
Provides a gateway for the handler into handling a command (message) sent by an user.
Provides a gateway for the handler into handling a command (message) sent by an user.
commands
ball8
Provides a "yes/no" type reply when executed.
Provides a "yes/no" type reply when executed.
coin
Provides the result of a flipping coin.
Provides the result of a flipping coin.
dice
Provides the result of a rolling dice.
Provides the result of a rolling dice.
latex
Provides a quick way into parsing a message into the chat into a latex equation (generally math equation).
Provides a quick way into parsing a message into the chat into a latex equation (generally math equation).
movies
Provides a summary of a movie based on themoviedb.org
Provides a summary of a movie based on themoviedb.org
quotes
Provides a qod of the specified category (http://quotes.rest/qod/categories to see the list of available public categories).
Provides a qod of the specified category (http://quotes.rest/qod/categories to see the list of available public categories).
weather
Provides a quick weather lookup.
Provides a quick weather lookup.
Provides a simple way to handle a potential command from a message sent by a user.
Provides a simple way to handle a potential command from a message sent by a user.
Provides a random integer generator.
Provides a random integer generator.
Provides a simple reply handler to the user.
Provides a simple reply handler to the user.

Jump to

Keyboard shortcuts

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