bridge

command module
v0.0.0-...-eb056b4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2017 License: MIT Imports: 12 Imported by: 0

README

bridge

Go Report Card MIT License
Bridge program between RSS and Slack or Discord webhook written in a pure Golang.

About

"bridge" is RSS feeds reader.
And RSS feeds convert into json,
And execute HTTP POST your team Slack or Discord webhook.
This app written a pure Golang.

Support webhooks

・Slack
・Discord

Install
go get -u github.com/Always-Newbie/bridge  
How to use

0.Please "go build"  

//cd $GOPATH/src/github.com/Always-Newbie/bridge

go build

1.Please preparation for settings.json
・file encoding is "UTF-8".
・Grant read / write permission.
・"settings.json" path is binary same directory. (default settings file)
deliveries is webhooks setting.
--・url is webhook url.
--・username is post username.
--・icon is post avatar icon. (case discord, url string)
--・type is webhook type. ("discord" or "slack")
--・post is can do post flag.
feeds is RSS feeds setting.
--・url is RSS feed url.
--・timestamp is latest read UTC+0000 timestamp. (YYYY/MM/DD HH24:MI:SS) *RUN TIME AUTO UPDATE!
--・read is can do read flag.

{
    "deliveries":[
        {
            "url": "https://discordapp.com/api/webhooks/xxxxxxxxxxxxxx",
            "username": "discord bot",
            "icon": "",
            "type": "discord",
            "post": true
        },
        {
            "url": "https://hooks.slack.com/services/yyyyyyyyyyyyyyy",
            "username": "slack bot",
            "icon": ":crossed_swords:",
            "type": "slack",
            "post": true
        }
    ],
    "feeds":[
        {
            "url": "http://www.nba.com/rss/nba_rss.xml",
            "timestamp": "2017/03/03 16:12:12",
            "read": true
        }
    ]
}

2.Please execute command

//go run main.go [option:-config=(setting file path. default is "./settings.json")] 

$ ./bridge [option:-config=(setting file path. default is "./settings.json")]

3.Please check your Slack or Discord channel

Affinity Usage

・cron

// crontab image

$ crontab -l
HOME=/xxx/bridge
*/10 * * * * ./bridge -config=planA.json
5 * * * * ./bridge -config=planB.json
* 1 * * * ./bridge -config=planC.json
Appendix: json image for Discord Webhook

・simple message example

{
    "content": "simple bot."
}

・embed example(hyperlink)

{
    "embeds": [
        {
            "title": "bot test",
            "url": "https://www.example.com/",
            "description": "bot bot bot!",
            "type": "link",
            "thumbnail":{
                "url": ""
            }
        }
    ]
}

・advanced example multiple contents(content + embeds)

{
    "username": "example username",
    "avatar_url": "https://xxxxxx.png",
    "content": "content sample",
    "embeds": [
        {
            "title" : "embed title",
            "url" : "https://www.example.com/",
            "author": {
                "name": "embed author name",
                "url": "https://www.example.com/",
                "icon_url": "https://xxxxxxxx.png",
            },
            "description": "[masking url text sample](https://www.google.com/)",
            "color": 15258703,
            "fields": [
                {
                    "name": "embed field first",
                    "value": "embed field first value"
                },
                {
                    "name": "embed field second",
                    "value": "embed field second value"
                }
            ],
            "footer": {
                "text": "footer text",
                "icon_url": "https://xxxxxxxx.png"
            }
        }
    ]
}

・a lot of field json image
WARNING: this json is do not work

{
    "username": "example username",
    "avatar_url": "https://www.example.com/avatar_url.png",
    "content": "Content Sample Text",
    "tts": false,
    "file":  "",
    "embeds": [
        {
            "title" : "Sample Embed Title",
            "url" : "https://www.example.com",
            "description": "[Click here to see this text](https://www.google.com/embed_description_url)",
            "color": 15258703,
            "author": {
                "name": "Sample Author Name",
                "url": "https://www.example.com/author_url",
                "icon_url": "https://www.example.com/author_icon_url.png",
                "description" : "Author Description Text Example"
            },
            "thumbnail": {
                "url": "https://www.example.com/thumbnail_url.png",
            },
            "image": {
                "url": "https://www.example.com/image_url.png"
            },
            "video": {
                "url": "https://www.example.com/video_url",
            },
            "footer": {
                "text": "Footer Sample Text",
                "icon_url": "https://www.example.com/footer_icon.png"
            },
            "provider": {
                "name": "Sample Provider Name",
                "url": "http://www.example.com/provider_url"
            },
            "fields": [
                {
                    "name": "First Description Field Sample Name",
                    "value": "First Description Field Sample Value",
                    "inline": true
                },
                {
                    "name": "Second Description Field Sample Name",
                    "value": "Second Description Field Sample Value",
                    "inline": false
                }
            ],
            "footer": {
                "text": "Footer Sample Text",
                "icon_url": "https://www.example.com/footer_icon.png"
            }
        }
    ]
}
Appendix: json image for Slack Webhook

Slack Webhook json sample

・simple

{
     "text": "Sample"
}

・a lot of fields sample

{
    "attachments": [
        {
            "fallback": "Required plain-text summary of the attachment.",
            "color": "#36a64f",
            "pretext": "Optional text that appears above the attachment block",
            "author_name": "Bobby Tables",
            "author_link": "http://flickr.com/bobby/",
            "author_icon": "http://flickr.com/icons/bobby.jpg",
            "title": "Slack API Documentation",
            "title_link": "https://api.slack.com/",
            "text": "Optional text that appears within the attachment",
            "fields": [
                {
                    "title": "Priority",
                    "value": "High",
                    "short": false
                }
            ],
            "image_url": "http://my-website.com/path/to/image.jpg",
            "thumb_url": "http://example.com/path/to/thumb.png",
            "footer": "Slack API",
            "footer_icon": "https://platform.slack-edge.com/img/default_application_icon.png",
            "ts": 123456789
        }
    ]
}

Thanks for Reading :)

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL