Categorygithub.com/StalkR/discordgo-bridge
modulepackage
1.0.10
Repository: https://github.com/stalkr/discordgo-bridge.git
Documentation: pkg.go.dev

# README

Discord Go Bridge library

Build Status Godoc

A small library using discordgo to implement bridges between discord and other chats (e.g. IRC). On the discord side, the bot uses webhook to impersonate nicknames, and if the nickname matches one on discord, also uses their avatar.

Example

import (
  bridge "github.com/StalkR/discordgo-bridge"
)

general := bridge.NewChannel("#general", "https://discord.com/api/webhooks/<webhook id>/<webhook token>", func(nick, text string) {
  log.Printf("relaying from discord -> external: <%v> %v", nick, text)
  // implement sending to external
})

go func() {
  // implement receiving from external
  for ; ; time.Sleep(10 * time.Second) {
    nick, text := "timebot", fmt.Sprintf("Current time: %v", time.Now())
    log.Printf("relaying from external -> discord: <%v> %v", nick, text)
    general.Send(nick, text)
  }
}()

b := bridge.NewBot("<bot token>", general)
if err := b.Start(); err != nil {
  log.Fatal(err)
}
defer b.Close()

log.Printf("Discord bridge bot running - press CTRL-C to exit")
sc := make(chan os.Signal, 1)
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
<-sc

Acknowledgements

Discord Go bindings: bwmarrin/discordgo (doc).

Bugs, comments, questions

Create a new issue.

# Packages

Package irc implements an irc-discord bridge.

# Functions

NewBot creates a new discord bridge bot.
NewChannel creates a new channel bridge.

# Variables

ErrNotConnected is returned when sending but the bot is not connected.

# Structs

A Bot represents a discord bridge bot.
A Channel represents a discord channel bridge.