Skip to content

Here is something wrong in InlineQueryResult type. #345

@okman334

Description

@okman334

look at the code is InlineQueryResult.cpp

const std::string InlineQueryResultCachedAudio::TYPE = "audio";
const std::string InlineQueryResultCachedDocument::TYPE = "document";
const std::string InlineQueryResultCachedGif::TYPE = "gif";
const std::string InlineQueryResultCachedMpeg4Gif::TYPE = "mpeg4_gif";
const std::string InlineQueryResultCachedPhoto::TYPE = "photo";
const std::string InlineQueryResultCachedSticker::TYPE = "sticker";
const std::string InlineQueryResultCachedVideo::TYPE = "video";
const std::string InlineQueryResultCachedVoice::TYPE = "voice";

const std::string InlineQueryResultArticle::TYPE = "article";
const std::string InlineQueryResultAudio::TYPE = "audio";
const std::string InlineQueryResultContact::TYPE = "contact";
const std::string InlineQueryResultGame::TYPE = "game";
const std::string InlineQueryResultDocument::TYPE = "document";
const std::string InlineQueryResultGif::TYPE = "gif";
const std::string InlineQueryResultLocation::TYPE = "location";
const std::string InlineQueryResultMpeg4Gif::TYPE = "mpeg4_gif";
const std::string InlineQueryResultPhoto::TYPE = "photo";
const std::string InlineQueryResultVenue::TYPE = "venue";
const std::string InlineQueryResultVideo::TYPE = "video";
const std::string InlineQueryResultVoice::TYPE = "voice";

InlineQueryResultPhoto and InlineQueryResultCachedPhoto is the same type.
and then in TgTypeParser.cpp, the type InlineQueryResultPhoto only enters parseInlineQueryResultCachedPhoto, resulting in an error

std::string TgTypeParser::parseInlineQueryResult(const InlineQueryResult::Ptr& object) const {
    if (!object) {
        return "";
    }
    std::string result;
    result += '{';
    appendToJson(result, "type", object->type);
    appendToJson(result, "id", object->id);
    appendToJson(result, "reply_markup", parseInlineKeyboardMarkup(object->replyMarkup));

    if (object->type == InlineQueryResultCachedAudio::TYPE) {
        result += parseInlineQueryResultCachedAudio(std::static_pointer_cast<InlineQueryResultCachedAudio>(object));
    } else if (object->type == InlineQueryResultCachedDocument::TYPE) {
        result += parseInlineQueryResultCachedDocument(std::static_pointer_cast<InlineQueryResultCachedDocument>(object));
    } else if (object->type == InlineQueryResultCachedGif::TYPE) {
        result += parseInlineQueryResultCachedGif(std::static_pointer_cast<InlineQueryResultCachedGif>(object));
    } else if (object->type == InlineQueryResultCachedMpeg4Gif::TYPE) {
        result += parseInlineQueryResultCachedMpeg4Gif(std::static_pointer_cast<InlineQueryResultCachedMpeg4Gif>(object));
    } /*else if (object->type == InlineQueryResultCachedPhoto::TYPE) {
        result += parseInlineQueryResultCachedPhoto(std::static_pointer_cast<InlineQueryResultCachedPhoto>(object));
    }*/ else if (object->type == InlineQueryResultCachedSticker::TYPE) {
        result += parseInlineQueryResultCachedSticker(std::static_pointer_cast<InlineQueryResultCachedSticker>(object));
    } else if (object->type == InlineQueryResultCachedVideo::TYPE) {
        result += parseInlineQueryResultCachedVideo(std::static_pointer_cast<InlineQueryResultCachedVideo>(object));
    } else if (object->type == InlineQueryResultCachedVoice::TYPE) {
        result += parseInlineQueryResultCachedVoice(std::static_pointer_cast<InlineQueryResultCachedVoice>(object));
    } else if (object->type == InlineQueryResultArticle::TYPE) {
        result += parseInlineQueryResultArticle(std::static_pointer_cast<InlineQueryResultArticle>(object));
    } else if (object->type == InlineQueryResultAudio::TYPE) {
        result += parseInlineQueryResultAudio(std::static_pointer_cast<InlineQueryResultAudio>(object));
    } else if (object->type == InlineQueryResultContact::TYPE) {
        result += parseInlineQueryResultContact(std::static_pointer_cast<InlineQueryResultContact>(object));
    } else if (object->type == InlineQueryResultGame::TYPE) {
        result += parseInlineQueryResultGame(std::static_pointer_cast<InlineQueryResultGame>(object));
    } else if (object->type == InlineQueryResultDocument::TYPE) {
        result += parseInlineQueryResultDocument(std::static_pointer_cast<InlineQueryResultDocument>(object));
    } else if (object->type == InlineQueryResultLocation::TYPE) {
        result += parseInlineQueryResultLocation(std::static_pointer_cast<InlineQueryResultLocation>(object));
    } else if (object->type == InlineQueryResultVenue::TYPE) {
        result += parseInlineQueryResultVenue(std::static_pointer_cast<InlineQueryResultVenue>(object));
    } else if (object->type == InlineQueryResultVoice::TYPE) {
        result += parseInlineQueryResultVoice(std::static_pointer_cast<InlineQueryResultVoice>(object));
    } else if (object->type == InlineQueryResultPhoto::TYPE) {
        result += parseInlineQueryResultPhoto(std::static_pointer_cast<InlineQueryResultPhoto>(object));
    } else if (object->type == InlineQueryResultGif::TYPE) {
        result += parseInlineQueryResultGif(std::static_pointer_cast<InlineQueryResultGif>(object));
    } else if (object->type == InlineQueryResultMpeg4Gif::TYPE) {
        result += parseInlineQueryResultMpeg4Gif(std::static_pointer_cast<InlineQueryResultMpeg4Gif>(object));
    } else if (object->type == InlineQueryResultVideo::TYPE) {
        result += parseInlineQueryResultVideo(std::static_pointer_cast<InlineQueryResultVideo>(object));
    }

    removeLastComma(result);
    result += '}';
    return result;
}

@reo7sp @llnulldisk @Makcal Can you fix it? Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions