def get_vscode_cheet(message): slack_info = SlackMessageService(API_TOKEN, message) FileService.write_log(slack_info.user_name, slack_info.user_id, slack_info.message_text) slack_info.upload_file('./upload_files/vscode_cheat.jpg') msg = '*VSCodeマスターになろうぜ!!:computer:*' message.send(msg)
def get_git_cheet(message): slack_info = SlackMessageService(API_TOKEN, message) FileService.write_log(slack_info.user_name, slack_info.user_id, slack_info.message_text) slack_info.upload_file('./upload_files/git_cheat.jpg') msg = '*SouceTree使うよりコマンド来の方がかっこよくね?:ghost:*' message.send(msg)
def create_task_ticket(message): slack_info = SlackMessageService(API_TOKEN, message) FileService.write_log(slack_info.user_name, slack_info.user_id, slack_info.message_text) jira_service = JiraService(JIRA['url'], JIRA['login_id'], JIRA['login_pass']) msg_list = slack_info.message_text.split() msg_len = len(msg_list) if msg_len == 3: kind = msg_list[1] title = msg_list[2] kind_list = kind.split(',') msg = JIRA_MSG['create_ticket'] error_msg = '' for kind in kind_list: if (kind in JIRA['ticket_kind']): summary = '【' + JIRA['ticket_kind'][kind] + '】' + title ticket = jira_service.create_tickets(JIRA['project'], JIRA['issue_type_id'], summary, slack_info.base_login_id) msg += JIRA_MSG['create_ticket_list'].format( summary=summary, url=JIRA['issue_url'] + str(ticket)) else: error_msg += JIRA_MSG['kind_error'].format(str(kind)) msg += error_msg else: msg = JIRA_MSG['help'] message.send(msg)
def get_assignee_ticket(message): slack_info = SlackMessageService(API_TOKEN, message) user_name = slack_info.user_name FileService.write_log(user_name, slack_info.user_id, slack_info.message_text) jira_service = JiraService(JIRA['url'], JIRA['login_id'], JIRA['login_pass']) msg_list = slack_info.message_text.split() msg_len = len(msg_list) user_id = slack_info.base_login_id if (msg_len > 1): user_mention = msg_list[1] if re.match(PATTERN['user_mention'], user_mention): user_mention = user_mention.lstrip('<@') user_mention = user_mention.rstrip('>') user_info = slack_info.get_user(user_mention) user_id = user_info['name'] user_name = user_info['profile']['display_name'] tickets = jira_service.get_incompleate_ticket( jira_service.get_assignee_ticket(JIRA['project'], user_id)) if len(tickets) == 0: msg = JIRA_MSG['not_assignee_ticket'].format(user_name) else: msg = JIRA_MSG['get_assignee_ticket'].format(user_name) msg += create_get_ticket_msg(jira_service, tickets) message.send(msg)
def yes_replay(message): slack_info = SlackMessageService(API_TOKEN, message) FileService.write_log(slack_info.user_name, slack_info.user_id, slack_info.message_text) yes_list = [ '頼んます~。', 'あざーす。', '君ならできる!', 'You Can Do It!!!', '素敵やん', 'よろしくっす~' ] message.send(random.choice(yes_list))
def useless_replay(message): slack_info = SlackMessageService(API_TOKEN, message) FileService.write_log(slack_info.user_name, slack_info.user_id, slack_info.message_text) quote_list = [ '人生に無駄なことは、なにひとつとしてない。', '自分のやってきたことは無駄じゃないと思いたい。', '人生に無駄なことがないのかは、僕たちには分からない。' ] message.send(random.choice(quote_list))
def oranigennkiwo_replay(message): slack_info = SlackMessageService(API_TOKEN, message) FileService.write_log(slack_info.user_name, slack_info.user_id, slack_info.message_text) yes_list = [ '君にこの言葉をささげよう\n>>>壁というのは、\nできる人にしかやってこない。\n超えられる可能性がある\n人にしかやってこない。\nだから、壁がある時は\nチャンスだと思っている。 \n\nby イチロー', '君にこの言葉をささげよう\n>>>神様は私たちに、\n成功してほしいなんて思っていません。\nただ、挑戦することを望んでいるだけよ。 \n\nby マザーテレサ', '君にこの言葉をささげよう\n>>>過去ばかり振り向いていたのではダメだ。\n自分がこれまで何をして、\nこれまでに誰だったのかを受け止めた上で、\それを捨てればいい。\n\nby スティーブ・ジョブズ', '君にこの言葉をささげよう\n>>>私は失敗したことがない。\nただ、1万通りの、\nうまく行かない方法を\n見つけただけだ。\n\nby トーマス・エジソン', '君にこの言葉をささげよう\n>>>万策尽きたと思うな。\n自ら断崖絶壁の淵にたて。\nその時はじめて新たなる風は必ず吹く。\n\nby 松下幸之助', '君にこの言葉をささげよう\n>>>太陽の光と雲ひとつない青空があって、\nそれを眺めていられるかぎり、\nどうして悲しくなれるというの?\n\nby アンネ・フランク', 'この映画全部見ればきっと元気になる!!!\nhttps://bibi-star.jp/posts/7801', ] message.send(random.choice(yes_list))
def get_report_ticket(message): slack_info = SlackMessageService(API_TOKEN, message) FileService.write_log(slack_info.user_name, slack_info.user_id, slack_info.message_text) jira_service = JiraService(JIRA['url'], JIRA['login_id'], JIRA['login_pass']) tickets = jira_service.get_incompleate_ticket( jira_service.get_report_ticket(JIRA['project'], slack_info.base_login_id)) if len(tickets) == 0: msg = JIRA_MSG['not_report_ticket'].format(slack_info.user_name) else: msg = JIRA_MSG['get_report_ticket'].format(slack_info.user_name) msg += create_get_ticket_msg(jira_service, tickets) message.send(msg)
def done_replay(message): slack_info = SlackMessageService(API_TOKEN, message) FileService.write_log(slack_info.user_name, slack_info.user_id, slack_info.message_text) done_list = ['やるやんっ', 'さすが!', '天才', 'いいね!', '僕の仕事も手伝ってw'] message.send(random.choice(done_list))
def thanks_replay(message): slack_info = SlackMessageService(API_TOKEN, message) FileService.write_log(slack_info.user_name, slack_info.user_id, slack_info.message_text) thanks_list = ['お安い御用っす', 'いつでもゆうてな!'] message.send(random.choice(thanks_list))
def get_break_time(message): slack_info = SlackMessageService(API_TOKEN, message) FileService.write_log(slack_info.user_name, slack_info.user_id, slack_info.message_text) message.send(create_break_msg())
def send_message(message): slack_info = SlackMessageService(API_TOKEN, message) FileService.write_log(slack_info.user_name, slack_info.user_id, slack_info.message_text) message.reply(DEFAULT_MSG)