GithubHelp home page GithubHelp logo

go-joe / joe Goto Github PK

View Code? Open in Web Editor NEW
474.0 19.0 27.0 645 KB

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

Go 78.83% Makefile 0.56% Shell 0.34% HTML 12.30% CSS 7.96%
joe slack chat bot chatbot-framework

joe's People

Contributors

akrennmair avatar cornelk avatar dwmunster avatar fgrosse avatar jfchevrette avatar mmlb avatar robertgzr avatar severecloud avatar warmans avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

joe's Issues

Slack DM

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.

How to change default log level

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

Registering a default response when no match

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.

Possible to send a message without having Message struct?

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

Add Reactions to Messages

Summary

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.

Basic example

func DoWork(msg joe.Message) error {
  msg.React(":+1:")
  time.Sleep(1 * time.Second)
  msg.Respond("Job is done")
}

Motivation

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.

Potential Issues

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.

Edit 1

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")
}

Allow for specifying whether message is DM in `ReceiveMessageEvent`

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.

Prefix Scans for Storage Keys

Summary

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.

Basic example

for _, key := range a.store.KeysWithPrefix("joe.permissions.mymodule.") {
  ...
}

Motivation

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.

Potential Issues

  • If the prefix scan isn't optional for the Storage interface, a new release would break any third party implementations. As described above, this would not be an issue.

CLIAdapter Character read problem in win10

  • 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
  • solution

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

List support in Memory

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.

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.