Giter Site home page Giter Site logo

startuplifers-tgbot-serverless's Introduction

NOTE: This project currently lives in https://github.com/Startuplifers/startuplifers-tgbot-serverless

Telegram bot for Startuplifers

Telegram bot that sends new job postings to a publicly available Telegram channel.

The app fetches a json file from api and compares it to the one stored in a s3 bucket. If there is difference between the two i.e. new job postings, the app sends the new jobs to the channel and saves the new json file to the s3 bucket.

Getting started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Installation

Clone the project: git clone https://github.com/tterimaa/startuplifers-tgbot-serverless.git

Install the dependencies: npm install

Install serverless framework: npm i serverless

You need to have awscli installed. With debian linux use sudo apt install awscli

Setup AWS

If you want to create an own IAM user for the bot, you need to grant the following permissions:

  • AmazonS3FullAccess
  • AWSCloudFormationFullAccess
  • AmazonAPIGatewayAdministrator
  • IAMFullAccess
  • AWSLambdaFullAccess

After configuring awscli you need to create a s3 bucket, name it according to environment variable BUCKET_NAME and add jobs.json to the bucket. jobs.json must initially contain an empty array []. After the first execution this file will contains the previous state of the json file in the API.

Setup Telegram

You need to create a new Telegram bot or use an existing one. New bot can easily be created messaging BotFather in Telegram with message /newbot. After creating a bot you obtain a bot token.

Create a Telegram channel and add your bot to the channel as an admin.

Start the project

Before starting you need to create .env file containing:

TOKEN=your-token
BUCKET_NAME=your-bucket-name

Now everything should be set up. Start the project using: npm start

Running the tests

Run tests using npm run test.

The tests are uploading files into s3, so it takes a while to run. After uploading something into the bucket it runs the index.js, thus the json file in the bucket is always left with the most recent jobs. Tests are overwriting the same file 'jobs.json' that is also used in production.

Tests could be improved to use their own file to make sure there is no interference between the tests and the production application.

Deployment

Deploy the project with: npm run deploy

By default the function is set up to run every 24h after the deployment and you can also test your deployment manually using HTTP endpoint, which you get after the deployment.

These settings can be changed from the configuration file serverless.yml:

events:
      - http:
          method: get
          path: index
      - schedule: rate(24 hours)

startuplifers-tgbot-serverless's People

Contributors

tterimaa avatar jetch avatar

Watchers

James Cloos avatar  avatar

Forkers

startuplifers

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.