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