bot

package
v0.0.0-...-94bce39 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bot

type Bot struct {
}

func NewBot

func NewBot() *Bot

New returns a new Bot object

func (*Bot) Run

func (b *Bot) Run() error

type Client

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

func NewTelegramClient

func NewTelegramClient(host string, token string, httpclient *http.Client) Client

func (*Client) RunRecvMsgLoop

func (c *Client) RunRecvMsgLoop(ctx context.Context, chwait chan<- struct{}, limit int, timeout int) error

delay timeout sec, max limit updates in one batch

func (*Client) SendMessage

func (c *Client) SendMessage(ctx context.Context, chatID int, text string) error

type Fetcher

type Fetcher struct {
	BaseURL *url.URL
	// contains filtered or unexported fields
}

func NewFetcher

func NewFetcher(ctx context.Context, httpclient *http.Client) *Fetcher

func (*Fetcher) FetchLanguagesList

func (t *Fetcher) FetchLanguagesList() ([]Language, error)

Fetch and parse language list from https://github.com/trending

func (*Fetcher) FetchRepos

func (t *Fetcher) FetchRepos(timeframe TrendTime, lang Language) ([]Repo, error)

Fetch and parse trending repo list from https://github.com/trending if lang.Name not set when fetch all trending language repos

type Language

type Language struct {
	Name string
}

type Message

type Message struct {
	ID   int    `json:"message_id"`
	Text string `json:"text"`
}

structs for Telegram api

type Repo

type Repo struct {
	NameURL  string
	Desc     string
	Language string
	Stars    [4]int // daily, weekly, monthly, all
}

type TimeInterval

type TimeInterval struct {
	Type     string
	Repolist []Repo
}

type TrendTime

type TrendTime int
const (
	TimeDaily TrendTime = 0 // daily
	TimeWeek  TrendTime = 1 // weekly
	TimeMonth TrendTime = 2 // monthly
)

type Update

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

type UpdatesResponse

type UpdatesResponse struct {
	Ok     bool     `json:"ok"`
	Result []Update `json:"result"`
}

Jump to

Keyboard shortcuts

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