post-to-socials

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

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

Go to latest
Published: May 4, 2021 License: MIT Imports: 19 Imported by: 0

README

📣 Post to socials API service

A simple REST based API service written in Go which relays a message via the API to social messaging networks. The service currently supports posting 140 char messages to Twitter, Telegram (chat) and Discord (channel).

Getting Started

This application requires Go 1.14 or above installed on your machine. Tested on linux and macosx.

Building

Check out the repository locally and run:

make build
Configuration

Edit the file config.yaml and fill in the required configuration values:

host => Post to socials API service hostname e.g. "localhost"  
port => Post to socials API service port e.g. "5432"

csv => Path to csv of authentication key/secret pairs e.g. "csv/auth.csv"

twitterEnabled           => true if you want to enable Twitter, false otherwise
twitterConsumerKey       => Twitter API consumer key e.g. "xgtOU2XljrxBBQuWzkWfe4ebp"
twitterConsumerSecret    => Twitter API consumer secret e.g. "HMcXX73htvoe73mS2NR2cY9aag3r9D8CmbJtAlMPEfXRD1Qucp" 
twitterAccessTokenKey    => Twitter API access token e.g. "1355884211619828228-NjPbG8kFxVUxjqMWFsPfS7CKfT3vOM"
twitterAccessTokenSecret => Twitter API access token secret e.g. "e2E1iLEWGqL1JMB0oQIPsH1omEyalXj9hcRHi6jAMyGaC"

telegramEnabled  => true if you want to enable Telegram, false otherwise
telegramChatId   => Telegram chat identifier to post to e.g. "-1991156818728"
telegramBotToken => Telegram bot token e.g. "1441979128:AKKpe6CDKXoChpQ2KJ-fwej6F2qjjhbmdNA"

discordEnabled  => true if you want to enable Discord, false otherwise
discordGuildId  => Discord guild/server identifier e.g. "120571334818737489"
discordChannel  => Discord channel to post to e.g. "bot-playground"
discordBotToken => Discord bot token e.g "XD1MTE2MzkyMDE3NDk0MDE2.YFFNEg.14wlVKNs5ITFgDLzT3N-bffOIsE" 

slackEnabled    => true if you want to enable Slack, false otherwise
slackToken      => Slack token
slackChannelID  => Slack channel ID

To help with deployment on cloud hosting providers, the config also supports Environment (ENV) variables. The named ENV vars are shown directly in the configuration source code.

Usage

Once built and configured, run the service binary using the following command:

./post-to-socials

To send a message, construct a JSON POST message to send with the following HTTP headers:

key => Post to socials API authentication key (from auth.csv file)
secret => Post to socials API authentication secret (from auth.csv file)

The message body should include the JSON body content as follows:

{"message":"Your message body here, max 140 characters :)"}

Please see the different API methods in the next section for your choice of network to relay to.

API methods
Method Location Description
POST /send/discord Send a Discord message (max 3000 chars) to the guild/channel specified in the config file.
POST /send/telegram Send a Telegram message (max 3000 chars) to the chat ID specified in the config file.
POST /send/slack Send a Slack message (max 3000 chars) to the channel specified in the config file.
POST /send/twitter Send a Twitter message (max 140 chars) to the profile specified (API keys) in the config file.
POST /send/all Send a message (max 140 chars) to all three social channels in one go!
GET /send Display a helpful web form to test credentials and send messages manually. See below.
Test form

Available for convenience of testing, uses the API defined above. Accessible in a web browser at /send:

CSV auth file

A very simple unencrypted key store, one line per key/secret pair. For example:

Contributing

Contributions very welcome, please fork the repo and then submit PR changes back here.

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Project Link: https://github.com/cdm/post-to-socials

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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