Fix crashes in commands due to not found contacts

adhoc
Bohdan Horbeshko 2 months ago
parent 0b1cbda1cc
commit 5dd60450c2

@ -504,6 +504,9 @@ func (c *Client) ProcessTransportCommand(cmdline string, resource string) string
if err != nil {
return err.Error()
}
if contact == nil {
return "Contact not found"
}
text := rawCmdArguments(cmdline, 1)
_, err = c.client.ReportChat(&client.ReportChatRequest{
@ -812,6 +815,9 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
if err != nil {
return err.Error(), true
}
if contact == nil {
return "Contact not found", true
}
_, err = c.client.AddChatMember(&client.AddChatMemberRequest{
ChatId: chatID,
@ -836,6 +842,9 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
if err != nil {
return err.Error(), true
}
if contact == nil {
return "Contact not found", true
}
_, err = c.client.SetChatMemberStatus(&client.SetChatMemberStatusRequest{
ChatId: chatID,
@ -851,6 +860,9 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
if err != nil {
return err.Error(), true
}
if contact == nil {
return "Contact not found", true
}
var hours int64
if len(args) > 1 {
@ -878,6 +890,9 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
if err != nil {
return err.Error(), true
}
if contact == nil {
return "Contact not found", true
}
_, err = c.client.SetChatMemberStatus(&client.SetChatMemberStatusRequest{
ChatId: chatID,
@ -897,6 +912,9 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
if err != nil {
return err.Error(), true
}
if contact == nil {
return "Contact not found", true
}
var hours int64
if len(args) > 1 {
@ -922,6 +940,9 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
if err != nil {
return err.Error(), true
}
if contact == nil {
return "Contact not found", true
}
_, err = c.client.SetChatMemberStatus(&client.SetChatMemberStatusRequest{
ChatId: chatID,
@ -937,6 +958,9 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
if err != nil {
return err.Error(), true
}
if contact == nil {
return "Contact not found", true
}
// clone the permissions
status := client.ChatMemberStatusAdministrator{
@ -1006,6 +1030,9 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
if err != nil {
return err.Error(), true
}
if chat == nil {
return "Chat not found", true
}
chatType := chat.Type.ChatTypeType()
if chatType == client.TypeChatTypeSecret {

Loading…
Cancel
Save