Skip to content
Permalink
Browse files

?

  • Loading branch information...
Depado committed May 22, 2018
1 parent 80731fa commit 6908604a8daf80e88b9831273de68c9f63f631d1
Showing with 18 additions and 8 deletions.
  1. +16 −5 main.go
  2. +2 −3 plugins/anon/command.go
21 main.go
@@ -2,10 +2,12 @@ package main

import (
"crypto/tls"
"log"
"fmt"
"strings"

flag "github.com/ogier/pflag"
"github.com/sirupsen/logrus"

flag "github.com/spf13/pflag"
"github.com/thoj/go-ircevent"

"github.com/depado/go-b0tsec/configuration"
@@ -28,12 +30,12 @@ func main() {
configuration.Load()

if err = cleverbot.Clever.Initialize(); err != nil {
log.Fatal(err)
logrus.WithError(err).Fatal("Couldn't connect cleverbot")
}

// Storage initialization and defering Close
if err := database.BotStorage.Open(); err != nil {
log.Fatalf("something went wrong with the databse : %v", err)
logrus.WithError(err).Fatal("Couldn't connect to the database")
}
defer database.BotStorage.Close()

@@ -50,14 +52,19 @@ func main() {
}
}
if err = ib.Connect(cnf.Server); err != nil {
log.Fatal(err)
logrus.WithError(err).Fatal("Couldn't connect to IRC server")
}

// Callback on 'Connected' event
ib.AddCallback("001", func(e *irc.Event) {
ib.Join(cnf.Channel)
})

// Callback on 'Invite' event
ib.AddCallback("INVITE", func(e *irc.Event) {
ib.Join(cnf.Channel)
})

// Callback on 'Message' event
ib.AddCallback("PRIVMSG", func(e *irc.Event) {
from := e.Nick
@@ -74,7 +81,11 @@ func main() {
command := splitted[0]
args := splitted[1:]
if p, ok := plugins.Commands[command]; ok {
if command == "anon" {
fmt.Println("That's the anon command")
}
p.Get(ib, from, to, args)
fmt.Println("Done !")
}
}
}
@@ -3,12 +3,12 @@ package anon
import (
"math/rand"
"strings"
"time"

"github.com/thoj/go-ircevent"

"github.com/depado/go-b0tsec/configuration"
"github.com/depado/go-b0tsec/plugins"
"github.com/depado/go-b0tsec/utils"
irc "github.com/thoj/go-ircevent"
)

const (
@@ -21,7 +21,6 @@ type Command struct {
}

func init() {
rand.Seed(time.Now().Unix())
plugins.Commands[command] = new(Command)
}

0 comments on commit 6908604

Please sign in to comment.
You can’t perform that action at this time.