-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
executable file
·626 lines (574 loc) · 29 KB
/
bot.py
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import requests
import html
import configparser
import urllib
from urllib.request import urlopen
from urllib.parse import quote_plus
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, InlineQueryHandler, CallbackQueryHandler
from telegram import InlineQueryResultArticle, ChatAction, InputTextMessageContent, InlineKeyboardButton, InlineKeyboardMarkup, Chat, User, Message, Update, ChatMember, UserProfilePhotos, File, ReplyMarkup, TelegramObject
from uuid import uuid4
import subprocess
import time
import logging
import json
from json import JSONDecoder
from functools import partial
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO)
logger = logging.getLogger(__name__)
def error(bot, update, error):
logger.warn('Update "%s" caused error "%s"' % (update, error))
def __repr__(self):
return str(self)
config = configparser.ConfigParser()
config.read('bot.ini')
updater = Updater(token=config['KEYS']['bot_api'])
jenkins = config['JENKINS']['url']
user = config['JENKINS']['user']
password = config['JENKINS']['password']
token = config['JENKINS']['token']
job = config['JENKINS']['job']
gerrituser = config['GERRIT']['user']
gerriturl = config['GERRIT']['url']
protocol = config['GERRIT']['protocol']
jenkinsconfig = config['JENKINS']['on']
username = config['ADMIN']['username']
dispatcher = updater.dispatcher
hereyago = "Here's a list of commands for you to use:\n"
build_help = "/build to start the build process\n"
changelog_help = "/changelog 'text' to set the changelog\n"
sync_help = "/sync to set sync to on/off\n"
clean_help = "/clean to set clean to on/off\n"
repopick_a_help = "/repopick to set repopick on or off\n"
reset_help = "/reset to set reset on or off\n"
repopick_b_help = "-- /repopick `changes` to pick from gerrit on build\n"
open_a_help = "/open to see all open changes\n"
open_b_help = "-- /open `projects` to see open changes for certain projects\n"
pickopen_help = "/pickopen to pick all open changes on gerrit\n"
help_help = "/help to see this message\n--/help 'command' to see information about that command :)" # love this lmao help_help
jenkinsnotmaster = "Sup *not* master. \n" + hereyago + open_a_help + open_b_help + help_help
nojenkinsnotmaster = "Sup *not* master. \n" + hereyago + open_a_help + open_b_help + help_help
jenkinsmaster = "Sup" + username + "\n" + hereyago + build_help + changelog_help + sync_help + clean_help + repopick_a_help + reset_help + repopick_b_help + pickopen_help + open_a_help + open_b_help + help_help
nojenkinsmaster = "Sup" + username + "\n" + hereyago + open_a_help + open_b_help + help_help
cg = "This is an automated build, provided by @BruhhJenkinsBot."
cg = quote_plus(cg)
syncparam = "true"
cleanparam = "false"
repopickstatus = "false"
rpick = ""
reporeset = "false"
release = "false"
def get_admin_ids(bot, chat_id):
"""Returns a list of admin IDs for a given chat."""
return [admin.user.id for admin in bot.getChatAdministrators(chat_id)]
def start(bot, update):
if update.message.chat.type == "private":
bot.sendChatAction(chat_id=update.message.chat_id,
action=ChatAction.TYPING)
bot.sendMessage(chat_id=update.message.chat_id,
text="Hi. I'm Hunter's Jenkins Bot! You can use me to do lots of cool stuff, assuming your name is @hunter_bruhh! If not, then I'm not much use to you right now! Maybe he'll implement some cool stuff later!")
if update.message.from_user.id != int(config['ADMIN']['id']):
if jenkinsconfig == "yes":
bot.sendChatAction(chat_id=update.message.chat_id,
action=ChatAction.TYPING)
time.sleep(1)
bot.sendMessage(chat_id=update.message.chat_id,
text=jenkinsnotmaster)
bot.sendChatAction(chat_id=update.message.chat_id,
action=ChatAction.TYPING)
else:
bot.sendChatAction(chat_id=update.message.chat_id,
action=ChatAction.TYPING)
time.sleep(1)
bot.sendMessage(chat_id=update.message.chat_id,
text=nojenkinsnotmaster)
bot.sendChatAction(chat_id=update.message.chat_id,
action=ChatAction.TYPING)
else:
if jenkinsconfig == "yes":
bot.sendMessage(chat_id=update.message.chat_id,
text=jenkinsmaster)
bot.sendChatAction(chat_id=update.message.chat_id,
action=ChatAction.TYPING)
else:
bot.sendMessage(chat_id=update.message.chat_id,
text=nojenkinsmaster)
bot.sendChatAction(chat_id=update.message.chat_id,
action=ChatAction.TYPING)
def help_message(bot, update, args):
jenkinsmasterlist = ["build", "changelog", "sync", "clean", "repopick", "pickopen", "open"]
nojenkinsmasterlist = ["open"]
nojenkinslist = ["open"]
jenkinslist = ["open"]
args_length = len(args)
if update.message.from_user.id != int(config['ADMIN']['id']):
if jenkinsconfig == "yes":
if args_length != 0:
if args_length > 1:
for x in jenkinslist:
try:
helpme
except NameError:
helpmeplox = "Please use only one argument. A list of arguments aka commands to ask about would be:\n"
helpmeplox = helpmeplox + x + ",\n"
helpme = helpmeplox
else:
if args[0] in jenkinslist:
if args[0] == "open":
helpme = open_a_help + open_b_help
else:
helpme = "That's not a command to ask about."
bot.sendChatAction(chat_id=update.message.chat_id,
action=ChatAction.TYPING)
time.sleep(1)
bot.sendMessage(chat_id=update.message.chat_id,
text=helpme)
else:
bot.sendChatAction(chat_id=update.message.chat_id,
action=ChatAction.TYPING)
time.sleep(1)
bot.sendMessage(chat_id=update.message.chat_id,
text=jenkinsnotmaster)
else:
if args_length != 0:
if args_length > 1:
for x in nojenkinslist:
try:
helpme
except NameError:
helpmeplox = "Please use only one argument. A list of arguments aka commands to ask about would be:\n"
helpmeplox = helpmeplox + x + ",\n"
helpme = helpmeplox
else:
if args[0] in nojenkinslist:
if args[0] == "open":
helpme = open_a_help + open_b_help
else:
helpme = "That's not a command to ask about."
bot.sendChatAction(chat_id=update.message.chat_id,
action=ChatAction.TYPING)
time.sleep(1)
bot.sendMessage(chat_id=update.message.chat_id,
text=helpme)
bot.sendChatAction(chat_id=update.message.chat_id,
action=ChatAction.TYPING)
time.sleep(1)
bot.sendMessage(chat_id=update.message.chat_id,
text=helpme)
else:
bot.sendChatAction(chat_id=update.message.chat_id,
action=ChatAction.TYPING)
time.sleep(1)
bot.sendMessage(chat_id=update.message.chat_id,
text=nojenkinsnotmaster)
else:
if jenkinsconfig == "yes":
if args_length != 0:
if args_length > 1:
for x in jenkinsmasterlist:
try:
helpme
except NameError:
helpmeplox = "Please use only one argument. A list of arguments aka commands to ask about would be:\n"
helpmeplox = helpmeplox + x + ",\n"
helpme = helpmeplox
else:
if args[0] in jenkinsmasterlist:
if args[0] == "build":
helpme = build_help
if args[0] == "changelog":
helpme = changelog_help
if args[0] == "sync":
helpme = sync_help
if args[0] == "clean":
helpme = clean_help
if args[0] == "repopick":
helpme = repopick_a_help + repopick_b_help
if args[0] == "pickopen":
helpme = pickopen_help
if args[0] == "open":
helpme = open_a_help + open_b_help
else:
helpme = "That's not a command to ask about."
bot.sendChatAction(chat_id=update.message.chat_id,
action=ChatAction.TYPING)
time.sleep(1)
bot.sendMessage(chat_id=update.message.chat_id,
text=helpme)
else:
bot.sendChatAction(chat_id=update.message.chat_id,
action=ChatAction.TYPING)
time.sleep(1)
bot.sendMessage(chat_id=update.message.chat_id,
text=jenkinsmaster)
else:
if args_length != 0:
if args_length > 1:
for x in nojenkinsmasterlist:
try:
helpme
except NameError:
helpmeplox = "Please use only one argument. A list of arguments aka commands to ask about would be:\n"
helpmeplox = helpmeplox + x + ",\n"
helpme = helpmeplox
else:
if args[0] in nojenkinsmasterlist:
if args[0] == "build":
helpme = build_help
if args[0] == "changelog":
helpme = changelog_help
if args[0] == "sync":
helpme = sync_help
if args[0] == "clean":
helpme = clean_help
if args[0] == "repopick":
helpme = repopick_a_help + repopick_b_help
if args[0] == "pickopen":
helpme = pickopen_help
if args[0] == "open":
helpme = open_a_help + open_b_help
else:
helpme = "That's not a command to ask about."
bot.sendChatAction(chat_id=update.message.chat_id,
action=ChatAction.TYPING)
time.sleep(1)
bot.sendMessage(chat_id=update.message.chat_id,
text=helpme)
else:
bot.sendChatAction(chat_id=update.message.chat_id,
action=ChatAction.TYPING)
time.sleep(1)
bot.sendMessage(chat_id=update.message.chat_id,
text=nojenkinsmaster)
def link(bot, update, args):
bot.sendChatAction(chat_id=update.message.chat_id,
action=ChatAction.TYPING)
str_args = ' '.join(args)
args_length = len(args)
if str_args == "":
bot.sendMessage(chat_id=update.message.chat_id,
text="You must provide change numbers to get a link to each change\n e.g. /link 99 123 345",
parse_mode="Markdown")
else:
for i in range(args_length):
try:
link
except NameError:
link = ""
link = link + args[i] + " - " + protocol + "://" + gerriturl + "/#/c/" + args[i] + "/" + "\n"
bot.sendMessage(chat_id=update.message.chat_id,
text=link)
def openchanges(bot, update, args):
bot.sendChatAction(chat_id=update.message.chat_id,
action=ChatAction.TYPING)
curl = "rm open.json && curl -H 'Accept-Type: application/json' " + protocol + "://" + gerrituser + "@" + gerriturl + "/changes/?q=status:open | sed '1d' > open.json"
command = subprocess.Popen(curl, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()
with open('open.json', encoding='utf-8') as data_file:
data = json.load(data_file)
dict_length = len(data)
str_args = ' '.join(args)
args_length = len(args)
if str_args != "":
for i in range(dict_length):
try:
openc
except NameError:
openc = ""
if str(data[i]['project']) in args:
openc = openc + "\n" + "<a href=" + '"' + protocol + "://" + gerriturl + "/#/c/" + str(data[i]['_number']) + "/" + '"' + ">" + html.escape(str(data[i]['_number'])) + "</a>" + html.escape(" - " + str(data[i]['subject']))
print(openc)
for i in range(dict_length):
try:
cnum
except NameError:
cnum = "/repopick"
if str(data[i]['project']) in args:
cnum = cnum + " " + str(data[i]['_number'])
else:
for i in range(dict_length):
try:
openc
except NameError:
openc = ""
openc = openc + "\n" + "<a href=" + '"' + protocol + "://" + gerriturl + "/#/c/" + str(data[i]['_number']) + "/" + '"' + ">" + html.escape(str(data[i]['_number'])) + "</a>" + html.escape(" - " + str(data[i]['subject']))
for i in range(dict_length):
try:
cnum
except NameError:
cnum = "/repopick"
cnum = cnum + " " + str(data[i]['_number'])
print(openc)
print(cnum)
if len(openc) > 4000:
msg = ""
openc = openc.splitlines()
for line in openc:
if type(msg) is not list:
if len(msg + line + "\n") < 4000:
msg += line + "\n"
else:
msg2 = line + "\n"
msg = [msg, msg2]
else:
if len(msg[-1] + line + "\n") < 4000:
msg[-1] = msg[-1] + line + "\n"
else:
msg2 = line + "\n"
msg.append(msg2)
openc = msg
if update.message.from_user.id == int(config['ADMIN']['id']) and update.message.chat.type == "private":
if type(openc) is not list:
bot.sendMessage(chat_id=update.message.chat_id,
text=openc,
parse_mode="HTML")
else:
for msg in openc:
bot.sendMessage(chat_id=update.message.chat_id,
text=msg,
parse_mode="HTML")
bot.sendMessage(chat_id=update.message.chat_id,
text=cnum,
parse_mode="Markdown")
else:
if openc is not list:
bot.sendMessage(chat_id=update.message.chat_id,
text=openc,
parse_mode="HTML")
else:
for msg in openc:
bot.sendMessage(chat_id=update.message.chat_id,
text=msg,
parse_mode="HTML")
if jenkinsconfig == "yes":
def pickopen(bot, update):
if update.message.from_user.id == int(config['ADMIN']['id']):
bot.sendChatAction(chat_id=update.message.chat_id,
action=ChatAction.TYPING)
curl = "rm open.json && curl -H 'Accept-Type: application/json' " + protocol + "://" + gerrituser + "@" + gerriturl + "/changes/?q=status:open | sed '1d' > open.json"
command = subprocess.Popen(curl, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()
with open('open.json', encoding='utf-8') as data_file:
data = json.load(data_file)
dict_length = len(data)
for i in range(dict_length):
try:
cnumbers
except NameError:
cnumbers = ""
cnumbers = cnumbers + " " + str(data[i]['_number'])
print(cnumbers)
text = "I will pick all open changes: " + cnumbers
bot.sendMessage(chat_id=update.message.chat_id,
text=text,
parse_mode="Markdown")
global rpick
cnumbers.replace(" ", "%20")
cnumbers_url = cnumbers.replace(" ", "%20")
rpick = cnumbers_url
def choosebuild(bot, update):
if update.message.from_user.id == int(config['ADMIN']['id']):
keyboard = [[InlineKeyboardButton("Without Paramaters", callback_data='build')],
[InlineKeyboardButton("With Parameters", callback_data='buildWithParameters')]]
reply_markup = InlineKeyboardMarkup(keyboard)
update.message.reply_text('Please choose a build style:', reply_markup=reply_markup)
def sync(bot, update):
if update.message.from_user.id == int(config['ADMIN']['id']):
keyboard = [[InlineKeyboardButton("YES", callback_data='syncon')],
[InlineKeyboardButton("NO", callback_data='syncoff')]]
reply_markup = InlineKeyboardMarkup(keyboard)
update.message.reply_text('Would you like to sync on a new build?:', reply_markup=reply_markup)
def reset(bot, update):
if update.message.from_user.id == int(config['ADMIN']['id']):
keyboard = [[InlineKeyboardButton("YES", callback_data='reseton')],
[InlineKeyboardButton("NO", callback_data='resetoff')]]
reply_markup = InlineKeyboardMarkup(keyboard)
update.message.reply_text('Would you like to reporeset?:', reply_markup=reply_markup)
def clean(bot, update):
if update.message.from_user.id == int(config['ADMIN']['id']):
keyboard = [[InlineKeyboardButton("YES", callback_data='cleanon')],
[InlineKeyboardButton("NO", callback_data='cleanoff')]]
reply_markup = InlineKeyboardMarkup(keyboard)
update.message.reply_text('Would you like to clean on a new build?:', reply_markup=reply_markup)
def setrelease(bot, update):
if update.message.from_user.id == int(config['ADMIN']['id']):
keyboard = [[InlineKeyboardButton("YES", callback_data='releaseon')],
[InlineKeyboardButton("NO", callback_data='releaseoff')]]
reply_markup = InlineKeyboardMarkup(keyboard)
update.message.reply_text('Would you like to do a release?', reply_markup=reply_markup)
def buildwithparams(bot, update, query):
query = update.callback_query
bot.sendMessage(chat_id=query.message.chat_id,
text="You have selected the 'buildWithParameters option, this will include a custom changelog with your build, and will specify whether to sync & clean or not",
parse_mode="Markdown")
user_id = update.callback_query.from_user.id
command_string = jenkins + "/job/" + job + "/buildWithParameters?token=" + token + "&changelog=" + cg + "&SYNC=" + syncparam + "&CLEAN=" + cleanparam + "&repopicks=" + rpick + "&REPORESET=" + reporeset + "&RELEASE=" + release
command = "curl --user " + user + ":" + password + " " + "'" + command_string + "'"
print (command)
if user_id == int(config['ADMIN']['id']):
bot.sendChatAction(chat_id=query.message.chat_id,
action=ChatAction.TYPING)
output = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
output = output.stdout.read().decode('utf-8')
output = '`{0}`'.format(output)
bot.sendMessage(chat_id=query.message.chat_id,
text=output,
parse_mode="Markdown")
def buildwithoutparams(bot, update, query):
user_id = update.callback_query.from_user.id
command_string = jenkins + "/job/" + job + "/buildWithParameters?token=" + token
command = "curl --user " + user + ":" + password + " " + "'" + command_string + "'"
print (command)
if user_id == int(config['ADMIN']['id']):
bot.sendChatAction(chat_id=query.message.chat_id,
action=ChatAction.TYPING)
output = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
output = output.stdout.read().decode('utf-8')
output = '`{0}`'.format(output)
bot.sendMessage(chat_id=query.message.chat_id,
text=output, parse_mode="Markdown")
def changelog(bot, update, args):
if update.message.from_user.id == int(config['ADMIN']['id']):
global cg
user = update.message.from_user
str_args = ' '.join(args)
if str_args != "":
update.message.reply_text('Changelog updated: ' + "'" + str_args + "'")
cgs = '%20'.join(args)
cg = cgs
print ("Changelog set to " + "'" + cg + "'")
else:
bot.sendMessage(chat_id=update.message.chat_id,
text="You cannot provide an empty changelog.",
parse_mode="Markdown")
def repopick(bot, update, args):
if update.message.from_user.id == int(config['ADMIN']['id']):
global rpick
global repopickstatus
user = update.message.from_user
str_args = ' '.join(args)
if str_args != "":
update.message.reply_text('I will pick changes: ' + "'" + str_args + "'")
rpicks = '%20'.join(args)
rpick = rpicks
repopickstatus = "true"
print ("Repopick set to" + "'" + rpick + "'")
else:
keyboard = [[InlineKeyboardButton("ON", callback_data='repopickon')],
[InlineKeyboardButton("OFF", callback_data='repopickoff')]]
reply_markup = InlineKeyboardMarkup(keyboard)
update.message.reply_text('Turn repopick ON or OFF:', reply_markup=reply_markup)
def button(bot, update, direct=True):
user_id = update.callback_query.from_user.id
if user_id == int(config['ADMIN']['id']):
query = update.callback_query
selected_button = query.data
global cleanparam
global syncparam
global repopickstatus
global reporeset
global release
if selected_button == 'buildWithParameters':
bot.editMessageText(text="Selected option: With Paramaters",
chat_id=query.message.chat_id,
message_id=query.message.message_id)
buildwithparams(bot, update, query)
if selected_button == 'build':
bot.editMessageText(text="Selected option: Without Paramaters",
chat_id=query.message.chat_id,
message_id=query.message.message_id)
buildwithoutparams(bot, update, query)
if selected_button == 'syncon':
bot.editMessageText(text="Sync set to true",
chat_id=query.message.chat_id,
message_id=query.message.message_id)
syncparam = "true"
if selected_button == 'syncoff':
bot.editMessageText(text="Sync set to false",
chat_id=query.message.chat_id,
message_id=query.message.message_id)
syncparam = "false"
if selected_button == 'cleanon':
bot.editMessageText(text="Clean set to true",
chat_id=query.message.chat_id,
message_id=query.message.message_id)
cleanparam = "true"
if selected_button == 'cleanoff':
bot.editMessageText(text="Clean set to false",
chat_id=query.message.chat_id,
message_id=query.message.message_id)
cleanparam = "false"
if selected_button == 'repopickon':
bot.editMessageText(text="Repopick set to ON",
chat_id=query.message.chat_id,
message_id=query.message.message_id)
repopickstatus = "true"
if selected_button == 'repopickoff':
bot.editMessageText(text="Repopick set to OFF",
chat_id=query.message.chat_id,
message_id=query.message.message_id)
repopickstatus = "false"
if selected_button == 'reseton':
bot.editMessageText(text="Reporeset set to ON",
chat_id=query.message.chat_id,
message_id=query.message.message_id)
reporeset = "true"
if selected_button == 'resetoff':
bot.editMessageText(text="Reporeset set to OFF",
chat_id=query.message.chat_id,
message_id=query.message.message_id)
reporeset = "false"
if selected_button == 'releaseon':
bot.editMessageText(text="Release set to ON",
chat_id=query.message.chat_id,
message_id=query.message.message_id)
release = "true"
if selected_button == 'releaseoff':
bot.editMessageText(text="Release set to OFF",
chat_id=query.message.chat_id,
message_id=query.message.message_id)
release = "false"
return False
def inlinequery(bot, update):
query = update.inline_query.query
o = execute(query, update, direct=False)
results = list()
results.append(InlineQueryResultArticle(id=uuid4(),
title=query,
description=o,
input_message_content=InputTextMessageContent(
'*{0}*\n\n{1}'.format(query, o),
parse_mode="Markdown")))
bot.answerInlineQuery(update.inline_query.id, results=results, cache_time=10)
if jenkinsconfig == "yes":
pickopen_handler = CommandHandler('pickopen', pickopen)
sync_handler = CommandHandler('sync', sync)
clean_handler = CommandHandler('clean', clean)
release_handler = CommandHandler('release', setrelease)
build_handler = CommandHandler('build', choosebuild)
repopick_handler = CommandHandler('repopick', repopick, pass_args=True)
changelog_handler = CommandHandler('changelog', changelog, pass_args=True)
reset_handler = CommandHandler('reset', reset)
start_handler = CommandHandler('start', start)
open_handler = CommandHandler('open', openchanges, pass_args=True)
help_handler = CommandHandler('help', help_message, pass_args=True)
link_handler = CommandHandler('link', link, pass_args=True)
if jenkinsconfig == "yes":
dispatcher.add_handler(pickopen_handler)
dispatcher.add_handler(sync_handler)
dispatcher.add_handler(clean_handler)
dispatcher.add_handler(release_handler)
dispatcher.add_handler(build_handler)
dispatcher.add_handler(repopick_handler)
dispatcher.add_handler(changelog_handler)
dispatcher.add_handler(reset_handler)
dispatcher.add_handler(start_handler)
dispatcher.add_handler(open_handler)
dispatcher.add_handler(help_handler)
dispatcher.add_handler(link_handler)
dispatcher.add_handler(CallbackQueryHandler(button))
dispatcher.add_handler(InlineQueryHandler(inlinequery))
dispatcher.add_error_handler(error)
updater.start_polling()
updater.idle()