Git Product home page Git Product logo

trafikverket-bot's Introduction

trafikverket-bot

trafikverket-logo

About The Project

A simple Telegram bot that collects information from the Trafikverket Open API about deviations on the Swedish railroad network.

Why?

Why not.

Prerequisites

You need an APIkey from the Trafikverket Open API which can be obtained by creating an account at: https://data.trafikverket.se/oauth2/Account/register

A Telegram bot APIkey is required for the bot to work properly, this can be obtained by creating a bot on Telegram. You also need to find the signed integer representing the channel you wish to send messages to.

Getting Started

To run this program you need at least Go version 1.22. You also need to create a json-config file in config/config.json that should look like this:

{
      "Telegram": {
		"tgAPIkey": "xxx",
		"tgChannel": "xxx"
	},
	"TrafikverketAPIKey": "xxx"
      "County": [0]
}

If you want to filter the output and only send updates for specific counties, add those to the list, thr default is 0, meaning all counties are announced. A list of all counties can be found in the map CountyMap in apipoller.go.

Usage

To keep track of updates it's recommended to use for example crontab to run the program once every fifth minute.

go run trafikverket.go

If you want to specify a location for the config file, start with:

go run trafikverket.go -config-file /path

DEBUG mode

  -config-file string
        Absolute path for config-file (default "./config/config.json")
  -debug
        Turns on debug for telegram
  -stdout
        Turns on stdout rather than sending to telegram
  -telegram-test
        Sends a test message to configured telegram channel

Roadmap

  • Add support for other file location for config-file
  • Fix update function posting updates to ongoing events
  • Fix deletion when ongoing event are cleared
  • Document and clean up code
  • Add function for bulk station lookup function
  • Fix affected stations print
  • Change to html when sent to Telegram for support of embedded images
  • Add county filter in config

trafikverket-bot's People

Contributors

wbergg avatar

Watchers

 avatar Kirill 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.