diff options
author | Trumeet <yuuta@yuuta.moe> | 2022-04-09 18:03:59 -0700 |
---|---|---|
committer | Trumeet <yuuta@yuuta.moe> | 2022-04-09 18:03:59 -0700 |
commit | c03e43f9bc38133f88fb93078e634b105e4a0600 (patch) | |
tree | 1c921d1ddfda5a0f73866c66ced8a94dcd126845 | |
parent | 22f6aeabe8a366cdbce96d419d8c1588e377587f (diff) | |
download | ksyxbot-c03e43f9bc38133f88fb93078e634b105e4a0600.tar ksyxbot-c03e43f9bc38133f88fb93078e634b105e4a0600.tar.gz ksyxbot-c03e43f9bc38133f88fb93078e634b105e4a0600.tar.bz2 ksyxbot-c03e43f9bc38133f88fb93078e634b105e4a0600.zip |
Support photo captions
-rw-r--r-- | store.c | 23 |
1 files changed, 18 insertions, 5 deletions
@@ -108,9 +108,6 @@ static bool filter(struct TdMessage *msg) { } } - if (msg->content_->ID != CODE_MessageText) { - return false; - } return true; } @@ -121,8 +118,24 @@ void store(struct TdMessage *msg, void (*cb)(bool)) { cb(false); return; } - struct TdMessageText *text = (struct TdMessageText *) msg->content_; - const char *t = text->text_->text_; + char *t; + switch (msg->content_->ID) { + case CODE_MessageText: { + struct TdMessageText *text = (struct TdMessageText *) msg->content_; + t = text->text_->text_; + break; + } + case CODE_MessagePhoto: { + struct TdMessagePhoto *photo = (struct TdMessagePhoto *) msg->content_; + if (!photo->caption_ || !photo->caption_->text_) goto f; + t = photo->caption_->text_; + break; + } + default: { + goto f; + } + } + assert(t); struct say *s; if (!(s = malloc(sizeof(struct say)))) { LOGEV("Cannot allocate memory: %s.", strerror(errno)); |