Skip to content

oyehiazarian/exchange-telegramBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

exchange-bot

A small Java Spring Boot Telegram bot that fetches official exchange rates from the Central Bank of Russia (CBR) and shows basic weather information using a public weather API. The project is minimal and intended for development or small demos.

What it does

  • Fetches USD and EUR official rates from the CBR XML feed and returns them on /usd and /eur commands.
  • Provides a simple /weather command: the bot asks for a city name and returns the current temperature (°C) from WeatherAPI.
  • Runs as a Telegram bot using the telegrambots library and OkHttp for HTTP calls.

Key files / classes

  • src/main/java/de/oyehiazarian/exchange_bot/ExchangeBotApplication.java — Spring Boot entry point.
  • src/main/java/de/oyehiazarian/exchange_bot/bot/ExchangeRatesBot.java — Telegram bot with commands (/start, /help, /usd, /eur, /weather).
  • src/main/java/de/oyehiazarian/exchange_bot/client/CbrClient.java — HTTP client using OkHttp to get CBR XML and weather JSON.
  • src/main/java/de/oyehiazarian/exchange_bot/service/impl/ExchangeRatesServiceImpl.java — parses CBR XML to extract rates.
  • src/main/java/de/oyehiazarian/exchange_bot/service/impl/WeatherServiceImpl.java — parses weather JSON to get temperature.

Configuration The project reads a few properties from src/main/resources/application.properties:

  • bot.token — Telegram bot token (currently present in the file; remove before sharing publicly).
  • cbr.currency.rates.xml.url — CBR XML URL (default: http://www.cbr.ru/scripts/XML_daily.asp).
  • api.key — WeatherAPI key (currently present in the file; keep secrets out of the repo).

Quick start

  1. Requirements: Java 21, Maven 3.6+, Internet access.
  2. Build:
mvn clean package -DskipTests
  1. Run:
java -jar target/exchange-bot-0.0.1-SNAPSHOT.jar

Or run with Maven during development:

mvn spring-boot:run

Notes and precautions

  • The repository currently contains secrets (Telegram token and API key) in application.properties. Remove or replace them and use environment variables or an external config for production.
  • Use the bot in test mode (or with a test Telegram bot) before using it in production.
  • The bot username returned by the code is exchange_money001bot (see ExchangeRatesBot#getBotUsername).

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages