-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.yaml
100 lines (81 loc) · 3.41 KB
/
config.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
---
cog_bundle_version: 4
name: twitter
description: Interact with Twitter
author: Operable <support@operable.io>
homepage: https://github.com/cogcmd/twitter
version: 0.0.12
docker:
image: cogcmd/twitter
tag: 0.0.12
permissions:
- twitter:tweet
commands:
tweet:
description: Tweet from one or more accounts
executable: /home/bundle/cog-command
arguments: "<message>"
examples: |
twitter:tweet "Everything is running fine"
twitter:tweet --as=news "We just released version 1.0.0!"
notes: |
Returns a JSON map with the following keys:
- tweet_text: The body of the tweet
- tweet_url: The URL for the tweet
- account_name: The Twitter screen name of the account that
sent the tweet, without the leading "@" sign.
Behavior is configured by the following environment variables:
TWITTER_CONSUMER_KEY_<ACCOUNT>
TWITTER_CONSUMER_SECRET_<ACCOUNT>
TWITTER_ACCESS_TOKEN_<ACCOUNT>
TWITTER_ACCESS_TOKEN_SECRET_<ACCOUNT>
TWITTER_DEFAULT_ACCOUNT
where <ACCOUNT> is either the value of the supplied `--as` option,
or the value of the environment variable TWITTER_DEFAULT_ACCOUNT.
Note that the value does not need to be the literal Twitter
account name, just a common tag to associate a group of
credentials together.
For example, say you have both @MyCompanyStatus and
@MyCompanyNews Twitter accounts, and you would like to configure
Cog to tweet from either account. Once you've obtained the
necessary API credentials from Twitter for each account, you
could create a dynamic configuration YAML file like this:
---
TWITTER_CONSUMER_KEY_STATUS: <consumer key for @MyCompanyStatus>
TWITTER_CONSUMER_SECRET_STATUS: <etc>
TWITTER_ACCESS_TOKEN_STATUS: <etc>
TWITTER_ACCESS_TOKEN_SECRET_STATUS: <etc>
TWITTER_CONSUMER_KEY_NEWS: <consumer key for @MyCompanyNews>
TWITTER_CONSUMER_SECRET_NEWS: <etc>
TWITTER_ACCESS_TOKEN_NEWS: <etc>
TWITTER_ACCESS_TOKEN_SECRET_NEWS: <etc>
TWITTER_DEFAULT_ACCOUNT: STATUS
(See http://docs.operable.io/docs/dynamic-command-configuration
for further details.)
Here we have set @MyCompanyStatus as the default account, so
when you execute
twitter:tweet "Everything is running fine"
@MyCompanyStatus will tweet that message. On the other hand, if
you want to tweet some news, you would execute
twitter:tweet --as=news "We just released version 1.0.0!"
which will use the @MyCompanyNews account.
You do not have to set TWITTER_DEFAULT_ACCOUNT, in which case
you will always need to explicitly declare who you're tweeting
as, using the suffix for the credential environment variables
you want.
The value specified for the `--as` option will be uppercased in
order to find the appropriate environment variables. Thus
`--as=news`, `--as=NEWS`, and `--as=NeWs` are all
equivalent. The environment variable names, however, must be
completely capitalized.
rules:
- 'when command is twitter:tweet must have twitter:tweet'
options:
as:
type: string
required: false
short_flag: a
description: the account to tweet as; see NOTES
templates:
tweet:
body: '~each var=$results~~$item.tweet_url~~end~'