mirror of https://github.com/velour/catbase.git
bot: refactor all rand seeds into main.go
This commit is contained in:
parent
01056f1956
commit
e15122cfe9
|
@ -137,8 +137,6 @@ func (b *bot) LastMessage(channel string) (msg.Message, error) {
|
|||
|
||||
// Take an input string and mutate it based on $vars in the string
|
||||
func (b *bot) Filter(message msg.Message, input string) string {
|
||||
rand.Seed(time.Now().Unix())
|
||||
|
||||
if strings.Contains(input, "$NICK") {
|
||||
nick := strings.ToUpper(message.User.Name)
|
||||
input = strings.Replace(input, "$NICK", nick, -1)
|
||||
|
|
4
main.go
4
main.go
|
@ -5,6 +5,8 @@ package main
|
|||
import (
|
||||
"flag"
|
||||
"log"
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
"github.com/velour/catbase/bot"
|
||||
"github.com/velour/catbase/config"
|
||||
|
@ -37,6 +39,8 @@ import (
|
|||
)
|
||||
|
||||
func main() {
|
||||
rand.Seed(time.Now().Unix())
|
||||
|
||||
var cfile = flag.String("config", "config.lua",
|
||||
"Config file to load. (Defaults to config.lua)")
|
||||
flag.Parse() // parses the logging flags.
|
||||
|
|
|
@ -4,9 +4,7 @@ package admin
|
|||
|
||||
import (
|
||||
"log"
|
||||
"math/rand"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/velour/catbase/bot"
|
||||
|
@ -95,7 +93,6 @@ func (p *AdminPlugin) handleVariables(message msg.Message) bool {
|
|||
// date.
|
||||
func (p *AdminPlugin) LoadData() {
|
||||
// This bot has no data to load
|
||||
rand.Seed(time.Now().Unix())
|
||||
}
|
||||
|
||||
// Help responds to help requests. Every plugin must implement a help function.
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
package dice
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/velour/catbase/bot"
|
||||
"github.com/velour/catbase/bot/msg"
|
||||
)
|
||||
|
@ -22,8 +20,6 @@ type DicePlugin struct {
|
|||
|
||||
// NewDicePlugin creates a new DicePlugin with the Plugin interface
|
||||
func New(bot bot.Bot) *DicePlugin {
|
||||
rand.Seed(time.Now().Unix())
|
||||
|
||||
return &DicePlugin{
|
||||
Bot: bot,
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
"math/rand"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/velour/catbase/bot"
|
||||
"github.com/velour/catbase/bot/msg"
|
||||
|
@ -22,8 +21,6 @@ type EmojifyMePlugin struct {
|
|||
}
|
||||
|
||||
func New(bot bot.Bot) *EmojifyMePlugin {
|
||||
rand.Seed(time.Now().Unix())
|
||||
|
||||
resp, err := http.Get("https://raw.githubusercontent.com/github/gemoji/master/db/emoji.json")
|
||||
if err != nil {
|
||||
log.Fatalf("Error generic emoji list: %s", err)
|
||||
|
|
|
@ -4,7 +4,6 @@ package picker
|
|||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"fmt"
|
||||
"math/rand"
|
||||
|
@ -19,17 +18,11 @@ type PickerPlugin struct {
|
|||
|
||||
// NewPickerPlugin creates a new PickerPlugin with the Plugin interface
|
||||
func New(bot bot.Bot) *PickerPlugin {
|
||||
rand.Seed(time.Now().Unix())
|
||||
|
||||
return &PickerPlugin{
|
||||
Bot: bot,
|
||||
}
|
||||
}
|
||||
|
||||
func rollDie(sides int) int {
|
||||
return rand.Intn(sides) + 1
|
||||
}
|
||||
|
||||
// Message responds to the bot hook on recieving messages.
|
||||
// This function returns true if the plugin responds in a meaningful way to the users message.
|
||||
// Otherwise, the function returns false and the bot continues execution of other plugins.
|
||||
|
|
|
@ -4,7 +4,6 @@ package reaction
|
|||
|
||||
import (
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
"github.com/velour/catbase/bot"
|
||||
"github.com/velour/catbase/bot/msg"
|
||||
|
@ -17,8 +16,6 @@ type ReactionPlugin struct {
|
|||
}
|
||||
|
||||
func New(bot bot.Bot) *ReactionPlugin {
|
||||
rand.Seed(time.Now().Unix())
|
||||
|
||||
return &ReactionPlugin{
|
||||
Bot: bot,
|
||||
Config: bot.Config(),
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
"fmt"
|
||||
"math/rand"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/velour/catbase/bot"
|
||||
"github.com/velour/catbase/bot/msg"
|
||||
|
@ -47,7 +46,6 @@ type TalkerPlugin struct {
|
|||
}
|
||||
|
||||
func New(bot bot.Bot) *TalkerPlugin {
|
||||
rand.Seed(time.Now().Unix())
|
||||
return &TalkerPlugin{
|
||||
Bot: bot,
|
||||
enforceNicks: bot.Config().EnforceNicks,
|
||||
|
|
|
@ -5,7 +5,6 @@ package your
|
|||
import (
|
||||
"math/rand"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/velour/catbase/bot"
|
||||
"github.com/velour/catbase/bot/msg"
|
||||
|
@ -19,7 +18,6 @@ type YourPlugin struct {
|
|||
|
||||
// NewYourPlugin creates a new YourPlugin with the Plugin interface
|
||||
func New(bot bot.Bot) *YourPlugin {
|
||||
rand.Seed(time.Now().Unix())
|
||||
return &YourPlugin{
|
||||
bot: bot,
|
||||
config: bot.Config(),
|
||||
|
|
Loading…
Reference in New Issue