-
Notifications
You must be signed in to change notification settings - Fork 0
/
pipeline.yml
138 lines (128 loc) · 3.16 KB
/
pipeline.yml
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
resource_types:
- name: telegram
type: docker-image
source:
repository: carlocolombo/telegram-resource
tag: latest-dev
resources:
- name: start
check_every: 5s
type: telegram
source:
filter: '/start'
telegram_key: {{telegram_bot_token}}
- name: answer
type: telegram
source:
telegram_key: {{telegram_bot_token}}
- name: red pill
check_every: 5s
type: telegram
source:
filter: 'red pill'
telegram_key: {{telegram_bot_token}}
- name: blue pill
check_every: 5s
type: telegram
source:
filter: 'blue pill'
telegram_key: {{telegram_bot_token}}
task_resource: &task_resource
type: docker-image
source:
repository: concourse/buildroot
tag: 'curl'
task_resource: &task_resource_py
type: docker-image
source:
repository: python
tag: 3-alpine
jobs:
- name: send start
plan:
- get: start
trigger: true
- task: prepare-answer
config:
platform: linux
image_resource: *task_resource_py
inputs:
- name: start
outputs:
- name: answer
params:
message: "This is your last chance. After this, there is no turning back. You take the blue pill—the story ends,
you wake up in your bed and believe whatever you want to believe. You take the red pill—you stay in Wonderland,
and I show you how deep the rabbit hole goes.
Remember: all I'm offering is the truth. Nothing more."
run:
path: python3
args:
- -c
- |
import json, os
with open('start/message') as msg_file, open('answer/message','w+') as answer_file:
msg = json.load(msg_file)
chat_id = msg['chat']['id']
answer = {
'chat_id': chat_id,
'text': os.environ['message'],
'reply_markup': {
'keyboard': [
[{'text': "blue pill"}],
[{'text': "red pill"}]
]
}
}
json.dump(answer, answer_file)
print("Your chat id is '%s'" % chat_id)
- put: answer
params:
message: answer/message
- name: rabbit hole
plan:
- get: red pill
trigger: true
- get: start
passed: [send start]
- task: test-code
config:
platform: linux
image_resource: *task_resource_py
inputs:
- name: red pill
run:
path: python3
args:
- -c
- |
with open('red pill/message') as f:
print(f.read())
print('the red pill')
- name: wake up in your bed
plan:
- get: blue pill
trigger: true
- get: start
passed: [send start]
- task: test-code
config:
platform: linux
image_resource: *task_resource
inputs:
- name: blue pill
outputs:
- name: answer
params:
MESSAGE: the story ends, you wake up in your bed and believe whatever you want to believe.
run:
path: sh
args:
- -exc
- |
echo "$MESSAGE" > answer/text
jq '.chat.id' < 'blue pill/message' > answer/chat_id
- put: answer
params:
text: answer/text
chat_id: answer/chat_id