v0.5.0
This commit is contained in:
6
bot.go
6
bot.go
@@ -262,12 +262,6 @@ func (b *Bot) Run() {
|
|||||||
middleware.Execute(ctx, b.dbContext)
|
middleware.Execute(ctx, b.dbContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, plugin := range b.plugins {
|
|
||||||
if plugin.UpdateListener != nil {
|
|
||||||
(*plugin.UpdateListener)(ctx, b.dbContext)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if u.CallbackQuery != nil {
|
if u.CallbackQuery != nil {
|
||||||
b.handleCallback(u, ctx)
|
b.handleCallback(u, ctx)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ type Api struct {
|
|||||||
func NewAPI(token string) *Api {
|
func NewAPI(token string) *Api {
|
||||||
l := slog.CreateLogger().Level(utils.GetLoggerLevel()).Prefix("API")
|
l := slog.CreateLogger().Level(utils.GetLoggerLevel()).Prefix("API")
|
||||||
l.AddWriter(l.CreateJsonStdoutWriter())
|
l.AddWriter(l.CreateJsonStdoutWriter())
|
||||||
client := &http.Client{Timeout: time.Second * 10}
|
client := &http.Client{Timeout: time.Second * 45}
|
||||||
return &Api{token, client, l}
|
return &Api{token, client, l}
|
||||||
}
|
}
|
||||||
func (api *Api) CloseApi() error {
|
func (api *Api) CloseApi() error {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package tgapi
|
package tgapi
|
||||||
|
|
||||||
|
import "git.nix13.pw/scuroneko/extypes"
|
||||||
|
|
||||||
type MessageReplyMarkup struct {
|
type MessageReplyMarkup struct {
|
||||||
InlineKeyboard [][]InlineKeyboardButton `json:"inline_keyboard"`
|
InlineKeyboard [][]InlineKeyboardButton `json:"inline_keyboard"`
|
||||||
}
|
}
|
||||||
@@ -26,7 +28,7 @@ type Message struct {
|
|||||||
|
|
||||||
Text string `json:"text"`
|
Text string `json:"text"`
|
||||||
|
|
||||||
Photo []*PhotoSize `json:"photo,omitempty"`
|
Photo extypes.Slice[*PhotoSize] `json:"photo,omitempty"`
|
||||||
Caption string `json:"caption,omitempty"`
|
Caption string `json:"caption,omitempty"`
|
||||||
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
|
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
|
||||||
|
|
||||||
|
|||||||
6
utils.go
6
utils.go
@@ -1,5 +1,7 @@
|
|||||||
package laniakea
|
package laniakea
|
||||||
|
|
||||||
|
import "git.nix13.pw/scuroneko/laniakea/utils"
|
||||||
|
|
||||||
func Ptr[T any](v T) *T { return &v }
|
func Ptr[T any](v T) *T { return &v }
|
||||||
|
|
||||||
func Val[T any](p *T, def T) T {
|
func Val[T any](p *T, def T) T {
|
||||||
@@ -8,3 +10,7 @@ func Val[T any](p *T, def T) T {
|
|||||||
}
|
}
|
||||||
return def
|
return def
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const VersionString = utils.VersionString
|
||||||
|
|
||||||
|
var EscapeMarkdown = utils.EscapeMarkdown
|
||||||
|
|||||||
Reference in New Issue
Block a user