From: qydysky Date: Sat, 7 May 2022 18:55:04 +0000 (+0800) Subject: 平均观看人数到小数点后1位 X-Git-Tag: v0.5.10~41^2~64 X-Git-Url: http://127.0.0.1:8081/?a=commitdiff_plain;h=d766ba6df07afcb4faccbd2c73b3fa040db9d577;p=bili_danmu%2F.git 平均观看人数到小数点后1位 --- diff --git a/Reply/Reply.go b/Reply/Reply.go index c094f08..81adbd7 100644 --- a/Reply/Reply.go +++ b/Reply/Reply.go @@ -321,9 +321,9 @@ func (replyF) user_toast_msg(s string) { //HeartBeat-心跳用来传递人气值 var ( - renqi_old int - watched_old int - continuity int + renqi_old int + pperm_old float64 + continuity int ) func (replyF) heartbeat(s int) { @@ -358,17 +358,20 @@ func (replyF) heartbeat(s int) { tmp = `(` + tmp + `)` } - var pperm = c.C.Watched / int(time.Since(c.C.Live_Start_Time)/time.Minute) - if watched_old != 0 { - tmp2 += `(avg: ` + strconv.Itoa(pperm) + `人/分 ` - tmp2 += strconv.Itoa(pperm-watched_old) + `)` + var pperm = float64(c.C.Watched) / float64(time.Since(c.C.Live_Start_Time)/time.Minute) + if pperm_old != 0 { + tmp2 += `(avg: ` + fmt.Sprintf("%.1f", pperm) + `人/分 ` + if pperm-pperm_old > 0 { + tmp2 += `+` + } + tmp2 += fmt.Sprintf("%.1f", pperm-pperm_old) + `)` } if renqi_old != s { fmt.Printf("\t人气:%d %s\t观看人数:%d %s\n", s, tmp, c.C.Watched, tmp2) } reply_log.Base_add(`人气`).Log_show_control(false).L(`I: `, "当前人气", s) renqi_old = s - watched_old = pperm + pperm_old = pperm } //Msg-房间特殊活动