package module
Version: v1.0.1 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Feb 29, 2020 License: BSD-3-Clause Imports: 4 Imported by: 0


Joe Bot - Redis Memory

Integrating Joe with Redis.

This repository contains a module for the Joe Bot library.

Getting Started

This library is packaged as Go module. You can get it via:

go get

Example usage

In order to connect your bot to Redis you can simply pass it as module when creating a new bot:

package main

import (

type ExampleBot struct {

func main() {
	b := &ExampleBot{
		Bot: joe.New("example",

	b.Respond("remember (.+) is (.+)", b.Remember)
	b.Respond("what is (.+)", b.WhatIs)
	b.Respond("show keys", b.ShowKeys)

	err := b.Run()
	if err != nil {

func (b *ExampleBot) Remember(msg joe.Message) error {
	key, value := msg.Matches[0], msg.Matches[1]
	msg.Respond("OK, I'll remember %s is %s", key, value)
	return b.Store.Set(key, value)

func (b *ExampleBot) WhatIs(msg joe.Message) error {
	key := msg.Matches[0]
	var value string
	ok, err := b.Store.Get(key, &value)
	if err != nil {
		return errors.Wrapf(err, "failed to retrieve key %q from brain", key)

	if ok {
		msg.Respond("%s is %s", key, value)
	} else {
		msg.Respond("I do not remember %q", key)

	return nil

func (b *ExampleBot) ShowKeys(msg joe.Message) error {
	keys, err := b.Store.Keys()
	if err != nil {
		return err

	msg.Respond("I got %d keys:", len(keys))
	for i, k := range keys {
		msg.Respond("%d) %q", i+1, k)
	return nil

Built With

  • go-redis - redis client in Go
  • redimock - redis mock library in tcp level
  • testify - A simple unit test library
  • zap - Blazing fast, structured, leveled logging in Go


If you want to hack on this repository, please read the short guide first.


We use SemVer for versioning. For the versions available, see the tags on this repository.


  • Friedrich Große - Initial work - fgrosse

See also the list of contributors who participated in this project.


This project is licensed under the BSD-3-Clause License - see the LICENSE file for details.


  • embedmd for a cool tool to embed source code in markdown files



Package redis implements a Redis integration for the Joe bot library.



This section is empty.


This section is empty.


func Memory

func Memory(addr string, opts ...Option) joe.Module

Memory returns a jos Module that configures the bot to use Redis as key-value store.

func NewMemory

func NewMemory(conf Config) (joe.Memory, error)

NewMemory creates a Redis implementation of a joe.Memory.


type Config

type Config struct {
	Addr     string
	Key      string
	Password string
	DB       int
	Logger   *zap.Logger

Config contains all settings for the Redis memory.

type Option

type Option func(*Config) error

An Option can be passed to the Memory function for opt-in functionality.

func WithConfig

func WithConfig(newConf Config) Option

WithConfig is an Option to have full control over all redis connection options.

func WithKey

func WithKey(key string) Option

WithKey is an Option to use a different redis key to store the memories of the bot (default is "joe-bot").

func WithLogger

func WithLogger(logger *zap.Logger) Option

WithLogger is an Option to let the Redis memory use a specific logger.


Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL