telegram-scrum-bot 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/.rspec +3 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +111 -0
- data/bin/console +7 -0
- data/bin/setup +7 -0
- data/exe/telegram-scrum-bot +2 -0
- data/lib/telegram-bot.rb +10 -0
- data/lib/telegram-bot/bot.rb +232 -0
- data/lib/telegram-bot/github.rb +45 -0
- data/lib/telegram-bot/issue.rb +23 -0
- data/lib/telegram-bot/trello.rb +112 -0
- data/lib/telegram-bot/version.rb +3 -0
- data/telegram-scrum-bot.gemspec +28 -0
- metadata +129 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7b50013c70e528116d1d7320bb0334e99d3a9974216fa96379c85ebac7ce38fb
|
4
|
+
data.tar.gz: b52fbdcb2033cbe23d6fa3545747561fe988e3639a4a6972004bf766758029a0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d50756eb900c94c9d5b6b31d6d65cef912e2706df12167c3a827f85861d0211454773eb026e9b3a8a521bdc6c2d1cda8b029b2810e718b8abe9fd05dad3fbaa1
|
7
|
+
data.tar.gz: 6b258df630a4f5332c89ae2b98c32323ff1c7b30b561cfd9819b4e4e8d2b2481342eda3f5fd6fa28ad81753537e39238af8940ab24e42610813da726d9885d57
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activemodel (5.2.1)
|
5
|
+
activesupport (= 5.2.1)
|
6
|
+
activesupport (5.2.1)
|
7
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
8
|
+
i18n (>= 0.7, < 2)
|
9
|
+
minitest (~> 5.1)
|
10
|
+
tzinfo (~> 1.1)
|
11
|
+
addressable (2.5.2)
|
12
|
+
public_suffix (>= 2.0.2, < 4.0)
|
13
|
+
axiom-types (0.1.1)
|
14
|
+
descendants_tracker (~> 0.0.4)
|
15
|
+
ice_nine (~> 0.11.0)
|
16
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
17
|
+
coercible (1.0.0)
|
18
|
+
descendants_tracker (~> 0.0.1)
|
19
|
+
concurrent-ruby (1.0.5)
|
20
|
+
descendants_tracker (0.0.4)
|
21
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
22
|
+
diff-lcs (1.3)
|
23
|
+
domain_name (0.5.20180417)
|
24
|
+
unf (>= 0.0.5, < 1.0.0)
|
25
|
+
equalizer (0.0.11)
|
26
|
+
excon (0.62.0)
|
27
|
+
faraday (0.12.2)
|
28
|
+
multipart-post (>= 1.2, < 3)
|
29
|
+
github_api (0.18.2)
|
30
|
+
addressable (~> 2.4)
|
31
|
+
descendants_tracker (~> 0.0.4)
|
32
|
+
faraday (~> 0.8)
|
33
|
+
hashie (~> 3.5, >= 3.5.2)
|
34
|
+
oauth2 (~> 1.0)
|
35
|
+
hashie (3.6.0)
|
36
|
+
http-cookie (1.0.3)
|
37
|
+
domain_name (~> 0.5)
|
38
|
+
i18n (1.1.0)
|
39
|
+
concurrent-ruby (~> 1.0)
|
40
|
+
ice_nine (0.11.2)
|
41
|
+
json (2.1.0)
|
42
|
+
jwt (1.5.6)
|
43
|
+
mime-types (3.2.2)
|
44
|
+
mime-types-data (~> 3.2015)
|
45
|
+
mime-types-data (3.2018.0812)
|
46
|
+
minitest (5.11.3)
|
47
|
+
multi_json (1.13.1)
|
48
|
+
multi_xml (0.6.0)
|
49
|
+
multipart-post (2.0.0)
|
50
|
+
netrc (0.11.0)
|
51
|
+
oauth (0.5.4)
|
52
|
+
oauth2 (1.4.0)
|
53
|
+
faraday (>= 0.8, < 0.13)
|
54
|
+
jwt (~> 1.0)
|
55
|
+
multi_json (~> 1.3)
|
56
|
+
multi_xml (~> 0.5)
|
57
|
+
rack (>= 1.2, < 3)
|
58
|
+
public_suffix (3.0.3)
|
59
|
+
rack (2.0.5)
|
60
|
+
rest-client (2.0.2)
|
61
|
+
http-cookie (>= 1.0.2, < 2.0)
|
62
|
+
mime-types (>= 1.16, < 4.0)
|
63
|
+
netrc (~> 0.8)
|
64
|
+
rspec (3.8.0)
|
65
|
+
rspec-core (~> 3.8.0)
|
66
|
+
rspec-expectations (~> 3.8.0)
|
67
|
+
rspec-mocks (~> 3.8.0)
|
68
|
+
rspec-core (3.8.0)
|
69
|
+
rspec-support (~> 3.8.0)
|
70
|
+
rspec-expectations (3.8.1)
|
71
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
72
|
+
rspec-support (~> 3.8.0)
|
73
|
+
rspec-mocks (3.8.0)
|
74
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
75
|
+
rspec-support (~> 3.8.0)
|
76
|
+
rspec-support (3.8.0)
|
77
|
+
ruby-trello (2.1.0)
|
78
|
+
activemodel (>= 3.2.0)
|
79
|
+
addressable (~> 2.3)
|
80
|
+
json
|
81
|
+
oauth (>= 0.4.5)
|
82
|
+
rest-client (>= 1.8.0)
|
83
|
+
telegram_bot (0.0.8)
|
84
|
+
excon (>= 0.30.0)
|
85
|
+
virtus (>= 1.0.0)
|
86
|
+
thread_safe (0.3.6)
|
87
|
+
tzinfo (1.2.5)
|
88
|
+
thread_safe (~> 0.1)
|
89
|
+
unf (0.1.4)
|
90
|
+
unf_ext
|
91
|
+
unf_ext (0.0.7.5)
|
92
|
+
virtus (1.0.5)
|
93
|
+
axiom-types (~> 0.1)
|
94
|
+
coercible (~> 1.0)
|
95
|
+
descendants_tracker (~> 0.0, >= 0.0.3)
|
96
|
+
equalizer (~> 0.0, >= 0.0.9)
|
97
|
+
|
98
|
+
PLATFORMS
|
99
|
+
ruby
|
100
|
+
|
101
|
+
DEPENDENCIES
|
102
|
+
github_api (~> 0.18.2)
|
103
|
+
rspec (~> 3.8)
|
104
|
+
ruby-trello (~> 2.1)
|
105
|
+
telegram_bot (~> 0.0.8)
|
106
|
+
|
107
|
+
RUBY VERSION
|
108
|
+
ruby 2.5.0p0
|
109
|
+
|
110
|
+
BUNDLED WITH
|
111
|
+
1.16.5
|
data/bin/console
ADDED
data/bin/setup
ADDED
data/lib/telegram-bot.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require_relative 'telegram-bot/bot'
|
2
|
+
|
3
|
+
module TelegramBot
|
4
|
+
end
|
5
|
+
|
6
|
+
config = YAML.load_file("./config/secrets.yml")
|
7
|
+
TelegramBot::TelegramScrumBot.set_token(config['telegram']['token'])
|
8
|
+
TelegramBot::set_trello_tokens(config['trello']['key'], config['trello']['token'])
|
9
|
+
bot = TelegramBot::TelegramScrumBot.new(username: 'hackvan', repository: 'telegram-bot')
|
10
|
+
bot.run
|
@@ -0,0 +1,232 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'telegram_bot'
|
3
|
+
require 'logger'
|
4
|
+
|
5
|
+
require_relative 'github'
|
6
|
+
require_relative 'trello'
|
7
|
+
|
8
|
+
module TelegramBot
|
9
|
+
class TelegramScrumBot
|
10
|
+
attr_accessor :github_username, :github_repository
|
11
|
+
attr_reader :logger, :bot, :user_message
|
12
|
+
|
13
|
+
def self.set_token(token)
|
14
|
+
@@telegram_token = token
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(username:, repository:)
|
18
|
+
@github_username = username
|
19
|
+
@github_repository = repository
|
20
|
+
|
21
|
+
@logger = Logger.new(STDOUT, Logger::DEBUG)
|
22
|
+
@bot = TelegramBot.new(token: @@telegram_token, logger: @logger)
|
23
|
+
@logger.debug "starting telegram bot"
|
24
|
+
end
|
25
|
+
|
26
|
+
def start
|
27
|
+
message = "Hola #{@user_message.from.first_name}, para iniciar puedes utilizar el comando /setup."
|
28
|
+
{
|
29
|
+
bot_message: message,
|
30
|
+
require_answer: false,
|
31
|
+
answer_variable: nil
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
def setup
|
36
|
+
message = "Bienvenido al asistente de configuración del bot:\n\n"
|
37
|
+
if @github_username.empty? || @github_repository.empty?
|
38
|
+
if @github_username.empty?
|
39
|
+
message << "Debe establecer el usuario de Github con /setgithubuser\n"
|
40
|
+
end
|
41
|
+
if @github_repository.empty?
|
42
|
+
message << "Debe establecer el repositorio de Github con /setgithubrepository\n"
|
43
|
+
end
|
44
|
+
else
|
45
|
+
message << "Todo se encuentra correctamente configurado, consulte /help para mas información\n"
|
46
|
+
end
|
47
|
+
{
|
48
|
+
bot_message: message,
|
49
|
+
require_answer: false,
|
50
|
+
answer_variable: nil
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
def set_github_user
|
55
|
+
message = "Por favor defina el usuario de github a utilizar:"
|
56
|
+
{
|
57
|
+
bot_message: message,
|
58
|
+
require_answer: true,
|
59
|
+
answer_variable: :github_username
|
60
|
+
}
|
61
|
+
end
|
62
|
+
|
63
|
+
def get_github_user
|
64
|
+
message = "La configuración establecida para el usuario de github es: #{@github_username}"
|
65
|
+
{
|
66
|
+
bot_message: message,
|
67
|
+
require_answer: false,
|
68
|
+
answer_variable: nil
|
69
|
+
}
|
70
|
+
end
|
71
|
+
|
72
|
+
def set_github_repository
|
73
|
+
message = "Por favor defina el repositorio de github a utilizar:"
|
74
|
+
{
|
75
|
+
bot_message: message,
|
76
|
+
require_answer: true,
|
77
|
+
answer_variable: :github_repository
|
78
|
+
}
|
79
|
+
end
|
80
|
+
|
81
|
+
def get_github_repository
|
82
|
+
message = "La configuración establecida para el repositorio de github es: #{@github_repository}"
|
83
|
+
{
|
84
|
+
bot_message: message,
|
85
|
+
require_answer: false,
|
86
|
+
answer_variable: nil
|
87
|
+
}
|
88
|
+
end
|
89
|
+
|
90
|
+
def help
|
91
|
+
message = "Hola soy Scrum Hackathon Bot, puedo ayudarte consultando Issues de un repositorio y a sincronizarlos con un tablero de Trello.\n\n"
|
92
|
+
message << "Puedes controlarme con los siguientes comandos:\n\n"
|
93
|
+
message << "/start - mensaje de bienvenida\n"
|
94
|
+
message << "/setup - asistente de configuración del bot\n\n"
|
95
|
+
message << "Configuraciones:\n"
|
96
|
+
message << "/setgithubuser - establece la configuración del usuario de github\n"
|
97
|
+
message << "/setgithubrepository - establece la configuración del repositorio de github\n\n"
|
98
|
+
message << "/getgithubuser - obtiene la configuración del usuario de github\n"
|
99
|
+
message << "/getgithubrepository - obtiene la configuración del repositorio de github\n\n"
|
100
|
+
message << "Comandos:\n"
|
101
|
+
message << "/issues - consultar el listado de Issues en el repositorio de Github\n"
|
102
|
+
message << "/trello - sincroniza los issues del repositorio en un tablero de Trello\n"
|
103
|
+
{
|
104
|
+
bot_message: message,
|
105
|
+
require_answer: false,
|
106
|
+
answer_variable: nil
|
107
|
+
}
|
108
|
+
end
|
109
|
+
|
110
|
+
def thanks
|
111
|
+
message = "You welcome!"
|
112
|
+
{
|
113
|
+
bot_message: message,
|
114
|
+
require_answer: false,
|
115
|
+
answer_variable: nil
|
116
|
+
}
|
117
|
+
end
|
118
|
+
|
119
|
+
def get_github_issues
|
120
|
+
if @github_username.empty?
|
121
|
+
message = "Debe indicar el usuario de Github, puede hacerlo con /setgithubuser"
|
122
|
+
elsif @github_repository.empty?
|
123
|
+
message = "Debe indicar el repositorio de Github, puede hacerlo con /setgithubrepository"
|
124
|
+
else
|
125
|
+
github = GitHubConnector.new(username: @github_username,
|
126
|
+
repository: @github_repository)
|
127
|
+
message = "Incidentes registrados en: @#{github.username}/#{github.repository}:\n\n"
|
128
|
+
github.get_issues.each do |issue|
|
129
|
+
if issue.instance_of?(Issue)
|
130
|
+
message << " issue ##{issue.number}\n #{issue.title}\n"
|
131
|
+
message << " -----\n\n"
|
132
|
+
else
|
133
|
+
message << issue
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
{
|
138
|
+
bot_message: message,
|
139
|
+
require_answer: false,
|
140
|
+
answer_variable: nil
|
141
|
+
}
|
142
|
+
end
|
143
|
+
|
144
|
+
def update_trello
|
145
|
+
if github_username.empty?
|
146
|
+
message = "Debe indicar el usuario de Github, puede hacerlo con /setgithubuser"
|
147
|
+
elsif github_repository.empty?
|
148
|
+
message = "Debe indicar el repositorio de Github, puede hacerlo con /setgithubrepository"
|
149
|
+
else
|
150
|
+
trello = TelegramBot::TrelloConnector.new(username: @github_username, repository: @github_repository)
|
151
|
+
message = trello.show_statistics
|
152
|
+
end
|
153
|
+
{
|
154
|
+
bot_message: message,
|
155
|
+
require_answer: false,
|
156
|
+
answer_variable: nil
|
157
|
+
}
|
158
|
+
end
|
159
|
+
|
160
|
+
def no_response_for(command)
|
161
|
+
message = "No tengo idea de lo que el comando #{command.inspect} significa."
|
162
|
+
{
|
163
|
+
bot_message: message,
|
164
|
+
require_answer: false,
|
165
|
+
answer_variable: nil
|
166
|
+
}
|
167
|
+
end
|
168
|
+
|
169
|
+
def get_answer_from_user
|
170
|
+
answer = @bot.get_updates(fail_silently: true).last
|
171
|
+
@logger.info "@#{answer.from.username}: #{answer.text}"
|
172
|
+
result = answer.text
|
173
|
+
answer.reply do |reply|
|
174
|
+
reply.text = "la configuracion ha sido actualizada a: #{result}"
|
175
|
+
reply.send_with(bot)
|
176
|
+
end
|
177
|
+
result
|
178
|
+
end
|
179
|
+
|
180
|
+
def run
|
181
|
+
@bot.get_updates(fail_silently: true) do |user_message|
|
182
|
+
@logger.info "@#{user_message.from.username}: #{user_message.text}"
|
183
|
+
@user_message = user_message
|
184
|
+
command = user_message.get_command_for(@bot)
|
185
|
+
|
186
|
+
user_message.reply do |reply|
|
187
|
+
case command
|
188
|
+
when /start/i
|
189
|
+
result_hash = start
|
190
|
+
when /setup/i
|
191
|
+
result_hash = setup
|
192
|
+
when /thanks/i
|
193
|
+
result_hash = thanks
|
194
|
+
when /setgithubuser/i
|
195
|
+
result_hash = set_github_user
|
196
|
+
when /getgithubuser/i
|
197
|
+
result_hash = get_github_user
|
198
|
+
when /setgithubrepository/i
|
199
|
+
result_hash = set_github_repository
|
200
|
+
when /getgithubrepository/i
|
201
|
+
result_hash = get_github_repository
|
202
|
+
when /help/i
|
203
|
+
result_hash = help
|
204
|
+
when /issues/i
|
205
|
+
result_hash = get_github_issues
|
206
|
+
when /trello/i
|
207
|
+
result_hash = update_trello
|
208
|
+
else
|
209
|
+
result_hash = no_response_for(command)
|
210
|
+
end
|
211
|
+
|
212
|
+
reply.text = result_hash[:bot_message]
|
213
|
+
puts "sending #{reply.text.inspect} to @#{user_message.from.username}"
|
214
|
+
reply.send_with(@bot)
|
215
|
+
|
216
|
+
if result_hash[:require_answer]
|
217
|
+
response = get_answer_from_user
|
218
|
+
instance_variable_set("@#{result_hash[:answer_variable]}", response)
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
if __FILE__ == $0
|
227
|
+
config = YAML.load_file("./config/secrets.yml")
|
228
|
+
TelegramBot::TelegramScrumBot.set_token(config['telegram']['token'])
|
229
|
+
TelegramBot::set_trello_tokens(config['trello']['key'], config['trello']['token'])
|
230
|
+
bot = TelegramBot::TelegramScrumBot.new(username: 'hackvan', repository: 'telegram-bot')
|
231
|
+
bot.run
|
232
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'github_api'
|
2
|
+
require_relative 'issue'
|
3
|
+
|
4
|
+
module TelegramBot
|
5
|
+
class GitHubConnector
|
6
|
+
attr_reader :github_object, :username, :repository, :issues_list
|
7
|
+
|
8
|
+
def initialize(username:, repository:)
|
9
|
+
@github_object = Github.new
|
10
|
+
@username = username
|
11
|
+
@repository = repository
|
12
|
+
@issues_list = []
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_issues(state: 'open', order_mode: 'asc')
|
16
|
+
begin
|
17
|
+
issues = @github_object.issues.list user: @username,
|
18
|
+
repo: @repository,
|
19
|
+
state: state,
|
20
|
+
sort: 'created',
|
21
|
+
direction: order_mode
|
22
|
+
issues.each do |issue|
|
23
|
+
@issues_list << Issue.new(id: issue.id,
|
24
|
+
number: issue.number,
|
25
|
+
title: issue.title,
|
26
|
+
body: issue.body,
|
27
|
+
state: issue.state,
|
28
|
+
url: issue.url)
|
29
|
+
end
|
30
|
+
rescue Github::Error::NotFound => exception
|
31
|
+
@issues_list << "Usuario/Repositorio no encontrado"
|
32
|
+
end
|
33
|
+
@issues_list
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
if __FILE__ == $0
|
39
|
+
github = TelegramBot::GitHubConnector.new(username: 'hackvan', repository: 'telegram-bot')
|
40
|
+
github.get_issues(state: 'all').each do |issue|
|
41
|
+
puts issue
|
42
|
+
puts "-" * 80
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module TelegramBot
|
2
|
+
class Issue
|
3
|
+
attr_accessor :id, :number, :title, :body, :state, :url
|
4
|
+
|
5
|
+
def initialize(id:, number:, title:, body:, state:, url:)
|
6
|
+
@id = id
|
7
|
+
@number = number
|
8
|
+
@title = title
|
9
|
+
@body = body
|
10
|
+
@state = state
|
11
|
+
@url = url
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_s
|
15
|
+
"issue: #{@id}\n" +
|
16
|
+
"number: #{@number}\n" +
|
17
|
+
"title: #{@title}\n" +
|
18
|
+
"body: #{@body}\n" +
|
19
|
+
"state: #{@state}\n" +
|
20
|
+
"url: #{@url}\n"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
module TelegramBot
|
2
|
+
require 'trello'
|
3
|
+
|
4
|
+
@@trello_developer_public_key = ''
|
5
|
+
@@trello_member_token = ''
|
6
|
+
|
7
|
+
def self.set_trello_tokens(key, token)
|
8
|
+
@@trello_developer_public_key = key
|
9
|
+
@@trello_member_token = token
|
10
|
+
|
11
|
+
Trello.configure do |config|
|
12
|
+
config.developer_public_key = @@trello_developer_public_key
|
13
|
+
config.member_token = @@trello_member_token
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
BOARD_DESC = 'Handling issues from the repository'
|
18
|
+
LIST_NAMES = ['Backlog', 'To Do', 'Done']
|
19
|
+
|
20
|
+
class TrelloConnector
|
21
|
+
attr_reader :github_username, :github_repository, :board_name, :statistics
|
22
|
+
|
23
|
+
def initialize(username:, repository:)
|
24
|
+
@statistics = { boards_created: 0, lists_created: 0, cards_created: 0 }
|
25
|
+
@github_username = username
|
26
|
+
@github_repository = repository
|
27
|
+
@board_name = @github_repository.split(/[-_]/i).map(&:capitalize).join(' ')
|
28
|
+
|
29
|
+
@board = find_or_create_board_by_name
|
30
|
+
create_scrum_lists!(@board)
|
31
|
+
close_default_lists!(@board)
|
32
|
+
# archive_existing_cards!
|
33
|
+
populate_issues_cards!
|
34
|
+
end
|
35
|
+
|
36
|
+
def show_statistics
|
37
|
+
"Estadisticas del proceso:\n" +
|
38
|
+
"-" * 25 + "\n" +
|
39
|
+
"Tableros Creados: #{@statistics[:boards_created]}\n" +
|
40
|
+
"Listas Creadas: #{@statistics[:lists_created]}\n" +
|
41
|
+
"Tarjetas Creadas: #{@statistics[:cards_created]}\n"
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
def find_or_create_board_by_name
|
46
|
+
board = Trello::Board.all.detect do |board|
|
47
|
+
board.name =~ /#{@board_name}/
|
48
|
+
end
|
49
|
+
|
50
|
+
unless board
|
51
|
+
board = Trello::Board.create(name: @board_name, description: BOARD_DESC)
|
52
|
+
@statistics[:boards_created] += 1
|
53
|
+
end
|
54
|
+
board
|
55
|
+
end
|
56
|
+
|
57
|
+
def find_backlog_list
|
58
|
+
@board.lists.detect { |list| list.name =~ /backlog/i }
|
59
|
+
end
|
60
|
+
|
61
|
+
def create_scrum_lists!(board)
|
62
|
+
LIST_NAMES.reverse.each do |name, index|
|
63
|
+
list = board.lists.detect { |list| list.name =~ /#{name}/i }
|
64
|
+
unless list
|
65
|
+
Trello::List.create(name: name, board_id: board.id, pos: index)
|
66
|
+
@statistics[:lists_created] += 1
|
67
|
+
end
|
68
|
+
end
|
69
|
+
self
|
70
|
+
end
|
71
|
+
|
72
|
+
def close_default_lists!(board)
|
73
|
+
board.lists.each do |list|
|
74
|
+
unless LIST_NAMES.include?(list.name)
|
75
|
+
list.update_fields(closed: true)
|
76
|
+
list.save
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def archive_existing_cards!
|
82
|
+
find_backlog_list.archive_all_cards
|
83
|
+
end
|
84
|
+
|
85
|
+
def populate_issues_cards!
|
86
|
+
backlog_list = find_backlog_list
|
87
|
+
if backlog_list
|
88
|
+
github = GitHubConnector.new(username: @github_username, repository: @github_repository)
|
89
|
+
github.get_issues.each do |issue|
|
90
|
+
if issue.instance_of?(Issue)
|
91
|
+
card = backlog_list.cards.detect { |c| c.name =~ /^##{issue.number}\s[-]/i }
|
92
|
+
|
93
|
+
unless card
|
94
|
+
Trello::Card.create(name: "##{issue.number} - #{issue.title}", desc: issue.body, list_id: backlog_list.id)
|
95
|
+
@statistics[:cards_created] += 1
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
self
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
if __FILE__ == $0
|
106
|
+
require 'yaml'
|
107
|
+
require_relative 'github'
|
108
|
+
config = YAML.load_file("./config/secrets.yml")
|
109
|
+
TelegramBot.set_trello_tokens(config['trello']['key'], config['trello']['token'])
|
110
|
+
trello = TelegramBot::TrelloConnector.new(username: 'hackvan', repository: 'telegram-bot')
|
111
|
+
puts trello.show_statistics
|
112
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# lib = File.expand_path("../lib", __FILE__)
|
2
|
+
# $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = 'telegram-scrum-bot'
|
6
|
+
spec.date = '2018-09-30'
|
7
|
+
spec.version = '0.0.1'
|
8
|
+
spec.authors = ["Diego Camacho"]
|
9
|
+
spec.email = 'hackvan@gmail.com'
|
10
|
+
|
11
|
+
spec.summary = "A custom bot with Github and Trello connection"
|
12
|
+
spec.description = "A utility bot that permit communicate with Github and Trello API."
|
13
|
+
spec.homepage = "https://github.com/hackvan/telegram-bot"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
17
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
end
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib", "config"]
|
22
|
+
|
23
|
+
spec.add_dependency "telegram_bot", "~> 0.0.8"
|
24
|
+
spec.add_dependency "github_api", "~> 0.18.2"
|
25
|
+
spec.add_dependency "ruby-trello", "~> 2.1"
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
27
|
+
spec.add_development_dependency 'rspec', '~> 3.8'
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: telegram-scrum-bot
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Diego Camacho
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-09-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: telegram_bot
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.0.8
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.0.8
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: github_api
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.18.2
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.18.2
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: ruby-trello
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.1'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.16'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.16'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.8'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.8'
|
83
|
+
description: A utility bot that permit communicate with Github and Trello API.
|
84
|
+
email: hackvan@gmail.com
|
85
|
+
executables:
|
86
|
+
- telegram-scrum-bot
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- Gemfile
|
93
|
+
- Gemfile.lock
|
94
|
+
- bin/console
|
95
|
+
- bin/setup
|
96
|
+
- exe/telegram-scrum-bot
|
97
|
+
- lib/telegram-bot.rb
|
98
|
+
- lib/telegram-bot/bot.rb
|
99
|
+
- lib/telegram-bot/github.rb
|
100
|
+
- lib/telegram-bot/issue.rb
|
101
|
+
- lib/telegram-bot/trello.rb
|
102
|
+
- lib/telegram-bot/version.rb
|
103
|
+
- telegram-scrum-bot.gemspec
|
104
|
+
homepage: https://github.com/hackvan/telegram-bot
|
105
|
+
licenses:
|
106
|
+
- MIT
|
107
|
+
metadata: {}
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options: []
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
- config
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
requirements: []
|
124
|
+
rubyforge_project:
|
125
|
+
rubygems_version: 2.7.3
|
126
|
+
signing_key:
|
127
|
+
specification_version: 4
|
128
|
+
summary: A custom bot with Github and Trello connection
|
129
|
+
test_files: []
|