polls

package
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: 1 Imported by: 2

Documentation

Overview

Package polls provides types to manage polls and some functions to create or manage them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoardCreate

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

A more specific poll type for Board.

func BoardPollNew

func BoardPollNew(title, description string, privacy bool, settings *Settings) (*BoardCreate, error)

Create a type manageable by the CreatePoll function for a new Board poll. The parameters description and settings are optional (they could be respectively "" and nil).

type DoodleCreate

type DoodleCreate struct {
	Choices *[]string `json:"choices"` // Possible choices of Doodle poll (string slice).
	// contains filtered or unexported fields
}

A more specific poll type for Doodle.

func DoodlePollNew

func DoodlePollNew(title, description string, privacy bool, choices *[]string, settings *Settings) (*DoodleCreate, error)

Create a type manageable by the CreatePoll function for a new Doodle poll. The parameters description and settings are optional (they could be respectively "" and nil).

type LimitedDoodleCreate

type LimitedDoodleCreate struct {
	Choices    *[]string `json:"choices"`
	MaxChoices *int      `json:"max_choices"`
	// contains filtered or unexported fields
}

A more specific poll type for Limited Doodle.

func LimitedDoodlePollNew

func LimitedDoodlePollNew(title, description string, privacy bool, choices *[]string, maxChoices int, settings *Settings) (*LimitedDoodleCreate, error)

Create a type manageable by the CreatePoll function for a new Limited Doodle poll. The parameters description and settings are optional (they could be respectively "" and nil).

type ParticipationCreate

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

A more specific poll type for Participation.

func ParticipationPollNew

func ParticipationPollNew(title, description string, settings *Settings) (*ParticipationCreate, error)

Create a type manageable by the CreatePoll function for a new Participation poll. The parameters description and settings are optional (they could be respectively "" and nil).

type Poll

type Poll map[string]interface{}

func (Poll) GetAPI

func (poll Poll) GetAPI() string

GetAPI returns API key of current Poll.

func (Poll) GetContent

func (poll Poll) GetContent() map[string]interface{}

Get Poll object as a map Possible contents:

poll_id - Integer - This is the identifier of the poll.

owner_id - Integer - This is the Telegram identifier of the owner.

title - String (1-512 characters) - This is the title of the poll.

description - String (1-512 characters) - This is the description of the poll.

privacy - String (1-32 characters) - This is the privacy of the poll. It can be anonymous or personal.

status - String - This is the status of the poll. It can be open or closed.

type - String (1-64 characters) - This is the type of poll. It can be vote, doodle, limited doodle, board, participation/war, rating or quiz.

participants - Array of strings - If the type of poll is participation here you can find all names of the participants.

participating - Boolean - If the type of poll is participation here you can find if you’re participating or not.

comments - Array of strings - If the type of poll is board here you can find all comments. If the privacy is set to personal the keys of all comments is the name of its.

rating - Array of strings - If the type of poll is rating here you can find the user’s rating.

choices - Array of strings - If the type of poll is vote, doodle, limited doodle or quiz here you can find all options and the number of voters for each option. If the privacy is personal the values of all options will be an array of names.

max_choices - Integer - If the type of poll is limited doodle this is the max choices that can be inserted.

right_choices Array of strings If the type of poll is quiz there are the right choices.

func (Poll) GetId

func (poll Poll) GetId() int

GetId returns poll_id of current Poll.

func (Poll) GetPrivacy

func (poll Poll) GetPrivacy() bool

GetPrivacy returns a boolean that indicates if the Poll is anonymous or not.

func (Poll) GetType

func (poll Poll) GetType() string

GetType returns poll type of current Poll.

func (Poll) SetAPI

func (poll Poll) SetAPI(api string)

SetAPI sets API key of current Poll.

func (Poll) SetPrivacy

func (poll Poll) SetPrivacy(privacy bool)

SetPrivacy sets Poll privacy from a boolean that indicates if the Poll is anonymous or not.

type QuizCreate

type QuizCreate struct {
	Choices      *[]string `json:"choices"`
	RightChoices *[]string `json:"right_choices"`
	// contains filtered or unexported fields
}

A more specific poll type for Quiz.

func QuizPollNew

func QuizPollNew(title, description string, privacy bool, choices, rightChoices *[]string, settings *Settings) (*QuizCreate, error)

Create a type manageable by the CreatePoll function for a new Quiz poll. The parameters description and settings are optional (they could be respectively "" and nil).

type RatingCreate

type RatingCreate struct {
	StartRange *int `json:"start_rating_range"`
	EndRange   *int `json:"end_rating_range"`
	// contains filtered or unexported fields
}

A more specific poll type for Rating.

func RatingPollNew

func RatingPollNew(title, description string, privacy bool, startRange, endRange int, settings *Settings) (*RatingCreate, error)

Create a type manageable by the CreatePoll function for a new Rating poll. The parameters description and settings are optional (they could be respectively "" and nil).

type Settings

type Settings struct {
	PagePreview    *bool   `json:"disable_web_page_preview,omitempty"`    // PagePreview setting pointer
	ContentPreview *bool   `json:"disable_web_content_preview,omitempty"` // ContentPreview setting pointer
	LinkPreview    *string `json:"web_content_preview,omitempty"`         // LinkPreview setting pointer
	Sort           *bool   `json:"sort,omitempty"`                        // Sort setting pointer
	Appendable     *bool   `json:"appendable,omitempty"`                  // Appendable setting pointer
	Notification   *bool   `json:"notification,omitempty"`                // Notification setting pointer
	VotesLimit     *int    `json:"votes_limit,omitempty"`                 // VotesLimit setting pointer
}

Settings type is used to add some Settings to a Poll. If a variable of Settings will be unset when used, it will be skipped.

func SettingsNew

func SettingsNew() *Settings

Create a new empty Settings object (unset options are set do default values).

func (*Settings) GetLinkPreview

func (conf *Settings) GetLinkPreview() string

LinkPreview -> The direct link for a media preview on the message.

func (*Settings) SetAppendable

func (conf *Settings) SetAppendable(appendable bool)

Appendable enables/disables the append option.

func (*Settings) SetContentPreview

func (conf *Settings) SetContentPreview(preview bool)

SetContentPreview enables/disables the content preview for the message.

func (*Settings) SetNotification

func (conf *Settings) SetNotification(notification bool)

Notification enables/disables notifications for append or board polls.

func (*Settings) SetPagePreview

func (conf *Settings) SetPagePreview(preview bool)

SetPagePreview enables/disables the web page preview for the message or show if is disabled or enabled.

func (*Settings) SetSort

func (conf *Settings) SetSort(sort bool)

SetSort enables/disables the Sort of the options by number of votes.

func (*Settings) SetVotesLimit

func (conf *Settings) SetVotesLimit(limit int)

VotesLimit sets a votes limit (between 1 and 999). It could be removed using 0.

type VoteCreate

type VoteCreate struct {
	Choices *[]string `json:"choices"` // Possible choices of Vote poll (string slice).
	// contains filtered or unexported fields
}

A more specific poll type for Vote.

func VotePollNew

func VotePollNew(title, description string, privacy bool, choices *[]string, settings *Settings) (*VoteCreate, error)

Create a type manageable by the CreatePoll function for a new Vote poll. The parameters description and settings are optional (they could be respectively "" and nil).

Jump to

Keyboard shortcuts

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