handler

package
v0.0.0-...-3b0903e Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package handler contains an HTTP Cloud Function to handle update from Telegram whenever a users interacts with the bot.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleTelegramWebHook

func HandleTelegramWebHook(w http.ResponseWriter, r *http.Request)

HandleTelegramWebHook sends a message back to the chat with a punchline starting by the message provided by the user.

Types

type Audio

type Audio struct {
	FileId   string `json:"file_id"`
	Duration int    `json:"duration"`
}

Audio message has extra attributes

func (Audio) String

func (a Audio) String() string

Implements the fmt.String interface to get the representation of an Audio as a string.

type Chat

type Chat struct {
	Id int `json:"id"`
}

A Chat indicates the conversation to which the Message belongs.

func (Chat) String

func (c Chat) String() string

Implements the fmt.String interface to get the representation of a Chat as a string.

type Document

type Document struct {
	FileId   string `json:"file_id"`
	FileName string `json:"file_name"`
}

Document Message refer to a file sent.

func (Document) String

func (d Document) String() string

Implements the fmt.String interface to get the representation of an Document as a string.

type Lyric

type Lyric struct {
	Punch string `json:"output"`
}

A Lyric is generated by the RapLyrics service.

type Message

type Message struct {
	Text     string   `json:"text"`
	Chat     Chat     `json:"chat"`
	Audio    Audio    `json:"audio"`
	Voice    Voice    `json:"voice"`
	Document Document `json:"document"`
}

Message is a Telegram object that can be found in an update. Note that not all Update contains a Message. Update for an Inline Query doesn't.

func (Message) String

func (m Message) String() string

Implements the fmt.String interface to get the representation of a Message as a string.

type Update

type Update struct {
	UpdateId int     `json:"update_id"`
	Message  Message `json:"message"`
}

Update is a Telegram object that we receive every time an user interacts with the bot.

func (Update) String

func (u Update) String() string

Implements the fmt.String interface to get the representation of an Update as a string.

type Voice

type Voice Audio

Voice Message can be summarized with similar attribute as an Audio message for our use case.

Jump to

Keyboard shortcuts

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