Golang Framework for writing Slack bots

Overview

hanu - Go for Slack Bots!

Current Release MIT License Read Tutorial Code Example

The Go framework hanu is your best friend to create Slack bots! hanu uses allot for easy command and request parsing (e.g. whisper <word>) and runs fine as a Heroku worker. All you need is a Slack API token and you can create your first bot within seconds! Just have a look at the hanu-example bot or read my tutorial

Features

  • Respond to mentions
  • Respond to direct messages
  • Auto-Generated command list for help
  • Works fine as a worker on Heroku

Usage

Use the following example code or the hanu-example bot to get started.

package main

import (
	"log"
	"strings"

	"github.com/sbstjn/hanu"
)

func main() {
	slack, err := hanu.New("SLACK_BOT_API_TOKEN")

	if err != nil {
		log.Fatal(err)
	}

	Version := "0.0.1"

	slack.Command("shout <word>", func(conv hanu.ConversationInterface) {
		str, _ := conv.String("word")
		conv.Reply(strings.ToUpper(str))
	})

	slack.Command("whisper <word>", func(conv hanu.ConversationInterface) {
		str, _ := conv.String("word")
		conv.Reply(strings.ToLower(str))
	})

	slack.Command("version", func(conv hanu.ConversationInterface) {
		conv.Reply("Thanks for asking! I'm running `%s`", Version)
	})

	slack.Listen()
}

The example code above connects to Slack using SLACK_BOT_API_TOKEN as the bot's token and can respond to direct messages and mentions for the commands shout <word> , whisper <word> and version.

You don't have to care about help requests, hanu has it built in and will respond with a list of all defined commands on direct messages like this:

/msg @hanu help

Of course this works fine with mentioning you bot's username as well:

@hanu help

Slack

Use direct messages for communication:

/msg @hanu version

Or use the bot in a public channel:

@hanu version

Dependencies

Credits

Issues
  • Add a v2 client of hanu using the nlopes/slack client

    Add a v2 client of hanu using the nlopes/slack client

    This does not modify the existing client in any way, just adds a v2 package like many other go packages do. It uses the github.com/nlopes/slack package for the connections. #13 is also handled with this update.

    opened by penguinpowernz 15
  • Uploading Files to the Slack via hanu

    Uploading Files to the Slack via hanu

    Hi

    Can we upload files to the Slack via hanu(For ex: log files , or dummy artifacts) ? If we can, how ?

    Thanks,

    opened by boranx 1
  • Expose Message to bots

    Expose Message to bots

    My use case is that I want my bot to know who it's talking to and on which channel, for authorisation purposes. This PR exposes MessageInterface.User() to bots via ConversationInterface.Message(). The channel is not exposed, since that's not in the Message interface.

    Any thoughts?

    opened by wolverian 1
  • Formatting response

    Formatting response

    Is it possible to use conv.Reply to send more elaborately formatted messages, or is plain text the only option?

    opened by jaxxstorm 1
  • Limited number of words in a message

    Limited number of words in a message

    I want to do same thing in every message. If it is 1 word, 2 words, 3 words. I use the functions slack.Command("word",func(conv hanu.ConversationInterface), slack.Command("word" "word2", func(conv hanu.ConversationInterface) slack.Command("word" "word2" "word3", func(conv hanu.ConversationInterface) respectivelty. It continues for every number of words in a message. What is the shortest way of do this? Thanks Edit: the words are in the < >

    opened by latifuluman 1
  • Increase test coverage

    Increase test coverage

    opened by sbstjn 0
  • Create response for help command

    Create response for help command

    Let hanu respond to @hanu help / help with an automatic generated text based on all registered commands.

    opened by sbstjn 0
  • Update README.md

    Update README.md

    opened by sbstjn 0
  • Use CircleCI

    Use CircleCI

    null

    opened by sbstjn 0
  • v2.0.0 fixes and improvements

    v2.0.0 fixes and improvements

    This puts the changes from #14 into the master branch and tags it with 2.0.0 so it can work with go modules.

    opened by penguinpowernz 0
  • Handle unknown commands

    Handle unknown commands

    Hi,

    Thanks for your great work.

    I'm asking for a way to handle unknown commands. My bot is handling 2 commands as the following.

    slack.Command("shout <word>", func(conv hanu.ConversationInterface) {
    	str, _ := conv.String("word")
    	fmt.Println(conv.Message().Text())
    	conv.Reply(strings.ToUpper(str))
    })
    
    slack.Command("your version", func(conv hanu.ConversationInterface) {
    	conv.Reply("Thanks for asking! I'm running `%s`", "323")
    })
    

    I want the bot to reply a message such as I don't understand your command when someone tries to send it an undefined command. Is it possible? Something like:

    slack.UnknownCommand(func(conv hanu.ConversationInterface) {
    	conv.Reply("Thanks for asking! But I don't understand your command.")
    })
    
    opened by ReeganExE 2
Releases(v0.1.0)
Owner
Sebastian Müller
Smash Patriarchy & Fight Fascism! AWS Serverless Hero, Certified AWS Solutions Architect, and GraphQL Expert.
Sebastian Müller
REPLbot is a Slack bot that allows you to control a REPL from within Slack.

?? REPLbot REPLbot is a Slack bot that allows you to control a REPL from within Slack. It comes with a few REPLs (Go ?? , Java, NodeJS, PHP, Python, R

Philipp C. Heckel 152 Nov 26, 2021
Automated Trader (at). Framework for building trading bots.

Automated Trader (at) Purpose: Framework for building automated trading strategies in three steps: Build your own strategy. Verify it with the backtes

Simon Klinkert 3 Dec 3, 2021
its the same idea as bruh-bot, but with golang, and add more bots

bruh-bot but more powerful! requirements python go you can used on mac and linux the idea its really simple, can make a lot of bots with the same task

pai 12 Jul 7, 2021
Slack Bot Framework

slacker Built on top of the Slack API github.com/slack-go/slack with the idea to simplify the Real-Time Messaging feature to easily create Slack Bots,

Raed Shomali 571 Nov 17, 2021
Slack bot core/framework written in Go with support for reactions to message updates/deletes

Overview Requirements Features Demo The Name Concepts Create Your Own Slackscot Assembling the Parts and Bringing Your slackscot to Life Configuration

Alexandre Normand 48 Nov 30, 2021
A Telegram Repo For Bots Under Maintenance Which Gives Faster Response To Users

Maintenance Bot A Telegram Repo For Bots Under Maintenance Which Gives Faster Response To Users Requests » Report a Bug | Request Feature Table of Con

HEIMAN PICTURES 7 Oct 10, 2021
A set of mastodon (fediverse) bots written in Go

Mastodon Bot Bots Hagh Hagh reblogs certain toots to itself creating a Hagh page. Users from local instance are able to make a toot hagh. Setup Have g

Ebrahim 4 Sep 17, 2021
A fast responsive, machine learning, conversational dialog engine for creating chat bots, written in Go.

chatbot English | 简体中文 项目说明 chatbot 是一个通过已知对话数据集快速生成回答的 Go 问答引擎。比 ChatterBot 快非常多,我们在1.2亿对话上的对比结果是:ChatterBot 回答需要21秒,chatbot 只需要18毫秒。 bot 问答引擎 cli tr

Kevin Wan 237 Nov 30, 2021
HellPot is a portal to endless suffering meant to punish unruly HTTP bots.

HellPot Summary HellPot is an endless honeypot based on Heffalump that sends unruly HTTP bots to hell. Notably it implements a toml configuration file

kayos 98 Dec 1, 2021
Golang bot that connects to slack using Socketclient to read and write messages.

?? (not)simple go project ?? Golang bot that connects to slack using Socketclient to read and write messages. ?? Use ?? @SquidBot : Mentions your name

Malin J. 0 Oct 8, 2021
IRC, Slack, Telegram and RocketChat bot written in go

go-bot IRC, Slack & Telegram bot written in Go using go-ircevent for IRC connectivity, nlopes/slack for Slack and Syfaro/telegram-bot-api for Telegram

null 711 Nov 30, 2021
Slack remind generator

slack-reminder Slack remind generator slack-reminder.mov Why Slack's /reminder is very hard to use. Required Go 1.16 ~ Installation $ go install githu

skanehira 27 Nov 6, 2021
send current weather updates from openweathermap api to your slack profile status using github action

go-slack-weather Send current weather updates from OpenWeatherMap API to your Slack profile status using GitHub Action Contents Setup Change Update Pe

Muhammad Thomas Fadhila Yahya 4 Nov 12, 2021
🦎 A slack bot for random gex quotes

?? A slack bot for random gex quotes

Matt Gleich 5 Nov 29, 2021
Library for testing interactive Slack applications.

Slackster Library for testing interactive Slack applications. Mock Slack API: user info, post and update message, publish view. Testing Slack UI in th

 Юла 12 Oct 1, 2021
Send Slack reports of pull requests pending review

preport Born out of a desire to get pull requests reviewed faster without having to send manual reminders, preport generates reports of GitLab pull re

Emile 1 Nov 23, 2021
Notify Slack about KPIs test

This action is a part of GitHub Actions Library created by rtCamp. Slack Notify - GitHub Action A GitHub Action to send a message to a Slack channel.

pipl.com 0 Nov 28, 2021
Simple yet customizable bot framework written in Go.

Introduction Sarah is a general-purpose bot framework named after the author's firstborn daughter. This comes with a unique feature called "stateful c

Go Hagiwara 212 Dec 4, 2021
Telegram Bot Framework for Go

Margelet Telegram Bot Framework for Go is based on telegram-bot-api It uses Redis to store it's states, configs and so on. Any low-level interactions

Gleb Sinyavskiy 66 Nov 15, 2021