GithubHelp home page GithubHelp logo

sasairc / marunage Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 32 KB

Slack Outgoing Webhooksのサーバのようなもの

License: Do What The F*ck You Want To Public License

Makefile 4.33% Perl 21.75% C 73.92%

marunage's Introduction

marunage

version license build

Slack Outgoing Webhooksの処理言語非依存なサーバのようなもの。

Install

% make
# make install

Usage

% marunage --port=[PORT] --call-parser=[CALL_PARSER] --logfile=[PATH]

marunage-p, --portで指定されたポートをリッスンし、Slack Outgoing Webhooksからの電文を受信します。 その際、HTTPヘッダ等を除いたbody部を第一引数として-c, --call-parserで指定された任意のプログラムを起動。標準出力に対して割り当てられたパイプ経由でJSON形式のデータを取得し、そのデータをレスポンスとして送信します。

パーサプログラムにて処理をtoken、またはtrigger_word単位で管理すれば、複数のSlack Outgoing Webhooksアプリケーションを一元化できます。

Options

長いオプションに必須の引数は短いオプションにも必須です。

  • -p, --port=[PORT] 使用するポートを指定します。既定では8880番です。 Apacheなどのサーバをフロントエンドとして使用している場合、そのリバースプロキシの転送先へ合わせて下さい。

  • -c, --call-parser=[PATH] POSTされた際に呼び出すパーサプログラムを指定します。このオプションは必須です。

  • -f, --logfile=[PATH] アクセスログを記録する任意のファイルを指定します。 とくに指定されない場合は、/var/log/marunage/marunage.logが使用されます。

  • -l, --with-log アクセスログを記録するモードです。既定で有効。

  • -n, --without-log アクセスログを記録しないモードです。

Parser Example

最も単純で危険な「perlでエコーを返す」サンプルです。 自分(bot)の発言内容にもひっかかるため実行は自己責任で・・・

#!/usr/bin/perl
use strict;
use warnings;
use utf8;

use JSON;

my @query = split(/&/, $ARGV[0]);
my ($str, $key, $val, %req);

foreach (@query) {
    ($key, $val) = split(/=/, $_);
    $req{$key} = $val;
}

my $data = {
    token   => $req{token},
    text    => $req{text},
};

print encode_json($data);

return 0;

License

WTFPL version 2

Author

sasairc (http://github.com/sasairc)

marunage's People

Contributors

sasairc avatar

Watchers

 avatar  avatar

marunage's Issues

--vervoseの実装

いつかやる。多分やると思う。やるんじゃないかな。

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.