Skip to content

Can't seem to figure out TBLocation? #154

@dannyz2

Description

@dannyz2

I have the following code that checks for a valid msg.chat_id, and reports to me the unauthorized chat_id, and supposedly, their location. All I ever see for location, is "User is located @ -0.000000 , 0.000000" What am I doing wrong?

    if (myBot.getNewMessage(msg))           // if there is an incoming message...
    {
        if (ALLOWED_CHAT_IDS.find(msg.chatId) == ALLOWED_CHAT_IDS.end()) 
        {
            test = msg.chatId;
            float lat = msg.location.latitude;
            float lon = msg.location.longitude;
            myBot.sendMessage(msg, "Un-Authorized User!");
            Serial.print("User ");
            Serial.print(test);
            Serial.println(" is attempting to access Bot!");
            Serial.print("Chat_ID is: ");
            Serial.println(test);
            snprintf(welcome_msg, 384, "ChatID %lld is Attempting to access Bot!\n User is located @ %f , %f \n", test, lat, lon);
            myBot.sendTo(userid, welcome_msg); // Send a message to me about un-authorized user

            return;
        }

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