Exemplo n.º 1
0
func (c *Connection) actionCb(ctx context.Context, eventCtx *guiniol.EventCtx) {
	if eventCtx.MessageEvent().Subtype == "bot_message" {
		return
	}

	name, m := matcher(eventCtx)
	if name != eventCtx.UserName() && name != eventCtx.UserId() {
		return
	}

	e := newEvent(ctx, eventCtx, m)

	if action, ok := c.actionMap[e.Command().Name()]; ok {
		if err := action.fn(e); err != nil {
			e.Reply(err.Error())
		}
	} else {
		e.Reply("???")
	}
}