masterpoll_go_sdk

package module
v0.0.0-...-11fd557 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2020 License: Apache-2.0 Imports: 3 Imported by: 11

README

MasterPoll Golang SDK

MasterPoll logo

Introduction

masterpoll-go-sdk is a new library made in collaboration with MasterPoll Telegram bot to manage their web APIs comfortably in Golang without writing it all by yourself.

Getting started

Install this repository

Install masterpoll-go-sdk on your pc using:

go get github.com/ErikPelli/masterpoll-go-sdk
Get an API Key

Before starting to use this library, you must get your own token to use the MasterPoll API, writing /api to MasterPoll Telegram bot.

Read the documentation

You can find the documentation for this library at godoc.org.

Understand the library structure

Before starting to use this library, you must create a variable of type MasterPoll, passing as a parameter the API key.

Now, you can create your poll (using MasterPollvar.CreatePoll function, passing a (PollType)Create type that has been set before.

You could also use GetPoll function that returns a Poll type (a map[string]interface{}), and in masterpoll-go-sdk package there are functions to edit its fields on MasterPoll web database (using the Rest API provided by them).

Check our examples

You can take a cue from all the examples in the cmd folder, to better understand how to integrate MasterPoll into your project, using the various functions available.

Let's start!

Now that you understand how it all works, you can integrate MasterPoll into your project!

⚠️ Archiving

Masterpoll telegram bot is no longer available, so this repository has been archived.

Documentation

Overview

Package to manage MasterPoll API using polls' package types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPollVote

func AddPollVote(poll *polls.Poll, value interface{}) error

AddPollVote adds your vote to a poll. value param by poll type: vote, doodle, limited doodle, quiz and board -> string rating -> int between 1 and 10 participation -> nil (It isn't required)

func ClosePoll

func ClosePoll(poll *polls.Poll) error

ClosePoll closes a opened poll (people will no longer be able to vote).

func DeletePoll

func DeletePoll(poll *polls.Poll) error

DeletePoll deletes the poll definitively (this action is irreversible).

func EditPoll

func EditPoll(poll *polls.Poll, privacy bool, settings *polls.Settings) error

EditPoll edits an existent poll.

func EditPollVote

func EditPollVote(poll *polls.Poll, value interface{}) error

EditPollVote edits your vote in a poll. value param by poll type: vote, quiz and board -> string rating -> int between 1 and 10 participation -> bool (true or false) doodle and limited doodle -> not supported

func GetGraph

func GetGraph(poll *polls.Poll, dark, bar bool) (string, error)

Function to get an URL with the graph of the poll. dark: true -> dark, false -> light. bar: true -> bar, false -> pie.

func GetStatus

func GetStatus() bool

GetStatus() returns API status (true -> ON, false -> OFF)

func OpenPoll

func OpenPoll(poll *polls.Poll) error

OpenPoll opens a closed poll.

func RemovePollVote

func RemovePollVote(poll *polls.Poll, choice string) error

RemoveVote removes your vote from a poll. Choice must contain the vote to remove as string only if the poll type is doodle, limited doodle or quiz (For the others you have to use "").

Types

type MasterPoll

type MasterPoll string

func MasterPollNew

func MasterPollNew(APIKey string) *MasterPoll

Create a new MasterPoll with an API key.

func (*MasterPoll) CreatePoll

func (MPoll *MasterPoll) CreatePoll(pollSend interface{}) (int, error)

Create a new poll with a PollSend interface object and return poll_id as int.

func (*MasterPoll) GetActivePolls

func (MPoll *MasterPoll) GetActivePolls() ([]*polls.Poll, error)

GetActivePolls returns all your polls currently active in MasterPoll database.

func (*MasterPoll) GetAllPolls

func (MPoll *MasterPoll) GetAllPolls() ([]*polls.Poll, error)

GetActivePolls returns all your polls in MasterPoll database.

func (*MasterPoll) GetMe

func (MPoll *MasterPoll) GetMe() ([]string, error)

GetMe() returns your personal information saved in bot database as a []string. 0 -> first_name, 1 -> last_name, 2 -> username, 3 -> language.

func (*MasterPoll) GetPoll

func (MPoll *MasterPoll) GetPoll(pollId int) (*polls.Poll, error)

GetPoll gets an existent poll from its id.

func (*MasterPoll) GetSubscribers

func (MPoll *MasterPoll) GetSubscribers() (int, error)

GetSubscribers() returns bot subscribers number

func (*MasterPoll) SetAPI

func (MPoll *MasterPoll) SetAPI(APIKey string)

Change API key of MasterPoll.

Directories

Path Synopsis
cmd
Package to manage errors produced by other packages.
Package to manage errors produced by other packages.
internal
Package polls provides types to manage polls and some functions to create or manage them.
Package polls provides types to manage polls and some functions to create or manage them.

Jump to

Keyboard shortcuts

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