Giter Site home page Giter Site logo

hal's Introduction

HAL

Unmaintained. Sorry :(

Hal is a chat bot framework written in the Go programming language.

Getting started

"Good morning, Dr. Chandra. This is HAL. I'm ready for my first lesson."

Hal is Go all the way down, and uses standard packages wherever possible. For an idea of how you can use it, look at a simple example, or a more complex example. Please see below for additional resources.

Resources

Is it any good?

Probably not.

License

Copyright 2014 Applied Awesome LLC.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

hal's People

Contributors

danryan avatar mvrilo avatar onbjerg avatar yosida95 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

hal's Issues

Flat file store

Would be neat to have some sort of persistence without using an external service. We could store the key/values in JSON or YML format in a single file somewhere.

Pass the *regexp.Regexp to handlers?

Rather than just passing the string matches, it might be nice to pass the full regexp object, this would make it possible to use named captures, would would be convenient for more complicated matches. Obviously this breaks the handlers, so it's a big deal.

question about the hook url's (and also a point about client.PostForm() error processing)

Hey, one more (hopefully) question.. I have stuff pretty much setup using the hubot integration, but I'm not getting any replies from hal.

I forked hal and added some additional debugging and found two things:

First, Hal was using whitelist behavior by default, so I had to set HAL_SLACK_CHANNEL_MODE=blacklist, which, I thought I'd mention as a new user because this wasn't documented very well. (I'd be happy to PR you some documentation if there's an easy way to do that)

Second, adding debugging to SendHTTP I see that my handler replies are, in fact, exiting hal, and they look pretty much like what I'd expect:

2014-12-02T23:01:45.421916+00:00 app[web.1]: 2014-12-02T23:01:45Z [hal] DEBUG: u is: https://hustlebotdev.slack.com/services/hooks/incoming-webhook?token=XXXXX
2014-12-02T23:01:45.421981+00:00 app[web.1]: 2014-12-02T23:01:45Z [hal] DEBUG: payload is: {"channel":"XXXX","username":"bob","text":":arrow_up: you complete me :arrow_up:"}

But they're being rejected by Slack. Transforming this into a CURL command like so:

curl -k -X POST --data-urlencode 'payload={"channel":"XXXX","username":"bob","text":":arrow_up: you complete me :arrow_up:"}' https://hustlebotdev.slack.com/services/hooks/incoming-webhook?token=XXXXX

and sending this manually, I get the following response from slack: "No hooks"

So my first comment is, It'd be awesome if I could have gotten the 'no hooks' error back from hal's client.PostForm() call instead of having to fork, change namespaces, add debugging, and etc..

and secondly, I'm wondering if you have any notion of why that post didn't work. No Hooks? I obviously have the hubot integration turned on.. is hal trying to post to an out of date hook url?

Thanks for making this and helpin out a newb!

Can't start simple example (examples/simple/main.go)

Running main.go (with deps installed) gives me the following:

bot|โ‡’ go run main.go
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x20 pc=0x124521]

goroutine 1 [running]:
panic(0x384aa0, 0xc82000a0c0)
    /usr/local/Cellar/go/1.6.2/libexec/src/runtime/panic.go:481 +0x3e6
github.com/broadway33/bot/vendor/github.com/Sirupsen/logrus.(*Entry).Reader(0xc820012700, 0xc83448c104, 0x0, 0x0)
    /Users/onbjerg/Go/src/github.com/broadway33/bot/vendor/github.com/Sirupsen/logrus/entry.go:44 +0x61
github.com/broadway33/bot/vendor/github.com/Sirupsen/logrus.Entry.log(0xc820012580, 0xc820016fc0, 0x0, 0x0, 0x0, 0xc82000b100, 0x0, 0x0, 0x4, 0xc82000b180, ...)
    /Users/onbjerg/Go/src/github.com/broadway33/bot/vendor/github.com/Sirupsen/logrus/entry.go:94 +0x296
github.com/broadway33/bot/vendor/github.com/Sirupsen/logrus.(*Entry).Info(0xc820051ce8, 0xc820051e10, 0x1, 0x1)
    /Users/onbjerg/Go/src/github.com/broadway33/bot/vendor/github.com/Sirupsen/logrus/entry.go:129 +0x8c
github.com/broadway33/bot/vendor/github.com/Sirupsen/logrus.(*Logger).Info(0xc820012580, 0xc820051e10, 0x1, 0x1)
    /Users/onbjerg/Go/src/github.com/broadway33/bot/vendor/github.com/Sirupsen/logrus/logger.go:128 +0xe7
github.com/broadway33/bot/vendor/github.com/danryan/hal.(*Robot).Run(0xc820054070, 0x0, 0x0)
    /Users/onbjerg/Go/src/github.com/broadway33/bot/vendor/github.com/danryan/hal/robot.go:94 +0x126
main.run(0xc820000180)
    /Users/onbjerg/Go/src/github.com/broadway33/bot/main.go:31 +0x21f
main.main()
    /Users/onbjerg/Go/src/github.com/broadway33/bot/main.go:40 +0x18
exit status 2
godep: go exit status 1

Seems like the error starts when the logger is used in robot.go at line 94. Can confirm that using the logger anywhere will give a similar error (hal.Logger).

Is this even maintained?

It seems rather sporadic whether or not the maintainer is available. Maybe adding a contributor would improve the project?

Replace odd message passing system with proper channel usage

An incoming message is received by the adapter, then passed to the robot, then copied to each registered handler (as a Response), then finally the response passes a new Message back to the adapter via the robot. That's a long path for a message to travel. An error has a similarly long path to bubble back up to the surface.

For example:

// Receive forwards a message to the robot (from shell_adapter.go)
func (a *ShellAdapter) Receive(msg *Message) error {
    a.Robot.Receive(msg)
    return nil
}

// Receive dispatches messages to our handlers (from robot.go)
func (robot *Robot) Receive(msg *Message) error {
    for _, handler := range robot.handlers {
        response := NewResponse(robot, msg)
        err := handler.Handle(response)
        //... snip ...
    }
    return nil
}

// Handle passes the response to the l.Handler func (from listener.go)
func (l *Listener) Handle(res *Response) error {
    // ... snip ...
    if err := l.Handler(res); err != nil {
        return err
    }
    return nil
}

// Assuming the above l.Handler func is this:
 func(res *hal.Response) error {
    return res.Send("PONG")
})

// Send a response back to the adapter (from response.go)
func (response *Response) Send(strings ...string) error {
    if err := response.Robot.Adapter.Send(response, strings...); err != nil {
        response.Logger.Error(err)
        return err
    }
    return nil
}

// Send sends a regular response (from shell_adapter.go)
func (a *ShellAdapter) Send(res *Response, strings ...string) error {
    for _, str := range strings {
        err := a.writeString(str)
        // ... snip ...
    }
    return nil
}

having some trouble with the slack adapter ignoring HAL_NAME

Hi this is awesome, and maybe I'm doing it wrong but...

I'm setting:

export HAL_ADAPTER='slack'
export HAL_NAME='hustlebot'
export HAL_SLACK_IRC_ENABLED='1'
export HAL_SLACK_IRC_PASSWORD='theactualpassword'
export HAL_SLACK_TEAM='theactualteam'
export HAL_SLACK_TOKEN='theactualtoken'

and Hal is starting with:

->./hustlebot
(*slack.config)(0xc2080605a0)({
Token: (string) (len=24) "theactualtoken",
Team: (string) (len=12) "theactualteam",
Channels: (string) "",
Mode: (string) "",
Botname: (string) (len=3) "hal",
IconEmoji: (string) "",
IrcEnabled: (bool) true,
IrcPassword: (string) (len=33) "theactualpassword",
ResponseMethod: (string) (len=4) "http",
ChannelMode: (string) ""
})
2014-11-30T21:27:16-06:00 [hal] INFO: starting robot
2014/11/30 21:27:16 Connected to hustlebotdev.irc.slack.com:6667 (23.21.77.76:6667)
2014/11/30 21:27:22 Error, disconnected: EOF
2014/11/30 21:27:22 Connected to hustlebotdev.irc.slack.com:6667 (23.21.77.76:6667)
2014/11/30 21:27:22 Error, disconnected: EOF
2014/11/30 21:27:22 Connected to hustlebotdev.irc.slack.com:6667 (23.21.77.76:6667)
2014/11/30 21:27:22 Error, disconnected: EOF

The shell adapter correctly honors HAL_NAME, but I'm assuming the irc connection is failing because hal is ignoring my HAL_NAME variable in the slack adapter and trying to connect with username hal?

I'll probably try to track down why this is actually happening but thought I'd send this in case I'm doing something obviously silly and you can save me some time. Thanks.

Dependency on go-logging breaking on go 1.4

go-logging uses a C function to get thread IDs that cannot be ported to go 1.4 (converting to C.go fails when trying to use runtime.h, and is trying to do something pretty dubious anyway). go-logging pull in another library from the same developer. It's probaby worth dropping it completely, since it's not really a huge win for all the extra external code.

Multi-line messages

I can't seem to send a message containing newlines, with either \r\n or a plain \n. Sending stuff one line at a time can be a bit noisy (this is using slack + irc)

Leverage Lua for simple actions

First - thanks for making it. 100% less coffeescript is welcome, and this is just the right opportunity to get me motivated to learn GO.

Now for the issue itself -- If you haven't seen it, you should take a look at Heka. It's obviously an entirely different tool from this, but they have done some incredible work with integrating Lua. By leveraging Lua's JIT strengths, you can customize it's processing on the fly by pushing lua modules into it, with great protections against those modules bringing down the whole system.

Integrating a similar concept here would be really powerful. Is that something you're open to for this project, or do you envision it as staying 100% Go?

Interesting behavior in examples

Hi,

I am trying the examples on a Windows machine with go version 1.3
Examples work fine but some of the listeners are not working properly.

For example in simple example ping is returning response PONG but open the pod bay doors returns nothing and not giving any error though.

In complex example foo and open the pod bay doors commands are not returning any response to shell

Why do you think this occurs? I think there is problem in hal.Response method but I will look into it.

non-response messages

I can't quite work out the right way to do this, but I'd like a handler to be able to generate messages that are not in response to incoming messages, probably from a go routine that is watching some external service.

Can I send messages without receiving messages?

I want to send messages via hal without receiving messages from room members, but hal seems on assumption that messages sent from hal are response of received message.

I propose using Envelope instead of *Response on first argument of Adapter interfaces' Send, Emote, Reply, Topic, Play method and add same name methods to Robot as shortcut.

If you accept this proposal, I will work for this issue and send pull request.

Help output

For example, hal help should print out all handlers that have help or usage information. At present there is no way for a user to know exactly what their bot will respond to without looking at the code.

add helpers for working with special adapter formatting

For example, when using slack, one can customize how the message is presented to the chat client (formatting, tables, icon, etc.) Would be a nice thing to provide helpers for objects and functions so folks don't have to.

PM to bot using slack + irc responds incorrectly

Hi,
The bot does not reply to PMs if using the slack + irc connectivity. This appears to be because of line 68 of slack/irc.go, the destination room of the original message is the bot name (e.g. "hal"), but, in the case of a direct message to the bot, the reply should presumably go to the person that sent it.

I can look at fixing this in the next couple of days.

Build is currently failing due to missing dependency

When trying to build, go get fails due to a missing test package:

go get github.com/danryan/hal/...
package github.com/daneharrigan/hipchat
        imports github.com/thoj/go-ircevent
        imports github.com/davecgh/go-spew/spew
        imports github.com/danryan/hal/adapter/test
        imports github.com/danryan/hal/adapter/test
        imports github.com/danryan/hal/adapter/test: cannot find package "github.com/danryan/hal/adapter/test" in any of:
        /usr/local/go/src/github.com/danryan/hal/adapter/test (from $GOROOT)
        /Users/vendion/gocode/src/github.com/danryan/hal/adapter/test (from $GOPATH)

Hipchat adapter

I started on one but it's not finished. I blame XMPP... ๐Ÿ˜€

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.