greetbot

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package greetbot is a minimal, real Telegram bot used to exercise Chatwright end-to-end. It speaks the Telegram Bot API via the tgbotapi client library; its outbound calls are redirected to whatever Bot API host it is constructed with (Chatwright's emulator in tests, https://api.telegram.org in production).

It is intentionally tiny: /start offers a language choice — picking one edits that same message in place, translating it, and is remembered for the rest of the chat — and /time replies with the current time. The point is to prove a genuine Telegram-protocol bot — parsing real updates, tracking per-chat state, editing its own messages, and sending via the real client — can be driven by Chatwright over HTTP.

Index

Constants

View Source
const TimeLayout = "15:04:05 MST"

TimeLayout is the format /time replies use. Exported so tests can compute the exact expected reply for a given instant without duplicating the format.

Variables

This section is empty.

Functions

func FormatTime

func FormatTime(t time.Time) string

FormatTime renders t (in UTC) the way /time replies do.

Types

type Bot

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

Bot is a minimal Telegram bot with per-chat language state.

func New

func New(apiBaseURL, token string, opts ...Option) *Bot

New builds a bot whose Telegram Bot API calls go to apiBaseURL (e.g. Chatwright's emulator URL). token is the bot token used in the API path.

func (*Bot) Handler

func (b *Bot) Handler() http.Handler

Handler returns the bot's webhook handler. Point Chatwright at it with ServeWebhook, or run it on a real listener and use WebhookAt.

type Option

type Option func(*Bot)

Option configures a Bot at construction time.

func WithClock

func WithClock(now func() time.Time) Option

WithClock overrides the bot's notion of "now", used by /time. Tests use it to get a deterministic, assertable reply instead of racing the wall clock.

Jump to

Keyboard shortcuts

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