(ctx *zero.Ctx)
| 129 | } |
| 130 | |
| 131 | func getPara(ctx *zero.Ctx) bool { |
| 132 | next := zero.NewFutureEvent("message", 999, false, ctx.CheckSession()) |
| 133 | recv, cancel := next.Repeat() |
| 134 | i := 0 |
| 135 | paras := [2]int{} |
| 136 | ctx.SendChain(message.Text("请输入投票模式序号\n1. 可重复投票\n2. 不可重复投票")) |
| 137 | for { |
| 138 | select { |
| 139 | case <-time.After(time.Second * 120): |
| 140 | ctx.SendChain(message.Text("未输入,退出投票")) |
| 141 | cancel() |
| 142 | return false |
| 143 | case c := <-recv: |
| 144 | msg := c.Event.Message.ExtractPlainText() |
| 145 | num, err := strconv.Atoi(msg) |
| 146 | if err != nil { |
| 147 | ctx.SendChain(message.Text("请输入数字!")) |
| 148 | continue |
| 149 | } |
| 150 | switch i { |
| 151 | case 0: |
| 152 | if num <= 0 || num > 2 { |
| 153 | ctx.SendChain(message.Text("投票模式非法!")) |
| 154 | continue |
| 155 | } |
| 156 | paras[0] = num |
| 157 | ctx.SendChain(message.Text("请输入投票时间(单位秒,至少3秒)")) |
| 158 | case 1: |
| 159 | if num < 3 { |
| 160 | ctx.SendChain(message.Text("投票时间非法!")) |
| 161 | continue |
| 162 | } |
| 163 | cancel() |
| 164 | paras[1] = num |
| 165 | ctx.State["vote_paras"] = paras |
| 166 | return true |
| 167 | } |
| 168 | i++ |
| 169 | } |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | func rankByVote(voteMap map[int]int) pairlist { |
| 174 | pl := make(pairlist, len(voteMap)) |
nothing calls this directly
no outgoing calls
no test coverage detected