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

You might also like...
Make discord bots to drain discriminators

allthebotses make discord bots to drain discriminators a stupid idea You can only make ~5 bots before getting ratelimited, and it gets tougher every t

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,

Slack bot core/framework written in Go with support for reactions to message updates/deletes
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

Golang bot that connects to slack using Socketclient to read and write messages.
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

Send Linux mails to Slack with golang

LinuxMailToSlack Install go install github.com/TKMAX777/[email protected] sudo

IRC, Slack, Telegram and RocketChat bot written in go
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

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

send current weather updates from openweathermap api to your slack profile status using github action
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

🦎 A slack bot for random gex quotes

🦎 A slack bot for random gex quotes

Comments
  • 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
  • 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
  • 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
  • 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
Slack-emoji-bot - This Slack bot will post the newly created custom Slack emojis to the channel of your choice

Slack Emoji Bot This Slack bot will post the newly created custom Slack emojis t

Ryan Hollis 7 Sep 23, 2022
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 172 Sep 14, 2022
This slack-bot collects all @gophers notifications into one slack channel

slack-bot Slack bot copying reference to a ping to notifications channel The bot is designed to listen on messages containing specific tag, copy refer

Kyma Incubator 2 Apr 11, 2022
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 55 Sep 12, 2022
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
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 9 Mar 21, 2022
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 341 Sep 29, 2022
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 156 Sep 15, 2022
Wrapper library for github.com/tucnak/telebot to create simple text-based Telegram bots

tbwrap Wrapper library for github.com/tucnak/telebot to create simple text-based Telegram bots Installation go get github.com/enrico5b1b4/tbwrap Exam

null 0 Dec 7, 2021