(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag)
| 297 | } |
| 298 | |
| 299 | func (m *MudmailModule) mudmailCommand(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag) (bool, error) { |
| 300 | |
| 301 | cmdPrompt, isNew := user.StartPrompt(`mudmail`, rest) |
| 302 | if isNew { |
| 303 | user.SendText(fmt.Sprintf(`Starting a new mud mail...%s`, term.CRLFStr)) |
| 304 | } |
| 305 | |
| 306 | msg := Message{ |
| 307 | DateSent: time.Now(), |
| 308 | } |
| 309 | |
| 310 | question := cmdPrompt.Ask(`From name?`, []string{}) |
| 311 | if !question.Done { |
| 312 | return true, nil |
| 313 | } |
| 314 | |
| 315 | if question.Response == `` { |
| 316 | user.SendText(`Some name must be provided.`) |
| 317 | question.RejectResponse() |
| 318 | return true, nil |
| 319 | } |
| 320 | |
| 321 | msg.FromName = question.Response |
| 322 | |
| 323 | question = cmdPrompt.Ask(`Message?`, []string{}) |
| 324 | if !question.Done { |
| 325 | return true, nil |
| 326 | } |
| 327 | |
| 328 | if question.Response == `` { |
| 329 | user.ClearPrompt() |
| 330 | return true, nil |
| 331 | } |
| 332 | |
| 333 | msg.Body = question.Response |
| 334 | |
| 335 | question = cmdPrompt.Ask(`Attach how much gold?`, []string{}) |
| 336 | if !question.Done { |
| 337 | return true, nil |
| 338 | } |
| 339 | |
| 340 | msg.Gold, _ = strconv.Atoi(question.Response) |
| 341 | |
| 342 | question = cmdPrompt.Ask(`Item name (or "none") to attach from your backpack?`, []string{}) |
| 343 | if !question.Done { |
| 344 | return true, nil |
| 345 | } |
| 346 | |
| 347 | if question.Response != `none` { |
| 348 | if itemAttached, found := user.Character.FindInBackpack(question.Response); found { |
| 349 | msg.Item = &itemAttached |
| 350 | } else { |
| 351 | user.SendText(`Could not find item: ` + question.Response) |
| 352 | question.RejectResponse() |
| 353 | return true, nil |
| 354 | } |
| 355 | } |
| 356 |
nothing calls this directly
no test coverage detected