Git Product home page Git Product logo

Comments (11)

parsley42 avatar parsley42 commented on June 14, 2024

My intention is that Gopherbot be able to support multiple protocols, so I'm trying not to make any design decisions that tie it completely to slack. I'm open, however, to protocol-specific extensions, if implemented cleanly. Also keep in mind it's designed to support multiple languages for plugins - while you primarily use Go plugins, I write plugins in Python, Ruby, PowerShell, Bash and Go - so the plugin calling convention is fairly fixed to something that works well when calling a command-line script.

Basically, the current design doesn't really support passing in a complex structure to the plugin. To support this kind of functionality in a script-friendly and protocol-agnostic way, it would mean allowing custom, protocol-specific matching functions. For instance, eventually there will be events for presence change, attachment received, etc.

I'll give this some more thought.

from gopherbot.

pasali avatar pasali commented on June 14, 2024

I understand your point. I also think that you will need this functionality at some point. Because eventually people are going to want these informations :).

from gopherbot.

parsley42 avatar parsley42 commented on June 14, 2024

Ok, I think I've addressed this for you in 69101ac, on the plugdev branch. Once I've filled out the plugin debugging code I'll merge this to master; once I've done more testing I'll go ahead and release v1.1.0, probably next week.

Your Go plugin should check bot.Protocol == bot.Slack, then use a type assertion to get the *slack.MessageEvent from bot.RawMsg. NOTE: I have not tested this AT ALL, though I intend to soon. Should be straightforward coding, but it's always possible I screwed something up. (although I've written a test suite now so I'm fairly confident I haven't screwed anything up badly)

from gopherbot.

pasali avatar pasali commented on June 14, 2024

thanks. i will give a try when i find a chance

from gopherbot.

pasali avatar pasali commented on June 14, 2024

@parsley42 MessageMatchers are not working now. When message received, it checks whether is command to bot or just text to channel

if preRegex != nil {
		matches := preRegex.FindAllStringSubmatch(messageFull, -1)
		if matches != nil && len(matches[0]) == 2 {
			isCommand = true
			message = matches[0][1]
		}
}

but preRegex is something like that ^(?i:|@?joe[:, ]\s*)(.*)$ which matches even robot was not mentioned. So below code block does not get executed. Because bot.isCommnd is true

	if !commandMatched && !waitingForReply && !bot.isCommand {
		// check for ambient message matches
		commandMatched = bot.checkPluginMatchersAndRun(false)
	}

from gopherbot.

parsley42 avatar parsley42 commented on June 14, 2024

Ouch.

Ok, I'll fix this and add tests for it, and get back with you.

from gopherbot.

parsley42 avatar parsley42 commented on June 14, 2024

Not sure what version you were using, but that was an old version of the regex, I think. In any case, older versions of Gopherbot wouldn't use MessageMatchers for DMs, but I've corrected that, as well. The new Robot object carries more info and allows this change (see the most recent commit).

So I added a test plugin that uses MessageMatchers, and added tests to the test suite - it all looks good now. Care to give it a shot with the latest snapshot / commit?

from gopherbot.

parsley42 avatar parsley42 commented on June 14, 2024

Ok, I took a little more time to look at this and found the issue - looking at your regex, I realized you hadn't configured an 'alias' for your bot. I fixed the regex generating algorithm and added tests for correct behavior when the robot has either no name or no alias.

Additionally, after thinking about it I realized the robot should check MessageMatchers if the user sends the robot a command, but it doesn't match. So, 'hello robot' and 'robot, hello robot' now both trigger the 'hello robot' MessageMatcher (unless there's a 'hello robot' command). (... and of course, my new mantra - 'I've added tests for this behavior').

All of these fixes are on master for v1.1.0-snapshot. I'm planning on fleshing out test coverage a bit more then releasing v1.1.0. Thanks for testing.

from gopherbot.

pasali avatar pasali commented on June 14, 2024

the last version you have released is OK for me now. I am done with development and its works like expected. We can close this issue by the time you release production version. Thanks for the feature.

from gopherbot.

parsley42 avatar parsley42 commented on June 14, 2024

Good to hear, thanks.

from gopherbot.

parsley42 avatar parsley42 commented on June 14, 2024

Version 1.1.0 has been released with this fix.

from gopherbot.

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.