Compare commits

...
7 Commits
Author SHA1 Message Date
Dusty.P d876f4ced9 Merge pull request #3 from dustinpianalto/development
CI / build (push) Has been cancelled
Fix addtag removing newlines
2020-09-01 21:40:46 -08:00
Dustin Pianalto fb4d7977aa Fix addtag removing newlines 2020-09-01 21:36:14 -08:00
Dusty.P 68a02e2f24 Merge pull request #2 from dustinpianalto/development
Adding actions and reorg
2020-08-30 22:08:47 -08:00
Dustin Pianalto 30394b35e5 Merge branch 'master' into development
CI / build (push) Has been cancelled
2020-08-30 21:53:25 -08:00
Dustin Pianalto 87961c5081 Remove branch check and also push latest tag 2020-08-30 17:57:19 -08:00
Dusty.P 35882993c2 Update init.go 2020-08-29 18:42:38 -08:00
Dusty.P 85bcb31d56 Merge pull request #1 from dustinpianalto/development
Add Puzzle parser
2020-08-29 18:37:59 -08:00
4 changed files with 28 additions and 21 deletions
+2 -1
View File
@@ -10,7 +10,6 @@ on:
jobs:
build:
if: endsWith(github.ref, 'master') || endsWith(github.ref, 'development')
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
@@ -41,3 +40,5 @@ jobs:
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:latest
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
+4 -19
View File
@@ -8,31 +8,17 @@ import (
"github.com/dustinpianalto/disgoman"
"github.com/dustinpianalto/goff/utils"
"github.com/kballard/go-shellquote"
)
func addTagCommand(ctx disgoman.Context, input []string) {
if len(input) >= 1 {
args, err := shellquote.Split(strings.Join(input, " "))
if err != nil {
if strings.Contains(err.Error(), "Unterminated") {
args = strings.SplitN(strings.Join(args, " "), " ", 2)
} else {
ctx.ErrorChannel <- disgoman.CommandError{
Context: ctx,
Message: "",
Error: err,
}
return
}
}
queryString := `SELECT tags.id, tags.tag, tags.content from tags
WHERE tags.guild_id = $1
AND tags.tag = $2;`
row := utils.Database.QueryRow(queryString, ctx.Guild.ID, args[0])
row := utils.Database.QueryRow(queryString, ctx.Guild.ID, input[0])
var dest string
if err := row.Scan(&dest); err != nil {
tag := args[0]
tag := input[0]
if tag == "" {
ctx.ErrorChannel <- disgoman.CommandError{
Context: ctx,
@@ -41,7 +27,7 @@ func addTagCommand(ctx disgoman.Context, input []string) {
}
return
}
if len(args) <= 1 {
if len(input) <= 1 {
ctx.ErrorChannel <- disgoman.CommandError{
Context: ctx,
Message: "I got a name but no value",
@@ -49,7 +35,7 @@ func addTagCommand(ctx disgoman.Context, input []string) {
}
return
}
value := args[1]
value := strings.Join(input[1:], " ")
if value == "" {
ctx.ErrorChannel <- disgoman.CommandError{
Context: ctx,
@@ -61,7 +47,6 @@ func addTagCommand(ctx disgoman.Context, input []string) {
queryString = `INSERT INTO tags (tag, content, creator, guild_id) VALUES ($1, $2, $3, $4);`
_, err := utils.Database.Exec(queryString, tag, value, ctx.Message.Author.ID, ctx.Guild.ID)
if err != nil {
ctx.Send(err.Error())
ctx.ErrorChannel <- disgoman.CommandError{
Context: ctx,
Message: "",
+1 -1
View File
@@ -4,7 +4,7 @@ go 1.14
require (
github.com/bwmarrin/discordgo v0.20.3-0.20200525154655-ca64123b05de
github.com/dustinpianalto/disgoman v0.0.10
github.com/dustinpianalto/disgoman v0.0.12
github.com/dustinpianalto/rpnparse v1.0.1
github.com/emersion/go-imap v1.0.5
github.com/emersion/go-message v0.12.0
+21
View File
@@ -16,6 +16,10 @@ var postfixes = []postfix{
Name: "1_Update_X_Guild_Prefixes_to_add_ID",
Invoke: updateXGuildPrefixesToAddID,
},
postfix{
Name: "1_Update_Tags_Content_Length",
Invoke: updateTagsContentLength,
},
}
func RunPostfixes() {
@@ -75,3 +79,20 @@ func updateXGuildPrefixesToAddID(revert bool) error {
}
return nil
}
func updateTagsContentLength(revert bool) error {
var queryString string
if !revert {
queryString = `ALTER TABLE tags
ALTER COLUMN content TYPE varchar(2000)`
} else {
queryString = `ALTER TABLE tags
ALTER COLUMN content TYPE varchar(1000)`
}
_, err := Database.Exec(queryString)
if err != nil {
log.Println(err)
return err
}
return nil
}