Skip to content

Commit

Permalink
feat: possibility to change the voice used
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTipo01 committed Nov 7, 2021
1 parent eb1d759 commit a7ac502
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 34 deletions.
5 changes: 4 additions & 1 deletion example_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ token: ""
prefix: "."

#Level of logging
loglevel: "informational"
loglevel: "informational"

# Voice used to generate audio files
voice: "Roberto"
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module roberto
go 1.16

require (
github.com/TheTipo01/libRoberto v0.0.0-20211107143112-0486adeecba8
github.com/TheTipo01/libRoberto v0.0.0-20211107172043-c2760d8fcf75
github.com/bwmarrin/discordgo v0.23.3-0.20211010150959-f0b7e81468f7
github.com/bwmarrin/lit v0.0.0-20190813132558-fd4b44871312
github.com/goccy/go-json v0.7.10
Expand All @@ -17,6 +17,6 @@ require (
golang.org/x/mod v0.5.1 // indirect
golang.org/x/sys v0.0.0-20211107104306-e0b2ad06fe42 // indirect
golang.org/x/tools v0.1.7 // indirect
modernc.org/ccgo/v3 v3.12.54 // indirect
modernc.org/ccgo/v3 v3.12.55 // indirect
modernc.org/sqlite v1.13.3
)
17 changes: 8 additions & 9 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,8 @@ github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAE
github.com/OpenPeeDeeP/depguard v1.0.1/go.mod h1:xsIw86fROiiwelg+jB2uM9PiKihMMmUx/1V+TNhjQvM=
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/TheTipo01/libRoberto v0.0.0-20211107140606-06378dad675e h1:R8fvd9aqJhSqwEAiUqgdezvhQ9qK8A/QEfWlbLaidaY=
github.com/TheTipo01/libRoberto v0.0.0-20211107140606-06378dad675e/go.mod h1:IJUYniQUjSFS5ZKBoWVfNBdAgqmBdBC7oFZQ4HPphYs=
github.com/TheTipo01/libRoberto v0.0.0-20211107142223-a0172673519d h1:O7kZfkEqrRp0gdvzLgM8K0sgALW2KUwef2KOibFx0xk=
github.com/TheTipo01/libRoberto v0.0.0-20211107142223-a0172673519d/go.mod h1:IJUYniQUjSFS5ZKBoWVfNBdAgqmBdBC7oFZQ4HPphYs=
github.com/TheTipo01/libRoberto v0.0.0-20211107143112-0486adeecba8 h1:JC0U8wiith+gNQ8YT2L8TzmzLfXKZVdIe/b6vIBv1io=
github.com/TheTipo01/libRoberto v0.0.0-20211107143112-0486adeecba8/go.mod h1:IJUYniQUjSFS5ZKBoWVfNBdAgqmBdBC7oFZQ4HPphYs=
github.com/TheTipo01/libRoberto v0.0.0-20211107172043-c2760d8fcf75 h1:yjB4XOxROhWZTq+sa7aUM0AOqpUGGXTtqNqCqrLwF7A=
github.com/TheTipo01/libRoberto v0.0.0-20211107172043-c2760d8fcf75/go.mod h1:IJUYniQUjSFS5ZKBoWVfNBdAgqmBdBC7oFZQ4HPphYs=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
Expand Down Expand Up @@ -1021,8 +1017,9 @@ modernc.org/cc/v3 v3.35.7/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
modernc.org/cc/v3 v3.35.8/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
modernc.org/cc/v3 v3.35.10/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
modernc.org/cc/v3 v3.35.15/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
modernc.org/cc/v3 v3.35.16 h1:YwB4BKGpX5rfDWyn2yVDVcUDHVLy6mqV3ZnytbCv9ZA=
modernc.org/cc/v3 v3.35.16/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
modernc.org/cc/v3 v3.35.17 h1:sWWFJxgj2whIJ5P/rzgHalMgpcIhkVSRgiLV0XA7p6Y=
modernc.org/cc/v3 v3.35.17/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
modernc.org/ccgo/v3 v3.9.5/go.mod h1:umuo2EP2oDSBnD3ckjaVUXMrmeAw8C8OSICVa0iFf60=
modernc.org/ccgo/v3 v3.10.0/go.mod h1:c0yBmkRFi7uW4J7fwx/JiijwOjeAeR2NoSaRVFPmjMw=
modernc.org/ccgo/v3 v3.11.0/go.mod h1:dGNposbDp9TOZ/1KBxghxtUp/bzErD0/0QW4hhSaBMI=
Expand All @@ -1048,8 +1045,9 @@ modernc.org/ccgo/v3 v3.12.47/go.mod h1:m8d6p0zNps187fhBwzY/ii6gxfjob1VxWb919Nk1H
modernc.org/ccgo/v3 v3.12.50/go.mod h1:bu9YIwtg+HXQxBhsRDE+cJjQRuINuT9PUK4orOco/JI=
modernc.org/ccgo/v3 v3.12.51/go.mod h1:gaIIlx4YpmGO2bLye04/yeblmvWEmE4BBBls4aJXFiE=
modernc.org/ccgo/v3 v3.12.53/go.mod h1:8xWGGTFkdFEWBEsUmi+DBjwu/WLy3SSOrqEmKUjMeEg=
modernc.org/ccgo/v3 v3.12.54 h1:YTmbBTMizgxUrNYL5oDvQQP6mO54QS1AoMPd38YEXt4=
modernc.org/ccgo/v3 v3.12.54/go.mod h1:yANKFTm9llTFVX1FqNKHE0aMcQb1fuPJx6p8AcUx+74=
modernc.org/ccgo/v3 v3.12.55 h1:2woak8DZIXsYUHQfPeFZnnke8Vx8Q7TwVcfAb0372qI=
modernc.org/ccgo/v3 v3.12.55/go.mod h1:rsXiIyJi9psOwiBkplOaHye5L4MOOaCjHg1Fxkj7IeU=
modernc.org/httpfs v1.0.6 h1:AAgIpFZRXuYnkjftxTAZwMIiwEqAfk8aVB2/oA6nAeM=
modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM=
modernc.org/libc v1.9.8/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w=
Expand Down Expand Up @@ -1077,8 +1075,9 @@ modernc.org/libc v1.11.45/go.mod h1:Y192orvfVQQYFzCNsn+Xt0Hxt4DiO4USpLNXBlXg/tM=
modernc.org/libc v1.11.47/go.mod h1:tPkE4PzCTW27E6AIKIR5IwHAQKCAtudEIeAV1/SiyBg=
modernc.org/libc v1.11.49/go.mod h1:9JrJuK5WTtoTWIFQ7QjX2Mb/bagYdZdscI3xrvHbXjE=
modernc.org/libc v1.11.51/go.mod h1:R9I8u9TS+meaWLdbfQhq2kFknTW0O3aw3kEMqDDxMaM=
modernc.org/libc v1.11.53 h1:/HHRPUOkFwx0kOJwyLEvOEpwBhVid7qByJO43J+6Zwg=
modernc.org/libc v1.11.53/go.mod h1:5ip5vWYPAoMulkQ5XlSJTy12Sz5U6blOQiYasilVPsU=
modernc.org/libc v1.11.54 h1:s5ivqw18xPSp3ssX2DoI2+VGISm5ennPwnGGDh+/NaU=
modernc.org/libc v1.11.54/go.mod h1:S/FVnskbzVUrjfBqlGFIPA5m7UwB3n9fojHhCNfSsnw=
modernc.org/mathutil v1.1.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
modernc.org/mathutil v1.4.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
Expand Down
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"database/sql"
libroberto "github.com/TheTipo01/libRoberto"
"github.com/bwmarrin/discordgo"
"github.com/bwmarrin/lit"
"github.com/kkyr/fig"
Expand All @@ -18,6 +19,7 @@ import (
type config struct {
Token string `fig:"token" validate:"required"`
LogLevel string `fig:"loglevel" validate:"required"`
Voice string `fig:"voice" validate:"required"`
}

var (
Expand Down Expand Up @@ -45,7 +47,7 @@ func init() {
return
}

// Config file found
libroberto.Voice = cfg.Voice
token = cfg.Token

// Set lit.LogLevel to the given value
Expand Down
24 changes: 3 additions & 21 deletions utilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,11 @@ func advancedReplace(src string, toReplace string, a []string) string {

// Executes a simple query given a DB
func execQuery(query string, db *sql.DB) {
stm, err := db.Prepare(query)
_, err := db.Exec(query)
if err != nil {
lit.Error("Error preparing query, %s", err)
return
}

_, err = stm.Exec()
if err != nil {
lit.Error("Error creating table, %s", err)
}

_ = stm.Close()
}

// Adds a custom command to db and to the command map
Expand All @@ -71,16 +64,12 @@ func addCommand(command string, text string, guild string) error {
server[guild].customCommands[command] = text

// And to the database
stm, _ := db.Prepare("INSERT INTO customCommands (server, command, text) VALUES(?, ?, ?)")

_, err := stm.Exec(guild, command, text)
_, err := db.Exec("INSERT INTO customCommands (server, command, text) VALUES(?, ?, ?)", guild, command, text)
if err != nil {
lit.Error("Error inserting into the database, %s", err)
return errors.New("error inserting into the database: " + err.Error())
}

_ = stm.Close()

return nil
}

Expand All @@ -92,15 +81,12 @@ func removeCustom(command string, guild string) error {
}

// Remove from DB
stm, _ := db.Prepare("DELETE FROM customCommands WHERE server=? AND command=?")
_, err := stm.Exec(guild, command)
_, err := db.Exec("DELETE FROM customCommands WHERE server=? AND command=?", guild, command)
if err != nil {
lit.Error("Error removing from the database, %s", err)
return errors.New("error removing from the database: " + err.Error())
}

_ = stm.Close()

// Remove from the map
delete(server[guild].customCommands, command)

Expand Down Expand Up @@ -145,11 +131,7 @@ func loadCustomCommands(db *sql.DB) {

server[guild].customCommands[command] = text
}

_ = commands.Close()
}

_ = guilds.Close()
}

// Returns a random value from a map of string
Expand Down

0 comments on commit a7ac502

Please sign in to comment.