Code Monkey home page Code Monkey logo

Comments (3)

0xArch3r avatar 0xArch3r commented on May 26, 2024
func newMessageEvent(slacker *Slacker, evt interface{}, req *socketmode.Request) *MessageEvent {
	var me *MessageEvent

	switch ev := evt.(type) {
	case *slackevents.MessageEvent:
		me = &MessageEvent{
			Channel:         ev.Channel,
			ChannelName:     getChannelName(slacker, ev.Channel),
			User:            ev.User,
			UserName:        getUserName(slacker, ev.User),
			Text:            ev.Text,
			Data:            evt,
			Type:            ev.Type,
			TimeStamp:       ev.TimeStamp,
			ThreadTimeStamp: ev.ThreadTimeStamp,
			BotID:           ev.BotID,
		}
	case *slackevents.AppMentionEvent:
		me = &MessageEvent{
			Channel:         ev.Channel,
			ChannelName:     getChannelName(slacker, ev.Channel),
			User:            ev.User,
			UserName:        getUserName(slacker, ev.User),
			Text:            ev.Text,
			Data:            evt,
			Type:            ev.Type,
			TimeStamp:       ev.TimeStamp,
			ThreadTimeStamp: ev.ThreadTimeStamp,
			BotID:           ev.BotID,
		}
	case *slack.SlashCommand:
		me = &MessageEvent{
			Channel:     ev.ChannelID,
			ChannelName: ev.ChannelName,
			User:        ev.UserID,
			UserName:    ev.UserName,
			Text:        fmt.Sprintf("%s %s", ev.Command[1:], ev.Text),
			Data:        req,
			Type:        req.Type,
		}
	}

from slacker.

0xArch3r avatar 0xArch3r commented on May 26, 2024

I was able to work around this by changing the definition of MessageEvent to the following:

`type MessageEvent struct {
// Channel ID where the message was sent
Channel string

// ChannelName where the message was sent
ChannelName string

// User ID of the sender
User string

// UserName of the the sender
UserName string

// Text is the unalterted text of the message, as returned by Slack
Text string

// TimeStamp is the message timestamp. For events that do not support
// threading (eg. slash commands) this will be unset.
// will be left unset.
TimeStamp string

// ThreadTimeStamp is the message thread timestamp. For events that do not
// support threading (eg. slash commands) this will be unset.
ThreadTimeStamp string

// Data is the raw event data returned from slack. Using Type, you can assert
// this into a slackevents *Event struct.
Data interface{}

// Type is the type of the event, as returned by Slack. For instance,
// `app_mention` or `message`
Type string

// BotID of the bot that sent this message. If a bot did not send this
// message, this will be an empty string.
BotID string

Event interface{}

}`

This allows me to now access the original event through the botCtx.Event().Event

from slacker.

shomali11 avatar shomali11 commented on May 26, 2024

This should now be resolved in this release https://github.com/shomali11/slacker/releases/tag/v2.0.0-alpha1

from slacker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.