test /say
This commit is contained in:
		
							parent
							
								
									bb1a7d0062
								
							
						
					
					
						commit
						40a0b5e800
					
				
							
								
								
									
										22
									
								
								bot.go
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								bot.go
									
									
									
									
									
								
							@ -72,6 +72,7 @@ func (b *Bot) BotHandlers() {
 | 
				
			|||||||
	b.bot.Handle("/give", botGive)
 | 
						b.bot.Handle("/give", botGive)
 | 
				
			||||||
	b.bot.Handle("/take", botTake)
 | 
						b.bot.Handle("/take", botTake)
 | 
				
			||||||
	b.bot.Handle("/passwd", botPasswd)
 | 
						b.bot.Handle("/passwd", botPasswd)
 | 
				
			||||||
 | 
						b.bot.Handle("/say", botSay)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	b.bot.Handle(tb.OnPhoto, botPhoto)
 | 
						b.bot.Handle(tb.OnPhoto, botPhoto)
 | 
				
			||||||
	b.bot.Handle(tb.OnChannelPost, botChannelPost)
 | 
						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))
 | 
						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) {
 | 
					func botPasswd(m *tb.Message) {
 | 
				
			||||||
	cc, ok := cfg.Clients[m.Sender.ID]
 | 
						cc, ok := cfg.Clients[m.Sender.ID]
 | 
				
			||||||
	if !ok {
 | 
						if !ok {
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										41
									
								
								packet.go
									
									
									
									
									
								
							
							
						
						
									
										41
									
								
								packet.go
									
									
									
									
									
								
							@ -63,6 +63,24 @@ const (
 | 
				
			|||||||
	AdminFrequencyQuarterly = 0x10
 | 
						AdminFrequencyQuarterly = 0x10
 | 
				
			||||||
	AdminFrequencyAnnually  = 0x20
 | 
						AdminFrequencyAnnually  = 0x20
 | 
				
			||||||
	AdminFrequencyAutomatic = 0x40
 | 
						AdminFrequencyAutomatic = 0x40
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						AdminNetworkActionJoin             = 0
 | 
				
			||||||
 | 
						AdminNetworkActionLeave            = 1
 | 
				
			||||||
 | 
						AdminNetworkActionServerMessage    = 2
 | 
				
			||||||
 | 
						AdminNetworkActionChat             = 3
 | 
				
			||||||
 | 
						AdminNetworkActionChatCompany      = 4
 | 
				
			||||||
 | 
						AdminNetworkActionChatClient       = 5
 | 
				
			||||||
 | 
						AdminNetworkActionGiveMoney        = 6
 | 
				
			||||||
 | 
						AdminNetworkActionNameChange       = 7
 | 
				
			||||||
 | 
						AdminNetworkActionCompanySpectator = 8
 | 
				
			||||||
 | 
						AdminNetworkActionCompanyJoin      = 9
 | 
				
			||||||
 | 
						AdminNetworkActionCompanyNew       = 10
 | 
				
			||||||
 | 
						AdminNetworkActionKicked           = 11
 | 
				
			||||||
 | 
						AdminNetworkActionExternalChat     = 12
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						AdminDestinationTypeBroadcast = 0
 | 
				
			||||||
 | 
						AdminDestinationTypeTeam      = 1
 | 
				
			||||||
 | 
						AdminDestinationTypeClient    = 2
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type Packet struct {
 | 
					type Packet struct {
 | 
				
			||||||
@ -82,6 +100,14 @@ type PacketAdminRCon struct {
 | 
				
			|||||||
	Command string
 | 
						Command string
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type PacketAdminChat struct {
 | 
				
			||||||
 | 
						Packet
 | 
				
			||||||
 | 
						ActionType      uint8
 | 
				
			||||||
 | 
						DestinationType uint8
 | 
				
			||||||
 | 
						DestinationID   uint32
 | 
				
			||||||
 | 
						Message         string
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type PacketServerProtocol struct {
 | 
					type PacketServerProtocol struct {
 | 
				
			||||||
	Packet
 | 
						Packet
 | 
				
			||||||
	ProtocolVersion    uint8
 | 
						ProtocolVersion    uint8
 | 
				
			||||||
@ -239,6 +265,21 @@ func (p *PacketAdminRCon) Bytes() []byte {
 | 
				
			|||||||
	return buf.Bytes()
 | 
						return buf.Bytes()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (p *PacketAdminChat) Bytes() []byte {
 | 
				
			||||||
 | 
						buf := new(bytes.Buffer)
 | 
				
			||||||
 | 
						p.PLength = uint16(len(p.Message) + 10)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						binary.Write(buf, binary.LittleEndian, p.PLength)
 | 
				
			||||||
 | 
						binary.Write(buf, binary.LittleEndian, p.ActionType)
 | 
				
			||||||
 | 
						binary.Write(buf, binary.LittleEndian, p.DestinationType)
 | 
				
			||||||
 | 
						binary.Write(buf, binary.LittleEndian, p.DestinationID)
 | 
				
			||||||
 | 
						buf.WriteString(p.Message)
 | 
				
			||||||
 | 
						buf.WriteByte(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return buf.Bytes()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (p *PacketAdminUpdateFrequency) Bytes() []byte {
 | 
					func (p *PacketAdminUpdateFrequency) Bytes() []byte {
 | 
				
			||||||
	buf := new(bytes.Buffer)
 | 
						buf := new(bytes.Buffer)
 | 
				
			||||||
	p.PLength = 7
 | 
						p.PLength = 7
 | 
				
			||||||
 | 
				
			|||||||
@ -1,6 +1,6 @@
 | 
				
			|||||||
// Code generated by version.sh (@generated) DO NOT EDIT.
 | 
					// Code generated by version.sh (@generated) DO NOT EDIT.
 | 
				
			||||||
package main
 | 
					package main
 | 
				
			||||||
var githash = "aa2a229"
 | 
					var githash = "bb1a7d0"
 | 
				
			||||||
var buildstamp = "2021-11-13_02:45:07"
 | 
					var buildstamp = "2021-11-13_05:44:46"
 | 
				
			||||||
var commits = "190"
 | 
					var commits = "193"
 | 
				
			||||||
var version = "aa2a229-b190 - 2021-11-13_02:45:07"
 | 
					var version = "bb1a7d0-b193 - 2021-11-13_05:44:46"
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user