shurillu / CTBot

A simple (and easy to use) Arduino Telegram BOT Library for ESP8266/ESP32
MIT License
147 stars 34 forks source link

V3.0.0 question about sending message #86

Closed konig87nikkinakki closed 2 years ago

konig87nikkinakki commented 2 years ago

Hi Shurillu, thank you for your library and sorry for my silly question. i need to write into the same message a text and a variable. This is command: myBot.sendMessage(chatID, "Text"); or: String hello = "Helloooo.\n"; myBot.sendMessage(chatID, hello); it works fine. my question is how can i send into the same message a variable (unsigned long, int...)? Something like that:

unsigned long time=millis() myBot.sendMessage(chatID, "Hi, this is the value of time: [write here time]");

i could write 2 messages but i cannot. i need to have all in 1 same mex. i know it's not an issue of library, it's me not so expert. When i program in C i remember printf("number1 %d \n", 123456); how can i do with your library? Thank you so much

shurillu commented 2 years ago

Hello konig87nikkinakki, for these kind of question, is better to open an issue and not a pull request. Moreover this is not an issue at all hehehe

Anyway, the easiest way is to use the String class. For example,

    String message = "This is a number: " + String(22);
    Serial.println(message);

The output will be: This is a number: 22

You can replace the number 22 with any number variable, the text with others Strings and concatenate it with + like doing sums. Obviously, you can use the message variable as a parameter for the sendMessage() method:

myBot.sendMessage(chatID, message);

Cheers,

Stefano

konig87nikkinakki commented 2 years ago

Thank you sooo much, exactly i didnt want to crate a Issue because it isnt. thank you again, why don t you think about making a big and practice guide for intermediate level in arduino? There are a lot of basics, i mean something upper, it may help and people will pay for it. Something like that you just teach me, bigger and well-written. A lot of intermediate will buy!