forked from jiang4920/jd_seckill
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from pppscn/main
将日志同时输出到控制台和文件
- Loading branch information
Showing
11 changed files
with
177 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,16 @@ | |
# 随意填写可能导致订单无法提交等问题 | ||
eid = | ||
fp = | ||
# 自动获取eid, fp的重试次数,测试商品sku_id | ||
retry_times = 5 | ||
test_sku_id = 100016034372 | ||
# 商品id | ||
# 已经是茅台的sku_id了 | ||
sku_id = 100012043978 | ||
# 抢购数量 | ||
seckill_num = 2 | ||
# 抢购开始时间设定 2021-01-01 09:59:59 | ||
buy_time = 2021-01-01 09:59:59 | ||
# 抢购开始时间设定,格式:09:59:59,如果小于当前时间,则表示明天这个时间点开始;大于当前时间,则为今天。 | ||
buy_time = 09:59:59 | ||
# 抢购总时间,单位:分钟,默认两分钟 | ||
seckill_time = | ||
# 抢购任务数量,默认5个 | ||
|
@@ -50,4 +53,11 @@ port = | |
# 邮箱地址 [email protected] | ||
email_user = | ||
# 邮箱授权码(并不一定是邮箱密码) xxxxxxxxxxxxxxxx | ||
email_pwd = | ||
email_pwd = | ||
|
||
#钉钉机器人配置 | ||
[dingtalk] | ||
# 机器人的Webhook地址(https://oapi.dingtalk.com/robot/send?access_token=XXXXXX)的access_token | ||
access_token = | ||
# 密钥,机器人安全设置页面,加签一栏下面显示的SEC开头的字符串 | ||
secret = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package service | ||
|
||
import ( | ||
"github.com/blinkbean/dingtalk" | ||
"github.com/unknwon/goconfig" | ||
"log" | ||
) | ||
|
||
type Dingtalk struct { | ||
conf *goconfig.ConfigFile | ||
} | ||
|
||
func NewDingtalk(conf *goconfig.ConfigFile) *Dingtalk { | ||
return &Dingtalk{conf: conf} | ||
} | ||
|
||
func (this *Dingtalk) Send(title, msg string) error { | ||
cli := dingtalk.InitDingTalkWithSecret( | ||
this.conf.MustValue("dingtalk", "access_token", ""), | ||
this.conf.MustValue("dingtalk", "secret", ""), | ||
) | ||
markdown := []string{ | ||
"### " + title, | ||
"---------", | ||
msg, | ||
} | ||
err := cli.SendMarkDownMessageBySlice(title, markdown) | ||
if err != nil { | ||
log.Println(err) | ||
} else { | ||
log.Println("钉钉机器人推送成功") | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.