GithubHelp home page GithubHelp logo

kohrongying / bete Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yi-jiayu/bete

0.0 1.0 0.0 206 KB

Bus Eta Bot's secret identity

Go 96.47% Dockerfile 0.15% Shell 0.28% PLpgSQL 1.06% Python 0.58% HTML 1.26% Makefile 0.19%

bete's Introduction

Bete

Bus Eta Bot's secret identity

Developing

Running tests

  • The DATABASE_URL should be set appropriately.
  • For a local database: env DATABASE_URL='postgres://localhost/bete_test?sslmode=disable' go test ./...

Testing with a real bot

  • Create a new bot with @BotFather on Telegram and obtain a bot token.
  • Request for API access to LTA DataMall and obtain an account key.
  • Build the server binary: make
  • Run the server with the DATAMALL_ACCOUNT_KEY, TELEGRAM_BOT_TOKEN and DATABASE_URL environment variables:
env DATABASE_URL='postgres://localhost/bete_test?sslmode=disable' DATAMALL_ACCOUNT_KEY='xxx' TELEGRAM_BOT_TOKEN='xxx' bin/bete
  • Start a separate ngrok process to expose the server: ngrok http 8080
  • Set the bot webhook to the public ngrok URL (use the HTTPS one). Note that the path should be /telegram/updates
curl https://api.telegram.org/bot$bot_token/setWebhook?url=https://xxx/telegram/updates
  • Find your bot on Telegram and chat with it, you should see HTTP requests logged by ngrok and bete.
  • For convenience, the Makefile contains a start target to build and run the server, and a webhook target to automatically set the webhook. These both need the appropriate environment variables to be set.

Generating mocks

  • Install mockgen binary to bin/mockgen: GOBIN=$PWD/bin go get github.com/golang/mock/mockgen
  • Generate mocks: go generate

Database migrations

  • Install migrate binary to bin/migrate: GOBIN=$PWD/bin go get -tags postgres github.com/golang-migrate/migrate/v4/cmd/migrate
  • The postgres tag is needed to run migrations against Postgres.
  • To generate new migrations: bin/migrate create -dir migrations -ext sql MIGRATION_NAME
  • To run migrations: bin/migrate -path migrations -database 'postgres://localhost/bete_test?sslmode=disable' up

bete's People

Contributors

yi-jiayu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.