package main
import (
"bytes"
"encoding/json"
"net/http"
"os"
)
const apiUrl = "https://api.telegram.org/bot%s/sendMessage"
func main() {
botToken := os.Getenv("TELEGRAM_BOT_TOKEN")
chatID := "your_chat_id"
message := "Hello, this is a message from your Go bot!"
sendMessage(botToken, chatID, message)
}
func sendMessage(botToken, chatID, message string) {
url := fmt.Sprintf(apiUrl, botToken)
payload := map[string]interface{}{
"chat_id": chatID,
"text": message,
}
payloadBytes, _ := json.Marshal(payload)
_, err := http.Post(url, "application/json", bytes.NewBuffer(payloadBytes))
if err != nil {
log.Fatalf("Error sending message: %v", err)
}
}
How do I avoid rehashing overhead with std::set in multithreaded code?
How do I find elements with custom comparators with std::set for embedded targets?
How do I erase elements while iterating with std::set for embedded targets?
How do I provide stable iteration order with std::unordered_map for large datasets?
How do I reserve capacity ahead of time with std::unordered_map for large datasets?
How do I erase elements while iterating with std::unordered_map in multithreaded code?
How do I provide stable iteration order with std::map for embedded targets?
How do I provide stable iteration order with std::map in multithreaded code?
How do I avoid rehashing overhead with std::map in performance-sensitive code?
How do I merge two containers efficiently with std::map for embedded targets?