go-joe / joe Goto Github PK
View Code? Open in Web Editor NEWA general-purpose bot library inspired by Hubot but written in Go. :robot:
Home Page: https://joe-bot.net
License: BSD 3-Clause "New" or "Revised" License
A general-purpose bot library inspired by Hubot but written in Go. :robot:
Home Page: https://joe-bot.net
License: BSD 3-Clause "New" or "Revised" License
Is there any example with Telegram? Would be cool to see a small example :)
Is there a way to message.Send DMs to users?
I'm sorry about the question but I couldn't find any reference to this in slack-adapter nor here.
Hi,
i'm just digging around how i can adjust the log level of the bot.
Maybe you can add a simple example how the log-level can be adjusted?
Thanks
I've been trying to figure out how I can make my bot respond with a helpful message when no message is matched.
Naively I've tried the following approach which results in both handlers to be executed
b.Respond("foo", b.FooHandler)
b.Respond(".*", b.HelpHandler)
Unless I'm missing something, there does not seem to be a way to register a default handler that would only be executed if no other handler matches the message.
There also does not appear to be a way to stop processing handlers after the FooHandler
is executed.
Thanks for putting together this library, I'm just starting to explore it.
I was wondering if there is a recommended method to send an arbitrary message to a channel without needing to "Respond" to a message that has come in.
My [first] use case is that I want to send a message to a channel after receiving a webhook via the http-server.
I suppose one way that I might be able to achieve this is to have the webhook handler publish a joe.ReceiveMessageEvent
event with the desired channel that I want to send
a message to, then listen for this 'silent' event emitted and respond to it. This will likely work, but it seems like quite a workaround to achieve my goal.
Any insight you can provide would be appreciated.
Thanks
Registration errors are hidden by the test bot because they are only returned if the handler is registered before the bot is started.
Many chat services (e.g. Slack, Rocket.Chat, Mattermost, etc.) offer the ability to "react" to messages with emoji. It would be nice to be able to make use of that capability.
func DoWork(msg joe.Message) error {
msg.React(":+1:")
time.Sleep(1 * time.Second)
msg.Respond("Job is done")
}
Using reactions is an easy way to acknowledge that a command has been received without cluttering up the chat with intermediate results. Simple commands could even skip output entirely and just use reactions.
Not all Adapters will be able to support reactions (e.g. CLI Adapter). A decision would be necessary for how to handle reactions in this case. My thought would be to fail silently (optionally with a logger warning) and to document that reactions are optional for adapters. An alternative would be to error if not available and to offer a capability to test if reactions are available ReactionsEnabled
or perhaps msg.ReactIfEnabled
.
Perhaps a pragmatic way to handle the absence of reactions would be a ReactOrRespond
function that would add a reaction if able, respond if not.
func DoWork(msg joe.Message) error {
msg.ReactOrRespond(":+1:", "Job started")
time.Sleep(1 * time.Second)
msg.Respond("Job is done")
}
Do you have any plans to add slack interactive message and dialogs features?
Currently, the standard joe.ReceiveMessageEvent
sent by all documented adapters does not specify whether the message is "private" (a one-on-one chat in Slack, a /msg
in IRC, etc).
This can be useful in having handlers process commands differently (e.g. allow admin-level commands in direct chats) depending on the communication mode, without having to either parse the Channel
or Data
fields (which assumes the handler knows which adapter is being used) or having to use custom events, which assume adapter support.
It would probably be useful to be able to let events also be custom scalar types.
E.g. this:
type CustomType int
Since many uses of the Storage
interface may have hierarchical keys, e.g. the permissions, it would be beneficial to have a way to iterate over keys matching a given prefix.
for _, key := range a.store.KeysWithPrefix("joe.permissions.mymodule.") {
...
}
From #28
Since we are iterating over all keys the bot knows we should expect that also non-permission keys are among them.
I suggest you update your unit test to check this is also handled correctly.
Rather than push this onto any developer who needs to interact with the permissions, we could require the Storage
interface to support prefix scans. Some storage engines may have a higher performance way of doing prefix scans and we could take advantage of that. If the storage engine does not offer it, the bot could handle the naive looping over keys itself. This removes the burden from developers to implement/test this independently.
Storage
interface, a new release would break any third party implementations. As described above, this would not be an issue.problem
the minimal examples seems don't work in win10。
as i run the examples and sent “ping” in cli there is nothing happen;
analyse
the problem is happen in CLIAdapter ;Actually two more characters were read;
line, err := r.ReadString('\n')
fmt.Printf("len:%d\n", len(line))
fmt.Printf("real line: %q\n", line)
lines <- line[:len(line)-1]
<========cmd=========>
example-bot > ping
len:6
real line: "ping\r\n"
So it's never been a match,Also will never enter the pong method
regex, _ := regexp.Compile("^(?i)ping$")
matches := regex.FindStringSubmatch("ping\r")
len(matches) == 0
i can solve it by use lines <- line[:len(line)-2]
in CLIAdapter.
I don't know if other platforms or it will have an impact on other places
I'd really like to have support for lists in Memory implementations, without having to build it up from KV considering that some of the Memory implementations have first class support (Redis). Would you want to add this concept to joe?
I'd also like to have Sets since my ultimate goal is actually a list of unique objects, and if we have List, and Set I can compose them into UniqList anyway.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.