test /say
This commit is contained in:
22
bot.go
22
bot.go
@@ -72,6 +72,7 @@ func (b *Bot) BotHandlers() {
|
||||
b.bot.Handle("/give", botGive)
|
||||
b.bot.Handle("/take", botTake)
|
||||
b.bot.Handle("/passwd", botPasswd)
|
||||
b.bot.Handle("/say", botSay)
|
||||
|
||||
b.bot.Handle(tb.OnPhoto, botPhoto)
|
||||
b.bot.Handle(tb.OnChannelPost, botChannelPost)
|
||||
@@ -299,6 +300,27 @@ func botTake(m *tb.Message) {
|
||||
bot.SendChat(m.Chat.ID, fmt.Sprintf("@%s now has %s left.", uStr, cc.TimeLeft))
|
||||
}
|
||||
|
||||
func botSay(m *tb.Message) {
|
||||
r := regexp.MustCompile("^\\/say( )+(?P<Message>.+)$")
|
||||
if !r.MatchString(m.Text) {
|
||||
bot.SendChat(m.Chat.ID, "No message provided")
|
||||
return
|
||||
}
|
||||
|
||||
msg := r.ReplaceAllString(m.Text, "${Message}")
|
||||
|
||||
px := PacketAdminChat{
|
||||
Packet: Packet{PType: AdminPacketAdminChat},
|
||||
ActionType: AdminNetworkActionChat,
|
||||
DestinationType: AdminDestinationTypeBroadcast,
|
||||
DestinationID: 0,
|
||||
Message: msg,
|
||||
}
|
||||
srv.Send(px.Bytes())
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func botPasswd(m *tb.Message) {
|
||||
cc, ok := cfg.Clients[m.Sender.ID]
|
||||
if !ok {
|
||||
|
||||
Reference in New Issue
Block a user