2024-03-29 14:30:48 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-05-15 20:41:53 +03:00
|
|
|
"surdeus.su/core/tg"
|
2024-03-29 14:30:48 +03:00
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
2024-05-15 20:41:53 +03:00
|
|
|
var UsageAction = tg.Func(func(c tg.Context) {
|
2024-03-29 14:30:48 +03:00
|
|
|
c.Sendf(
|
|
|
|
"There is no such command %q",
|
|
|
|
c.CallbackUpdate().Message.Command(),
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
2024-05-15 20:41:53 +03:00
|
|
|
var PreStartAction = tg.Func(func(c tg.Context) {
|
2024-03-29 14:30:48 +03:00
|
|
|
c.Sendf("Please, use /start ")
|
|
|
|
})
|
|
|
|
|
|
|
|
var BotCommands = []tg.Command{
|
|
|
|
tg.NewCommand(
|
|
|
|
"start",
|
|
|
|
"start or restart the bot or move to the start screen",
|
|
|
|
).Go(StartAbsPath),
|
|
|
|
tg.NewCommand(
|
|
|
|
"info",
|
|
|
|
"info desc",
|
|
|
|
).WithAction(tg.Func(func(c tg.Context) {
|
2024-05-15 20:41:53 +03:00
|
|
|
c.SendfHTML(`<a href="https://res.cloudinary.com/demo/image/upload/v1312461204/sample.jpg">cock</a><strong>cock</strong> die`)
|
2024-03-29 14:30:48 +03:00
|
|
|
})),
|
|
|
|
tg.NewCommand("hello", "sends the 'Hello, World!' message back").
|
|
|
|
WithAction(tg.Func(func(c tg.Context) {
|
|
|
|
c.Sendf("Hello, World!")
|
|
|
|
})),
|
|
|
|
tg.NewCommand("read", "reads a string and sends it back").
|
|
|
|
WithWidget(
|
|
|
|
tg.Func(func(c tg.Context) {
|
|
|
|
str := c.ReadString("Type a string and I will send it back")
|
|
|
|
if str == "" {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
c.Sendf2("You typed `%s`", str)
|
|
|
|
}),
|
|
|
|
),
|
|
|
|
tg.NewCommand("cat", "sends a sample image of cat from the server storage").
|
|
|
|
WithAction(tg.Func(func(c tg.Context) {
|
|
|
|
f, err := os.Open("media/cat.jpg")
|
|
|
|
if err != nil {
|
|
|
|
c.Sendf("err: %s", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
defer f.Close()
|
|
|
|
photo := tg.NewFile(f).Photo().Name("cat.jpg").Caption("A cat!")
|
|
|
|
c.Send(photo)
|
|
|
|
})),
|
|
|
|
tg.NewCommand("document", "sends a sample text document").
|
|
|
|
WithAction(tg.Func(func(c tg.Context) {
|
|
|
|
f, err := os.Open("media/hello.txt")
|
|
|
|
if err != nil {
|
|
|
|
c.Sendf("err: %s", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
defer f.Close()
|
|
|
|
doc := tg.NewFile(f).Document().Name("hello.txt").Caption("The document")
|
|
|
|
c.Send(doc)
|
|
|
|
})),
|
|
|
|
tg.NewCommand("botname", "get the bot name").
|
|
|
|
WithAction(tg.Func(func(c tg.Context) {
|
|
|
|
bd := c.Bot().Data().(*BotData)
|
|
|
|
c.Sendf("My name is %q", bd.Name)
|
|
|
|
})),
|
|
|
|
tg.NewCommand("history", "print go history").
|
|
|
|
WithAction(tg.Func(func(c tg.Context) {
|
|
|
|
c.Sendf("%q", c.PathHistory())
|
|
|
|
})),
|
|
|
|
tg.NewCommand(
|
|
|
|
"washington",
|
|
|
|
"send location of the Washington",
|
|
|
|
).WithAction(tg.Func(func(c tg.Context) {
|
|
|
|
c.Sendf("Washington location")
|
|
|
|
c.Send(
|
|
|
|
tg.Messagef("").Location(
|
|
|
|
47.751076, -120.740135,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
})),
|
|
|
|
}
|