repositorypackage
1.0.10
Repository: https://github.com/stalkr/discordgo-bridge.git
Documentation: pkg.go.dev
# Packages
No description provided by the author
# README
Discord Go Bridge library
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.