summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/bwmarrin/discordgo/examples/pingpong
diff options
context:
space:
mode:
authorWim <wim@42.be>2018-08-06 21:47:05 +0200
committerWim <wim@42.be>2018-08-06 21:47:05 +0200
commit51062863a5c34d81e296cf15c61140911037cf3b (patch)
tree9b5e044672486326c7a0ca8fb26430f37bf4d83c /vendor/github.com/bwmarrin/discordgo/examples/pingpong
parent4fb4b7aa6c02a54db8ad8dd98e4d321396926c0d (diff)
downloadmatterbridge-msglm-51062863a5c34d81e296cf15c61140911037cf3b.tar.gz
matterbridge-msglm-51062863a5c34d81e296cf15c61140911037cf3b.tar.bz2
matterbridge-msglm-51062863a5c34d81e296cf15c61140911037cf3b.zip
Use mod vendor for vendored directory (backwards compatible)
Diffstat (limited to 'vendor/github.com/bwmarrin/discordgo/examples/pingpong')
-rw-r--r--vendor/github.com/bwmarrin/discordgo/examples/pingpong/main.go71
1 files changed, 0 insertions, 71 deletions
diff --git a/vendor/github.com/bwmarrin/discordgo/examples/pingpong/main.go b/vendor/github.com/bwmarrin/discordgo/examples/pingpong/main.go
deleted file mode 100644
index 155e782f..00000000
--- a/vendor/github.com/bwmarrin/discordgo/examples/pingpong/main.go
+++ /dev/null
@@ -1,71 +0,0 @@
-package main
-
-import (
- "flag"
- "fmt"
- "os"
- "os/signal"
- "syscall"
-
- "github.com/bwmarrin/discordgo"
-)
-
-// Variables used for command line parameters
-var (
- Token string
-)
-
-func init() {
-
- flag.StringVar(&Token, "t", "", "Bot Token")
- flag.Parse()
-}
-
-func main() {
-
- // Create a new Discord session using the provided bot token.
- dg, err := discordgo.New("Bot " + Token)
- if err != nil {
- fmt.Println("error creating Discord session,", err)
- return
- }
-
- // Register the messageCreate func as a callback for MessageCreate events.
- dg.AddHandler(messageCreate)
-
- // Open a websocket connection to Discord and begin listening.
- err = dg.Open()
- if err != nil {
- fmt.Println("error opening connection,", err)
- return
- }
-
- // Wait here until CTRL-C or other term signal is received.
- fmt.Println("Bot is now running. Press CTRL-C to exit.")
- sc := make(chan os.Signal, 1)
- signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
- <-sc
-
- // Cleanly close down the Discord session.
- dg.Close()
-}
-
-// This function will be called (due to AddHandler above) every time a new
-// message is created on any channel that the autenticated bot has access to.
-func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
-
- // Ignore all messages created by the bot itself
- // This isn't required in this specific example but it's a good practice.
- if m.Author.ID == s.State.User.ID {
- return
- }
- // If the message is "ping" reply with "Pong!"
- if m.Content == "ping" {
- s.ChannelMessageSend(m.ChannelID, "Pong!")
- }
-
- // If the message is "pong" reply with "Ping!"
- if m.Content == "pong" {
- s.ChannelMessageSend(m.ChannelID, "Ping!")
- }
-}