Fix crashes in commands due to not found contacts
This commit is contained in:
parent
0b1cbda1cc
commit
5dd60450c2
|
@ -504,6 +504,9 @@ func (c *Client) ProcessTransportCommand(cmdline string, resource string) string
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err.Error()
|
return err.Error()
|
||||||
}
|
}
|
||||||
|
if contact == nil {
|
||||||
|
return "Contact not found"
|
||||||
|
}
|
||||||
|
|
||||||
text := rawCmdArguments(cmdline, 1)
|
text := rawCmdArguments(cmdline, 1)
|
||||||
_, err = c.client.ReportChat(&client.ReportChatRequest{
|
_, err = c.client.ReportChat(&client.ReportChatRequest{
|
||||||
|
@ -812,6 +815,9 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err.Error(), true
|
return err.Error(), true
|
||||||
}
|
}
|
||||||
|
if contact == nil {
|
||||||
|
return "Contact not found", true
|
||||||
|
}
|
||||||
|
|
||||||
_, err = c.client.AddChatMember(&client.AddChatMemberRequest{
|
_, err = c.client.AddChatMember(&client.AddChatMemberRequest{
|
||||||
ChatId: chatID,
|
ChatId: chatID,
|
||||||
|
@ -836,6 +842,9 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err.Error(), true
|
return err.Error(), true
|
||||||
}
|
}
|
||||||
|
if contact == nil {
|
||||||
|
return "Contact not found", true
|
||||||
|
}
|
||||||
|
|
||||||
_, err = c.client.SetChatMemberStatus(&client.SetChatMemberStatusRequest{
|
_, err = c.client.SetChatMemberStatus(&client.SetChatMemberStatusRequest{
|
||||||
ChatId: chatID,
|
ChatId: chatID,
|
||||||
|
@ -851,6 +860,9 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err.Error(), true
|
return err.Error(), true
|
||||||
}
|
}
|
||||||
|
if contact == nil {
|
||||||
|
return "Contact not found", true
|
||||||
|
}
|
||||||
|
|
||||||
var hours int64
|
var hours int64
|
||||||
if len(args) > 1 {
|
if len(args) > 1 {
|
||||||
|
@ -878,6 +890,9 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err.Error(), true
|
return err.Error(), true
|
||||||
}
|
}
|
||||||
|
if contact == nil {
|
||||||
|
return "Contact not found", true
|
||||||
|
}
|
||||||
|
|
||||||
_, err = c.client.SetChatMemberStatus(&client.SetChatMemberStatusRequest{
|
_, err = c.client.SetChatMemberStatus(&client.SetChatMemberStatusRequest{
|
||||||
ChatId: chatID,
|
ChatId: chatID,
|
||||||
|
@ -897,6 +912,9 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err.Error(), true
|
return err.Error(), true
|
||||||
}
|
}
|
||||||
|
if contact == nil {
|
||||||
|
return "Contact not found", true
|
||||||
|
}
|
||||||
|
|
||||||
var hours int64
|
var hours int64
|
||||||
if len(args) > 1 {
|
if len(args) > 1 {
|
||||||
|
@ -922,6 +940,9 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err.Error(), true
|
return err.Error(), true
|
||||||
}
|
}
|
||||||
|
if contact == nil {
|
||||||
|
return "Contact not found", true
|
||||||
|
}
|
||||||
|
|
||||||
_, err = c.client.SetChatMemberStatus(&client.SetChatMemberStatusRequest{
|
_, err = c.client.SetChatMemberStatus(&client.SetChatMemberStatusRequest{
|
||||||
ChatId: chatID,
|
ChatId: chatID,
|
||||||
|
@ -937,6 +958,9 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err.Error(), true
|
return err.Error(), true
|
||||||
}
|
}
|
||||||
|
if contact == nil {
|
||||||
|
return "Contact not found", true
|
||||||
|
}
|
||||||
|
|
||||||
// clone the permissions
|
// clone the permissions
|
||||||
status := client.ChatMemberStatusAdministrator{
|
status := client.ChatMemberStatusAdministrator{
|
||||||
|
@ -1006,6 +1030,9 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err.Error(), true
|
return err.Error(), true
|
||||||
}
|
}
|
||||||
|
if chat == nil {
|
||||||
|
return "Chat not found", true
|
||||||
|
}
|
||||||
|
|
||||||
chatType := chat.Type.ChatTypeType()
|
chatType := chat.Type.ChatTypeType()
|
||||||
if chatType == client.TypeChatTypeSecret {
|
if chatType == client.TypeChatTypeSecret {
|
||||||
|
|
Loading…
Reference in a new issue