Comments (11)
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.
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.
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.
thanks. i will give a try when i find a chance
from gopherbot.
@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.
Ouch.
Ok, I'll fix this and add tests for it, and get back with you.
from gopherbot.
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.
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.
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.
Good to hear, thanks.
from gopherbot.
Version 1.1.0 has been released with this fix.
from gopherbot.
Related Issues (20)
- Add API call for deleting long-term memories
- Create bot.Threaded() methods
- Allowing anchoring in ambient message regexes HOT 1
- Update python objects for ruby parity
- Add i(gnore) command to help/ping HOT 1
- Slack connector sends message deletions to robot HOT 1
- Update catch-all help for threads
- Run init jobs with new environment variables
- Deleting a preview from a message makes the robot re-process the message
- Allow short-term memory contexts to be shared (remove the 'user') HOT 1
- Unlisted users are being ignored in threads / AI plugin HOT 1
- Require administrators to be listed in UserRoster
- Feature: Subscribe API HOT 2
- Feature: GOPHER_ADDRMODE HOT 1
- Persist thread ephemeral memories in the brain HOT 1
- cbot.sh updates HOT 1
- Major installer updates - eliminate R/W deploy key !! HOT 1
- Allow (alias)foo instead of (bot), foo HOT 1
- Data race during build
- AI Plugin: stream out a paragraph at a time
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gopherbot.