Fix a crash on big emojis
This commit is contained in:
parent
105f5017c3
commit
2a1c09fcdd
|
@ -154,6 +154,7 @@ func (c *Client) interactor() {
|
||||||
for {
|
for {
|
||||||
state, ok := <-c.authorizer.State
|
state, ok := <-c.authorizer.State
|
||||||
if !ok {
|
if !ok {
|
||||||
|
gateway.SendMessage(c.jid, "", "Interactor is disconnected", c.xmpp)
|
||||||
log.Error("Interactor is disconnected")
|
log.Error("Interactor is disconnected")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -247,11 +247,13 @@ func (c *Client) formatMessage(chatID int64, messageID int64, preview bool, mess
|
||||||
}
|
}
|
||||||
|
|
||||||
var text string
|
var text string
|
||||||
switch message.Content.MessageContentType() {
|
if message.Content != nil {
|
||||||
case client.TypeMessageText:
|
switch message.Content.MessageContentType() {
|
||||||
messageText, _ := message.Content.(*client.MessageText)
|
case client.TypeMessageText:
|
||||||
text = messageText.Text.Text
|
messageText, _ := message.Content.(*client.MessageText)
|
||||||
// TODO: handle other message types with labels (not supported in Zhabogram!)
|
text = messageText.Text.Text
|
||||||
|
// TODO: handle other message types with labels (not supported in Zhabogram!)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if text != "" {
|
if text != "" {
|
||||||
if !preview {
|
if !preview {
|
||||||
|
@ -285,6 +287,11 @@ func (c *Client) formatContent(file *client.File, filename string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) messageToText(message *client.Message) string {
|
func (c *Client) messageToText(message *client.Message) string {
|
||||||
|
if message.Content == nil {
|
||||||
|
log.Warnf("Unknown message (big emoji?): %#v", message)
|
||||||
|
return "<BIG EMOJI>"
|
||||||
|
}
|
||||||
|
|
||||||
markupFunction := formatter.EntityToMarkdown
|
markupFunction := formatter.EntityToMarkdown
|
||||||
switch message.Content.MessageContentType() {
|
switch message.Content.MessageContentType() {
|
||||||
case client.TypeMessageSticker:
|
case client.TypeMessageSticker:
|
||||||
|
@ -378,6 +385,10 @@ func (c *Client) messageToText(message *client.Message) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) contentToFilename(content client.MessageContent) (*client.File, string) {
|
func (c *Client) contentToFilename(content client.MessageContent) (*client.File, string) {
|
||||||
|
if content == nil {
|
||||||
|
return nil, ""
|
||||||
|
}
|
||||||
|
|
||||||
switch content.MessageContentType() {
|
switch content.MessageContentType() {
|
||||||
case client.TypeMessageSticker:
|
case client.TypeMessageSticker:
|
||||||
sticker, _ := content.(*client.MessageSticker)
|
sticker, _ := content.(*client.MessageSticker)
|
||||||
|
|
Loading…
Reference in a new issue