Giter VIP home page Giter VIP logo

gitlabtelegramchannel's Introduction

Gitlab Telegram Channel

The application integrating GitLab with Telegram.

How it works

The application listens for GitLab webhooks and calls the Telegram Bot API.

Which Webhook events are supported

How to setup

  1. Plan the endpoint for the application to run.
  2. Setup GitLab webhooks and obtain a GitLab secret token. Use the following url as a webhook target: <your_endpoint>/gitlab_hook, e.g. https://my-hook-endpoint.com/gitlab_hook
  3. Setup a Telegram bot and obtain a Bot token
  4. Setup a Telegram channel to which your bot would post messages
  5. Configure and deploy the app, see the Configuration reference section below

Configuring

If you're familiar with the .NET Core configuration framework

Use any of the standard ways to provide the app configuration:

  • appsettigns.json
  • appsettings.{environment}.json
  • environment variables
  • command line arguments

If not

There are several ways to configure a .NET Core application

  1. appsettings.json file - normally contains the most of the configuration.
  2. appsettings.{environment}.json file - may be used to make some environment-dependent configuration overrides. The environment name normally comes from the ASPNETCORE_ENVIRONEMNT environment variable or from an --environment command line arg. By-default the environment name is Production, so the filename would be the appsettings.production.json.
  3. Environment variables. Every setting from the appsettings.json may be overriden by an environment variable, having a name, same to the setting name in appsettings.json. The : symbol in a variable name is used as a hierarchy level separator. E.g. configuration setting TGram > Connection > Timeout may be overriden by an environemnt variable TGRAM:CONNECTION:TIMEOUT.
  4. Command line arguments. Every setting from the appsettings.json may be overriden by a command-line key. The : symbol in a key name is used as a hierarchy-level separator. E.g. configuration setting TGram > Connection > Timeout may be overriden by a --tgram:connection:timeout parameter.

Running the app

  1. Ensure you have the runtime of a compatible version installed. At the moment the application was developed, the 2.2.x version of the runtime was current. Pay attention you don't need the whole SDK to run the app - a bare runtime is enough.
  2. run dotnet TGramWeb.dll, optionally providing command-line args. e.g: dotnet TGramWeb.dll --urls http://localhost:9000 --environment azure

Configuration reference

Listen addresses

A set of addresses the app would be listening at. A semicolon ; may be used as a separator for multiple addresses. E.g. http://localhost:5000;https://localhost:5001

appsettings.json Command line Env variable
n/a --urls ASPNETCORE_URLS

Runtime environment

Determines the application environment. The default value is Production

appsettings.json Command line Env variable
n/a --environment ASPNETCORE_ENVIRONMENT

Gitlab secure token

A secure token you obtain when configuring a gitlab web hook.

appsettings.json Command line Env variable
Gitlab>Token --gitlab:token GITLAB:TOKEN

Telegram API endpoint

Address of the telegram API. Normally https://api.telegram.org

appsettings.json Command line Env variable
TGram>Endpoint --tgram:endpoint TGRAM:ENDPOINT

Telegram bot token

Telegram bot token you obtain when creating a bot.

appsettings.json Command line Env variable
TGram>Token --trgram:token TGRAM:TOKEN

Telegram channel

Telegram channel name. E.g. @mytgramchannel

appsettings.json Command line Env variable
TGram>Channel --tgram:channel TGRAM:CHANNEL

Telegram API connection timeout

Connection timeout when trying to send a message to telegram.

appsettings.json Command line Env variable
TGram>Connection>Timeout --tgram:connection:timeout TGRAM:CONNECTION:TIMEOUT

Telegram API connection attempts

Number of attempts to send a message to telegram before giving up.

appsettings.json Command line Env variable
TGRAM:CONNECTION:ATTEMPTS --tgram:connection:attempts TGRAM:CONNECTION:ATTEMPTS

Telegram API connection interval

An interval between telegram call attempts.

appsettings.json Command line Env variable
TGram>Connection>Interval --tgram:connection:interval TGRAM:CONNECTION:INTERVAL

Internal daemon address

A localhost address used to communicate between the web server and internal message handlers.

appsettings.json Command line Env variable
Daemon>Address --daemon:address DAEMON:ADDRESS

Number of internal message handlers

appsettings.json Command line Env variable
Daemon>ThreadCount --daemon:threadcount DAEMON:THREADCOUNT

Serilog

Serilog standard configuration. See here.

appsettings.json Command line Env variable
Serilog>... --serilog:... SERILOG:...

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.