HaruiBot

package module
v0.0.0-...-47c01e7 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

README

HaruiBot

Simple Telegram bot api Framework, based on Reibot Design.


Quick Reference

Documentation

Overview

Package HaruiBot This package for make color log here. reference : https://shipengqi.github.io/posts/2019-09-18-go-color/

Index

Constants

View Source
const (
	PanicLevel int = iota
	FatalLevel
	ErrorLevel
	WarnLevel
	InfoLevel
	DebugLevel
)

Variables

View Source
var (
	ConnectionLogger   = log.Logger{} // connection, receiving messages.
	BotSelfLogger      = log.Logger{} // bot information, Handler information.
	BotSelfPanicLogger = log.Logger{} // bot handler panic information yet.
)

Functions

func Colorize

func Colorize(s string, c Color) string

Colorize a string based on given color.

func PrintLogo()

func ProcessHandler

func ProcessHandler()

Types

type BotConfig

type BotConfig struct {
	BotName         string  // if BotName is null, them use Telegram Provided.
	AdministratorID []int64 // if null, them admin permission will not work yet.
}

type BotInstance

type BotInstance struct {
	UnionId           int64 // union id is generated when an instance work here, to ensure instance worker can be found by id.
	BotUserConfig     BotConfig
	BotRegisterUpdate []string
	Worker            tgbotapi.BotAPI
	Self              tgbotapi.User
}

BotInstance bot data will store into mapped runner.

func (*BotInstance) RunInstance

func (b *BotInstance) RunInstance()

type BotRegister

type BotRegister struct {
	BotConfig
	Token      string
	Debug      bool
	HttpClient http.Client // make request work with proxy if you are in Mainland China or some countries that you cannot contact.
	OnUpdate   []string    // Telegram requests for updated information, which can ensure what bot will receive data here.
}

func (*BotRegister) GetInstance

func (register *BotRegister) GetInstance() *BotInstance

GetInstance make a new instance bot here

type Color

type Color int

Color defines a single SGR Code

const (
	FgBlack Color = iota + 30
	FgRed
	FgGreen
	FgYellow
	FgBlue
	FgMagenta
	FgCyan
	FgWhite
)

Foreground text colors

const (
	FgHiBlack Color = iota + 90
	FgHiRed
	FgHiGreen
	FgHiYellow
	FgHiBlue
	FgHiMagenta
	FgHiCyan
	FgHiWhite
)

Foreground Hi-Intensity text colors

type DefaultSets

type DefaultSets struct {
	DataFolder         string
	DisableChannelUser bool // in some situation,
	// we may not want a channel (ignore / unknown user) to use our bot,
	//so this function can enable to stop work for channel user yet.
	DataBaseLocation string
}

DefaultSets when application work, read config here.

var ApplicationSets DefaultSets

Directories

Path Synopsis
Package database, store user handler information here, also user can register for storing data here.
Package database, store user handler information here, also user can register for storing data here.

Jump to

Keyboard shortcuts

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