Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

send_game needs chat_id by ChatId not u32 #1066

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

strongtu
Copy link

async fn message_handler(
    bot: Bot,
    msg: Message,
    me: Me,
) -> Result<(), Box<dyn Error + Send + Sync>> {
    println!("msg: {:?}", msg.text().unwrap_or("default"));

    let text = msg.text().unwrap_or("default");
    match text {
        "/game" => {
            bot.send_game( msg.chat.id.0,  "game_name")
                .reply_markup(make_game_message()).await?;
        }
        _ => {
            bot.send_message(msg.chat.id, text).await?;
        }
    }

    Ok(())
}

This will cause a compilation error because the chat_id type declared by send_game is u32, but the type of msg.chat.id is i64
and should change send_message(chat_id : u32) to send_message(chat_id : i64) to make it work

here is the issues detail #1065

@teloxidebot
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @WaffleLapkin (or someone else) soon.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @teloxidebot author: the review is finished, PR author should check the comments and take action accordingly
  • @teloxidebot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@teloxidebot teloxidebot added A-requester Area: requester trait, bot adaptors A-requests Area: representation of telegram bot API requests/methods C-core crate: teloxide-core S-waiting-on-review Status: Awaiting review from the assignee labels May 17, 2024
@syrtcevvi
Copy link
Contributor

Hi!

Thank you for your pull request.

Our Requester trait is created by codegen, so I'm not sure that that change will be enough. I think, it worth to change the schema.ron in teloxide -core. So, the send_game will accept smth similar to send_message

Copy link
Member

@WaffleLapkin WaffleLapkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for noticing the mistake! We do have a dedicated ChatId type though, so you should use that.

@teloxidebot teloxidebot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author and removed S-waiting-on-review Status: Awaiting review from the assignee labels May 17, 2024
@@ -4031,7 +4031,7 @@ Schema(
params: [
Param(
name: "chat_id",
ty: u32,
ty: i64,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ty: i64,
ty: RawTy("ChatId"),

@strongtu strongtu changed the title send_game needs chat_id by i64 not u32 send_game needs chat_id by ChatId not u32 May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-requester Area: requester trait, bot adaptors A-requests Area: representation of telegram bot API requests/methods C-core crate: teloxide-core S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants