{"id":22242388,"url":"https://github.com/manzanit0/londibot-prototype","last_synced_at":"2025-03-25T10:40:34.206Z","repository":{"id":127186540,"uuid":"165912120","full_name":"manzanit0/londibot-prototype","owner":"manzanit0","description":"Yet another Telegram bot. But this one reports TFL services.","archived":false,"fork":false,"pushed_at":"2019-03-14T16:26:09.000Z","size":61,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-30T09:41:52.081Z","etag":null,"topics":["clojure","slack-bot","telegram-bot","tfl-api"],"latest_commit_sha":null,"homepage":null,"language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/manzanit0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-15T19:39:22.000Z","updated_at":"2019-05-03T14:23:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"308f2015-598d-448a-919a-b9081af68066","html_url":"https://github.com/manzanit0/londibot-prototype","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manzanit0%2Flondibot-prototype","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manzanit0%2Flondibot-prototype/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manzanit0%2Flondibot-prototype/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manzanit0%2Flondibot-prototype/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/manzanit0","download_url":"https://codeload.github.com/manzanit0/londibot-prototype/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245449496,"owners_count":20617185,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clojure","slack-bot","telegram-bot","tfl-api"],"created_at":"2024-12-03T04:16:03.018Z","updated_at":"2025-03-25T10:40:34.191Z","avatar_url":"https://github.com/manzanit0.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LondiBot\n\nTelegram/Slack bot which reports the status of London TFL services.\n\nThis project was started as an exercise to get in touch with Clojure and its ecosystem.\n\n## Live demo\n\nIf you want to see how the bot works in Slack, simply add it to your workspace: [link](https://slack.com/oauth/authorize?client_id=2225972970.533137885794\u0026scope=incoming-webhook,commands,bot,users:read,chat:write:bot,groups:read,channels:read,im:read,mpim:read,users:read.email,channels:write). A live version has been deployed to Heroku – be aware that it is using free dynos, so it make take time to awake it.\n\n## Getting started\n\n_**Disclaimer:** Before continuing with the below instructions I assume you are aquainted with either the Slack API or the Telegram API in order to develop bots. If that is not the case, please make sure you are familiar with them._\n\nFirst make sure you have leiningen installed, otherwise visit leiningen.org.\n\nSecondly, in order to be able to run any of the bots you will need a PostgreSQL database which contains a `jobs` table. To install PostgreSQL visit https://www.postgresql.org/download/, and to replicate the jobs table, take the following script:\n\n```sql\nCREATE TABLE jobs (\n  id serial PRIMARY KEY, \n  userId VARCHAR(50), \n  cronExpression VARCHAR(50), \n  service VARCHAR(50), \n  submittedDate TIMESTAMPTZ NOT NULL DEFAULT NOW()\n);\n```\n\nTo clone the database for the testing environment you might find this script handy:\n\n```SQL\nCREATE DATABASE londibot_test WITH TEMPLATE londibot OWNER your_user;\n```\n\nYou can name the database as you wish, but make sure that the connection strings are properly configured in the `:profiles` section of leiningen's project map (`project.clj`). In this repository the DB's are set as `londibot` and `londibot_test`.\n\nLastly, once you have the database set up and leiningen install, simply run:\n\n```\nexport TELEGRAM_TOKEN=\u003cyour_token\u003e\nlein telegram\n```\n\nor, in case you prefer to run the Slack bot:\n\n```\nexport SLACK_TOKEN=\u003cyour_token\u003e\nlein slack\n```\n\nAnd that should get you started.\n\n## Explanation\n\nAs you can see in the code, this repository has 3 main sections: the first one is the core functionality to interact with the TFL API. It is a set of Clojure functions which retrieve, parse and expose the status of the tube in London via the TFL API and also allow the application to save scheduled notifications.\n\nThe scheduled notifications or *jobs* represent future notifications which users can request. They are a combination of the `channelId` to which notifications will be sent, a `cron expression` which specifies the regularity of the notifications and the `service` or application through which the request has been made (that's Telegram or Slack). Whenever a user requests a scheduled notification of the status of the tube, a job will be saved in the database.\n\nThe other two sections of the repository are the platform-specific code for the bots; Telegram and Slack. In both of them a ring server is implemented to process requests and return TFL data. For this reason, there are two main functions, one for each of the bots – for this, two aliases have been set in the `project.clj` for convenience.\n\nIts important to note that both bots work with the same database. That's why the `jobs` table has a `service` column. The column allows the applications to distinguish which scheduled jobs correspond to which users. Records will have the values of either `telegram` or `slack`. This allows them, in case the use both applications, to schedule different jobs from the different services.\n\n## TFL API\n\nIn order to make this bot work it uses the current TFL Unified API. For more information, visit: https://api.tfl.gov.uk/.\n\n## Documentation/Where I learnt\n\n1. [How to set up environment profiles](https://8thlight.com/blog/kevin-buchanan/2014/12/08/organizing-your-clojure-environment-and-logs-with-leiningen.html)\n\n2. [Using JDBC Clojure wrapper](http://clojure-doc.org/articles/ecosystem/java_jdbc/using_sql.html)\n\n3. [Setting up testing fixtures](http://thornydev.blogspot.com/2012/09/before-and-after-logic-in-clojuretest.html)\n\n4. [Regexes in Clojure](https://lispcast.com/clojure-regex/)\n\n5. [The complete guide to Clojure destructuring](http://blog.brunobonacci.com/2014/11/16/clojure-complete-guide-to-destructuring)\n\n## License\n\nCopyright © 2019 Manzanit0\n\nDistributed under the Eclipse Public License either version 1.0 or (at\nyour option) any later version.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanzanit0%2Flondibot-prototype","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmanzanit0%2Flondibot-prototype","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanzanit0%2Flondibot-prototype/lists"}