Skip to content

ferclager/golang-weather-telegrambot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Golang Weather Telegram Bot

This repository contains the code for building a Weather Telegram Bot using Golang. The bot fetches weather information from the OpenWeatherMap API and sends it to a specified Telegram chat.

Prerequisites

Before you begin, make sure you have the following:

  • Telegram Bot: create a Telegram bot by following the instructions here.

  • Telegram Chat ID: obtain the chat ID from your bot. Refer to this guide for more information.

  • OpenWeatherMap API Token: register on the OpenWeatherMap website to obtain an API token. Visit here to register and get your API token.

  • OpenWeatherMap City ID: find the city ID for your desired location on the OpenWeatherMap website. For example, the city ID for Mexico City is 3530597.

  • Configuration: configure your enviroment (file .env)

		KEY_WEATHER=YOUR_KEY
		TELEGRAM_BOT_TOKEN=YOUR_BOT_TOKEN
		TELEGRAM_CHAT_ID=YOUR_CHAT_ID

Usage

To use the Weather Telegram Bot, follow these steps:

  • Clone the repository:
	git clone https://github.com/your-username/golangWeatherTelegramBot.git
  • Navigate to the project directory:
	cd golang-weather-telegramBot
  • Run the weatherBot.go file with your own information. For example, to get the weather forecast for Mexico City, run the following command:
	go run weatherBot.go -cityName=MexicoCity -request=WF

That's it! The bot will fetch the weather information from the OpenWeatherMap API and send it to the specified Telegram chat.

Feel free to modify the code according to your requirements and enhance the functionality of the bot.

Enjoy using the Weather Telegram Bot!

License

This project is licensed under the MIT License.

About

Building a weather bot in golang using Telegram API

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages