Commit 787448a9 authored by gm's avatar gm

Merge branch 'master' of git.wanmeizhensuo.com:mobile/HappyKit

parents 13b3a0a6 1685dcc4
#!/Users/wangyang/.rvm/rubies/ruby-2.3.1/bin/ruby
#!/usr/bin/ruby
require 'httparty'
require "ostruct"
......@@ -25,8 +25,11 @@ end
def today
# 打开下面注释,改成某个版本开始时间,就可以调试这个版本的发邮件服务了
# return Date.parse("2019-09-17")
return Date.today
if $DEBUG
return Date.parse("2019-09-17")
else
return Date.today
end
end
def a_month_ago
......
#!/usr/bin/ruby
require 'dingbot'
TEST_BOT = "0e53adfed496676b49931ab73092ce6dc206ced89fb66852be0906b5e3dcfa75"
def ding_text(bot_id, msg)
DingBot.access_token = $DEBUG ? TEST_BOT : bot_id
DingBot.send_text(msg)
end
def ding_at_me(bot_id, msg)
DingBot.access_token = $DEBUG ? TEST_BOT : bot_id
message = DingBot::Message::Text.new(msg, ["15811315780"], false)
DingBot.send_msg(message)
end
# msg 消息文本内容
# ats 数组,["15811311111", "15811311113", "15811311112"]
def ding_at(bot_id, msg, ats)
DingBot.access_token = $DEBUG ? TEST_BOT : bot_id
message = DingBot::Message::Text.new(msg, ats, false)
DingBot.send_msg(message)
end
\ No newline at end of file
#! /Users/wangyang/.rvm/rubies/ruby-2.3.1/bin/ruby
require 'httparty'
require "ostruct"
require 'mail'
require 'dingbot'
#!/usr/bin/ruby
require File.dirname(__FILE__) + '/ding'
require File.dirname(__FILE__) + '/Confluence'
# 提前通知要过可行;当天也会提示
def ke_xing_notify()
ke_xing_event_id = "2c8733f7-938d-41e4-9706-ea01bf88ba91"
events = get_events(ke_xing_event_id)
for event in events
start = Date.parse(event.start)
puts event.title
# 还剩几天
days_left = (start - today).to_i
# cweek是日期所在的周数,所以cweek_offset则是两个时间所差周数
cweek_offset = start.cweek - today.cweek
# 只提前一天提示,要考虑跨周末的情况
......@@ -46,45 +42,19 @@ def notify_to_book_ke_xing_meeting_room()
days_left = (start - today).to_i
cweek_offset = start.cweek - today.cweek
if start == today
ding_meeting_book
ding_at_me(KEXING_BOT, "预订下一个迭代可行的会议室")
end
end
end
# PMs-更美 app 大迭代
PM_BOT = "7f105786f654bac5491b5ad808d24521e6fec5d8da8f8b6b7590c16a91a1c4fd"
# 更美大迭代技术可行小组
KEXING_BOT = "6565866a84fe1e879c06273d434152bfd7669d93153780ca34ec2792e0386c1c"
TEST_BOT = "0e53adfed496676b49931ab73092ce6dc206ced89fb66852be0906b5e3dcfa75"
def ding_msg(msg)
# ding(PM_BOT, msg)
# ding(KEXING_BOT, msg)
ding(TEST_BOT, msg)
end
def ding(bot_id, msg)
puts msg
DingBot.endpoint = 'https://oapi.dingtalk.com/robot/send'
DingBot.access_token = bot_id
message = DingBot::Message::Text.new(
"#{msg}",
[],
false
)
DingBot.send_msg(message)
ding_text(PM_BOT, msg)
ding_text(KEXING_BOT, msg)
end
def ding_meeting_book
DingBot.endpoint = 'https://oapi.dingtalk.com/robot/send'
DingBot.access_token = KEXING_BOT
message = DingBot::Message::Text.new(
"预订下一个迭代可行的会议室",
["15811315780"],
false
)
DingBot.send_msg(message)
end
login
ke_xing_notify
notify_to_book_ke_xing_meeting_room
#!/usr/bin/ruby
require File.dirname(__FILE__) + '/Confluence'
require File.dirname(__FILE__) + '/notify_release_date_by_email'
require File.dirname(__FILE__) + '/kexing_notify'
$DEBUG = true
DingBot.endpoint = 'https://oapi.dingtalk.com/robot/send'
login
notify_release_date_by_email
ke_xing_notify
notify_to_book_ke_xing_meeting_room
\ No newline at end of file
#!/usr/bin/ruby
# encoding: UTF-8
require 'httparty'
require "ostruct"
require 'mail'
require 'dingbot'
require File.dirname(__FILE__) + '/Confluence'
require File.dirname(__FILE__) + '/ding'
# 类似于“7.11开发”这样的事件名,用于对比记录邮件是否已经发送
$dev_title = ""
......@@ -98,10 +97,10 @@ def send_email()
text_part do
content_type "text/plain; charset=utf-8"
body <<-EOF
Hi,All
body <<~EOF
Hi,All
#{$submit_title}时间为#{$submit_date.to_s},请准备商店相关的物料信息(是否更换APP icon和商店海报),谢谢~
#{$submit_title}时间为#{$submit_date.to_s},请准备商店相关的物料信息(是否更换APP icon和商店海报),谢谢~
EOF
end
end
......@@ -110,37 +109,35 @@ end
# 测试 email_body 是否符合预期
def test_email_body()
puts <<-EOF
Hi,All
puts <<~EOF
Hi,All
#{$submit_title}时间为#{$submit_date.to_s},请准备商店相关的物料信息(是否更换APP icon和商店海报),谢谢~
EOF
#{$submit_title}时间为#{$submit_date.to_s},请准备商店相关的物料信息(是否更换APP icon和商店海报),谢谢~
EOF
end
login
if should_send_email_today
get_submit_info
begin
send_email
# 可以注释掉上面的 send_email方法,打开下面的test_email_body方法,单独测试
# test_email_body
def notify_release_date_by_email()
if should_send_email_today
get_submit_info
begin
if $DEBUG
test_email_body
else
send_email
end
# 邮件发送成功后,再存储数据
set_store_value(STORE_KEY, $dev_title)
# 邮件发送成功后,再存储数据
set_store_value(STORE_KEY, $dev_title)
puts "邮件已发送"
rescue Exception => e
puts "邮件发送失败"
puts e.message
DingBot.endpoint = 'https://oapi.dingtalk.com/robot/send'
DingBot.access_token = '8142e051fe21d101b7e619c179741b0502f99b66ede221e164c2c1643122378d'
message = DingBot::Message::Text.new(
"sprintEmail 迭代发版时间邮件发送失败.\n#{e.message}",
['15811315780'],
false
)
DingBot.send_msg(message)
end
puts "邮件已发送"
rescue Exception => e
puts "邮件发送失败"
puts e.message
# 客户端组
bot_id = "8142e051fe21d101b7e619c179741b0502f99b66ede221e164c2c1643122378d"
ding_at_me(bot_id,
"sprintEmail 迭代发版时间邮件发送失败.\n#{e.message}")
end
end
end
#! /bin/bash
/usr/bin/ruby $(pwd)/notify_release_date_by_email.rb
/usr/bin/ruby $(pwd)/kexing_notify.rb
#!/bin/bash
/usr/bin/ruby $(pwd)/main.rb
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment