Git Product home page Git Product logo

spacelaunchslackbot's Introduction

Space Launch Slack Bot

This repository contains the code for a script that will post information regarding upcoming space launches to a custom Slack Channel.

What It Does: Post information about upcoming space launches to your Slack Channel

What It Does Not: Fulfill your hopes and dreams (unless your hopes and dreams were to post information about space launches to your Slack Channel)

Setup

Prerequisites

  • Python 3
  • Working Internet Connection
  • Admin Access to a Slack Team or the ability to bribe someone who does

Implementation

  1. Create a new Incoming Slack Webhook
  • Feel free to customize it as you wish.
  • If you don't have access to add an incoming webhook, see the Recommended Settings section for more details.
  1. Dump webhook url into the copy of the script if running directly. (See Docker section below if running in Docker)
  • Webhook goes in the SLACK_WEBHOOK variable
  1. Run that shit. Schedule a cron job or put it in Kubernetes or something. I don't know.

Recommended Settings

Create a Custom Webhook integration for your Slack org: Link

When creating the custom webhook for the Slack channel, there are a few options to customize.

It's also possible that you don't have access to add an incoming webhook to your team because of the permissions model. In that case, you would need to know what to send to the admin to get it set up. This is that stuff.

Here are the recommended settings when setting up the Hook:

  • Post to Channel: Your #space channel, or #rockets
  • Descriptive Label: Whatever you want. This isn't really necessary.
  • Customize Name: "Upcoming Launches"
  • Customize Icon: Pick an emoji โ†’ :rocket: ๐Ÿš€

Copy the Webhook URL or have the Admin send that URL to you, you'll need it for the script.

Running

The bot will run and post the details of the next rocket launch, as determined via info from LaunchLibrary

Running in Docker

Since this script is fairly simple, it's easy enough to run in a compact docker container, ensuring that the script is offloaded from whatever main host you have.

Building Docker Image

There is a GitHub action which will build and deploy this container automatically, but if you want to build it locally (i.e. to use a custom cron schedule)

  1. Edit the crontab file to reflect the schedule you want. By default, it will run at 7am daily. (Be sure to set the TZ env var to your local time, otherwise UTC will be used)

  2. Build the image

docker build -t slack-launch .
  1. Run the image
docker run -it --detach --rm --name slack-launch -e TZ="America/New_York" -e SLACK_WEBHOOK='https://hooks.slack.com/services/HOOKURL' slack-launch

Contributing

Check out the Issues page for a list of potential tasks and features that are on the roadmap to be added. Once you select an issue or feature that you would like to work on, please assign yourself that issue.

spacelaunchslackbot's People

Contributors

amayer5125 avatar dependabot[bot] avatar tomswartz07 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

nathanielevry

spacelaunchslackbot's Issues

Containerize

Make it portable with a docker container or something that will also sets up Cron rules.

It would be great if the project was set up with some sort of CI/CD pipeline to automatically update the instance and run the code when triggered by merges to master

Expand data that is returned

Using the current API, there is a vast amount of data that is returned from various sources.

Current implementation has quite a few of them displayed, but items such as Launch Hold, Probability of Launch, etc. could be implemented as well.

A sample return of a single launch:

{
  "total": 1,
  "launches": [
    {
      "id": 1263,
      "name": "Long March 3B/E | Chinasat-9A",
      "windowstart": "May 10, 2017 00:00:00 UTC",
      "windowend": "May 10, 2017 00:00:00 UTC",
      "net": "May 10, 2017 00:00:00 UTC",
      "wsstamp": 0,
      "westamp": 0,
      "netstamp": 0,
      "isostart": "20170510T000000Z",
      "isoend": "20170510T000000Z",
      "isonet": "20170510T000000Z",
      "status": 2,
      "inhold": 0,
      "tbdtime": 1,
      "vidURLs": [],
      "vidURL": null,
      "infoURLs": [],
      "infoURL": null,
      "holdreason": null,
      "failreason": null,
      "tbddate": 1,
      "probability": -1,
      "hashtag": null,
      "location": {
        "pads": [
          {
            "id": 147,
            "name": "Unknown, Xichang Satellite Launch Center",
            "infoURL": "Unknown",
            "wikiURL": "https://en.wikipedia.org/wiki/Xichang_Satellite_Launch_Center",
            "mapURL": "https://www.google.com/maps?ll=28.246017,102.026556&q=28.246017,102.026556&hl=en&t=m&z=15",
            "latitude": 28.246017,
            "longitude": 102.026556,
            "agencies": [
              {
                "id": 17,
                "name": "China National Space Administration",
                "abbrev": "CNSA",
                "countryCode": "CHN",
                "type": 1,
                "infoURL": "http://www.cnsa.gov.cn/",
                "wikiURL": "http://en.wikipedia.org/wiki/China_National_Space_Administration",
                "infoURLs": [
                  "http://www.cnsa.gov.cn/"
                ]
              }
            ]
          }
        ],
        "id": 25,
        "name": "Xichang Satellite Launch Center, People's Republic of China",
        "infoURL": "",
        "wikiURL": "",
        "countryCode": "CHN"
      },
      "rocket": {
        "id": 69,
        "name": "Long March 3B/E",
        "configuration": "B/E",
        "familyname": "Long March 3",
        "agencies": [
          {
            "id": 88,
            "name": "China Academy of Space Technology",
            "abbrev": "CASC",
            "countryCode": "CHN",
            "type": 3,
            "infoURL": "http://www.cast.cn/CastEn/",
            "wikiURL": "http://en.wikipedia.org/wiki/China_Academy_of_Space_Technology",
            "infoURLs": [
              "http://www.cast.cn/CastEn/"
            ]
          }
        ],
        "wikiURL": "https://en.wikipedia.org/wiki/Long_March_3B",
        "infoURLs": [],
        "imageURL": "https://s3.amazonaws.com/launchlibrary/RocketImages/placeholder_1920.png",
        "imageSizes": [
          320,
          480,
          640,
          720,
          768,
          800,
          960,
          1024,
          1080,
          1280,
          1440,
          1920
        ]
      },
      "missions": [
        {
          "id": 559,
          "name": "Chinasat-9A",
          "description": "ChinaSat-9A is based on the DFH-4 satellite platform and is to provide direct broadcast services with eighteen 36MHz and four 54MHz BSS Ku band transponders. Together with ChinaSat-9 direct broadcast satellite, ChinaSat 9A is designed to serve the radio and TV transmission, digital film and digital broadband multi-media system as well as information and entertainment broadcasting market.",
          "type": 10,
          "typeName": "Communications"
        }
      ]
    }
  ],
  "offset": 0,
  "count": 1
}

Add a time-window based trigger, rather than always posting on run

Expected Behaviour:

  • A launch is scheduled to occur within 24h or 1h

  • Script runs

  • Message is posted

  • A launch is scheduled to occur 1 week from current time

  • Script runs

  • Message is not posted

Current Behaviour

Message is posted regarding next launch, no matter the timeframe

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.