Compare commits
No commits in common. 'bd493223ca5656bde00f4aca5979e9e8c31e8968' and '6e1c27ca27341d13d7bc8cbde5b87cb02ff9681c' have entirely different histories.
bd493223ca
...
6e1c27ca27
6 changed files with 18 additions and 100 deletions
@ -1,51 +0,0 @@ |
|||||||
package tools |
|
||||||
|
|
||||||
import ( |
|
||||||
"encoding/json" |
|
||||||
"flag" |
|
||||||
"fmt" |
|
||||||
"log" |
|
||||||
"os" |
|
||||||
"os/signal" |
|
||||||
"syscall" |
|
||||||
|
|
||||||
"github.com/bwmarrin/discordgo" |
|
||||||
) |
|
||||||
|
|
||||||
var ( |
|
||||||
token string |
|
||||||
dg *discordgo.Session |
|
||||||
guild string |
|
||||||
) |
|
||||||
|
|
||||||
func init() { |
|
||||||
flag.StringVar(&token, "t", "", "Bot Token") |
|
||||||
flag.StringVar(&guild, "g", "", "Guild ID") |
|
||||||
flag.Parse() |
|
||||||
} |
|
||||||
|
|
||||||
func main() { |
|
||||||
if token == "" { |
|
||||||
fmt.Printf("No token provided. Please run: disgord-thanos -t <bot token>") |
|
||||||
} |
|
||||||
dg, _ = discordgo.New("Bot " + token) |
|
||||||
dg.AddHandler(messageCreate) |
|
||||||
_ = dg.Open() |
|
||||||
sc := make(chan os.Signal, 1) |
|
||||||
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt) |
|
||||||
<-sc |
|
||||||
dg.Close() |
|
||||||
} |
|
||||||
|
|
||||||
func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) { |
|
||||||
if guild != "" { |
|
||||||
if m.GuildID != guild { |
|
||||||
return |
|
||||||
} |
|
||||||
} |
|
||||||
jsonMsg, err := json.Marshal(m) |
|
||||||
if err != nil { |
|
||||||
jsonMsg = append(jsonMsg, '0') |
|
||||||
} |
|
||||||
log.Printf("----------\n%+v: %+v\n\n%+v\n------------------------------\n\n", m.Author.Username, m.Content, string(jsonMsg)) |
|
||||||
} |
|
Loading…
Reference in new issue