Telegram bot for easy currency conversion with extensive features.
See @inintobot
The implementation consists of the following components:
buildSrc- project with Gradle build-scriptscommon- common utilities and interfaces, also objects containing list of available currencies and rate apis.fetch-rates- function which downloads the latest rates and populates the designated store (supposed to be running on schedule)
See classorg.mksn.inintobot.rates.FetchRequestfor input object parametersexchange-rates- main module which containing bot logicmigrate-settings- one-time function which designated to migrate existing settings from Postgres SQL.
See classorg.mksn.inintobot.migrate.MigrateInputfor input object parameters To deploy:gcloud functions deploy inintobot-exchange-rates \ --entry-point=org.mksn.inintobot.gcp.function.Function \ --memory=512MB --runtime=java11 --trigger-http --source=build/libs \ --region=europe-central2componud-server- project which connectsfetch-ratesandexchange-ratesfunctions into a single executable server Require envs from bothfetch-ratesandexchange-ratesprojects to be setplatform-gcp- set of platform-related projects (or just configurations) to deploy the bot on GCP and save data into Firestoreapp-engine- GCP version ofcompund-serverproject. Fillapp.yamlwith required envs.function- adapter implementation between common function interface and GCP cloud functions interfacestore- GCP Firestore implementation of common storage interfacesfunction-exchange-rates- GCP version ofexchange-ratesproject. To deploy:gcloud functions deploy inintobot-exchange-rates \ --entry-point=org.mksn.inintobot.gcp.function.Function \ --memory=512MB --runtime=java11 --trigger-http --source=build/libs \ --region=europe-central2 --min-instances=1 \ --set-env-vars BOT_TOKEN=<bot token>,BOT_USERNAME=<bot username>,CREATOR_ID=<id of admin>
function-fetch-rates- GCP version ofexchange-ratesproject. To deploy:gcloud functions deploy inintobot-fetch-rates \ --entry-point=org.mksn.inintobot.gcp.function.Function \ --memory=512MB --runtime=java11 --trigger-http --source=build/libs \ --region=europe-central2 \ --set-env-vars FIXER_ACCESS_KEY=<token>,FOREX_ACCESS_KEY=<token>,OPENEXCHANGERATES_ACCESS_KEY=<token>,TRADERMADE_ACCESS_KEY=<token>
function-migrate-settings- GCP version ofmigrate-settingsproject. To deploy:gcloud functions deploy inintobot-migrate-settings \ --entry-point=org.mksn.inintobot.gcp.function.Function \ --memory=512MB --runtime=java11 --trigger-http --source=build/libs \ --region=europe-central2
To set webhook:
curl -X "POST" "https://api.telegram.org/bot<token>/setWebhook" \
-d '{"drop_pending_updates": true, "url": "<app-link>", "allowed_updates": ["edited_message", "inline_query", "message", "chosen_inline_result", "callback_query"]}' \
-H 'Content-Type: application/json; charset=utf-8'