MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / mudmailCommand

Method mudmailCommand

modules/mudmail/mudmail.go:299–400  ·  view source on GitHub ↗
(rest string, user *users.UserRecord, room *rooms.Room, flags events.EventFlag)

Source from the content-addressed store, hash-verified

297}
298
299func (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

Callers

nothing calls this directly

Calls 12

saveMethod · 0.95
loadMethod · 0.95
ProcessFunction · 0.92
GetAllActiveUsersFunction · 0.92
SearchOfflineUsersFunction · 0.92
StartPromptMethod · 0.80
AskMethod · 0.80
RejectResponseMethod · 0.80
ClearPromptMethod · 0.80
SendTextMethod · 0.45
FindInBackpackMethod · 0.45
CommandMethod · 0.45

Tested by

no test coverage detected