-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
660 lines (587 loc) · 21.3 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
package main
import (
"context"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"math/rand"
"net/http"
"os"
"sort"
"strconv"
"strings"
"time"
"github.com/gorilla/mux"
"golang.org/x/oauth2"
"golang.org/x/oauth2/google"
"google.golang.org/api/forms/v1"
"google.golang.org/api/option"
"google.golang.org/api/sheets/v4"
)
type Credentials struct {
ClientID string `json:"client_id"`
ClientSecret string `json:"client_secret"`
RedirectURIs []string `json:"redirect_uris"`
}
func handle_start_vote(client *http.Client) {
if _, err := os.Stat("state/ballot.txt"); err == nil {
fmt.Println("`state/ballot.txt` already exists, meaning voting has already started!")
os.Exit(1)
}
var applicationID string
{
applicationIdBytes, err := os.ReadFile("state/application.txt")
if err != nil {
fmt.Println("`state/application.txt' does not exist, meaning you haven't opened applications! To open applications, use the start-application subcommand.")
os.Exit(1)
}
applicationID = string(applicationIdBytes)
}
service, err := forms.NewService(context.Background(), option.WithHTTPClient(client))
if err != nil {
panic(err)
}
nameQuestionID := ""
positionsQuestionID := ""
{
applicationForm, err := service.Forms.Get(applicationID).Do()
if err != nil {
panic(err)
}
for _, item := range applicationForm.Items {
if item.Title == "Name" && item.QuestionItem != nil && item.QuestionItem.Question != nil && item.QuestionItem.Question.TextQuestion != nil {
nameQuestionID = item.QuestionItem.Question.QuestionId
}
if item.Title == "Positions" && item.QuestionItem != nil && item.QuestionItem.Question != nil && item.QuestionItem.Question.ChoiceQuestion != nil {
positionsQuestionID = item.QuestionItem.Question.QuestionId
}
}
if nameQuestionID == "" || positionsQuestionID == "" {
missing := ""
if nameQuestionID == "" {
missing += "Name "
}
if positionsQuestionID == "" {
missing += "Positions "
}
fmt.Println("Invalid application form; missing questions: " + missing)
os.Exit(1)
}
}
applicantsByPosition := make(map[string][]string)
// {email, name} tuple
ineligibleApplicants := [][2]string{}
{
applicantResponses, err := service.Forms.Responses.List(applicationID).Do()
if err != nil {
panic(err)
}
if applicantResponses.NextPageToken != "" {
fmt.Println("There are more than " + fmt.Sprint(len(applicantResponses.Responses)) + " responses! This program cannot process more than 5000 responses.")
os.Exit(1)
}
for _, resp := range applicantResponses.Responses {
isEligibleApplicant := false
for _, eligibleApplicant := range eligibleApplicants {
if strings.EqualFold(eligibleApplicant, resp.RespondentEmail) {
isEligibleApplicant = true
}
}
applicantName := resp.Answers[nameQuestionID].TextAnswers.Answers[0].Value
applicantPositions := []string{}
for _, textAnswer := range resp.Answers[positionsQuestionID].TextAnswers.Answers {
applicantPositions = append(applicantPositions, textAnswer.Value)
}
if !isEligibleApplicant {
ineligibleApplicants = append(ineligibleApplicants, [2]string{strings.ToLower(resp.RespondentEmail), applicantName})
} else {
for _, position := range applicantPositions {
applicantsByPosition[position] = append(applicantsByPosition[position], applicantName)
}
}
}
}
if len(ineligibleApplicants) != 0 {
fmt.Println("Ineligible Applicants:")
for _, tuple := range ineligibleApplicants {
fmt.Println("\t- " + tuple[1] + " <" + tuple[0] + ">")
}
fmt.Print("Press [Enter] to ignore these applicants, or [Ctrl-C] to address this issue and re-run this command again later: ")
fmt.Scanln()
fmt.Println()
}
// construct form
form, err := service.Forms.Create(&forms.Form{
Info: &forms.Info{
Title: electionConfig.Name + " Ballot",
DocumentTitle: electionConfig.Name + " Ballot",
},
}).Do()
if err != nil {
panic(err)
}
requests := []*forms.Request{}
for positionIdx, position := range electionConfig.Positions {
rows := []*forms.Question{}
for _, applicant := range applicantsByPosition[position.Name] {
rows = append(rows, &forms.Question{
RowQuestion: &forms.RowQuestion{
Title: applicant,
},
})
}
requests = append(requests, &forms.Request{
CreateItem: &forms.CreateItemRequest{
Item: &forms.Item{
Title: position.Name,
Description: position.Description + " \n\nScore each candidate from 0-2, with 2 expressing approval and 0 expressing disapproval. You do not have to fill in every row; blank rows will be treated like a 0.",
QuestionGroupItem: &forms.QuestionGroupItem{
Grid: &forms.Grid{
Columns: &forms.ChoiceQuestion{
Options: []*forms.Option{
{Value: "0"},
{Value: "1"},
{Value: "2"},
},
Type: "RADIO",
},
},
Questions: rows,
},
},
Location: &forms.Location{Index: int64(positionIdx), ForceSendFields: []string{"Index"}},
},
})
}
scoreDescription := "This election uses score voting. During the voting process, each voter scores each candidate from 0-2 based on how suited to the position the voter thinks the candidate is. " +
"After votes are in, scores are added up and whichever candidate has the most points is elected. If there is a tie between two or more candidates, there will be a runoff election for that position.\n\n" +
"To maximize the value of your vote, it is recommended to score 2 for at least one candidate per position."
requests = append(requests, &forms.Request{
UpdateFormInfo: &forms.UpdateFormInfoRequest{
Info: &forms.Info{
Description: electionConfig.VoteDescription + "\n\n" + scoreDescription,
},
UpdateMask: "description",
},
})
_, err = service.Forms.BatchUpdate(form.FormId, &forms.BatchUpdateFormRequest{Requests: requests}).Do()
if err != nil {
panic(err)
}
fmt.Println()
fmt.Println("Ballot Form URL: " + "https://docs.google.com/forms/d/" + form.FormId)
fmt.Println("At this point, do the following on ballot form:")
fmt.Println("\t- Turn on 'Collect email addresses'")
fmt.Println("\t- Turn on 'Allow response editing'")
fmt.Println("\t- Turn on 'Limit to 1 response'")
fmt.Println("Also:")
fmt.Println("\t- Close the application form")
fmt.Print("Press [Enter] when you are done with the above: ")
fmt.Scanln()
fmt.Println()
fmt.Println("As a reminder, do NOT share the raw results with anyone, as this will compromise the anonymity of the voting process.")
fmt.Print("Press [Enter] to confirm: ")
fmt.Scanln()
f, err := os.Create("state/ballot.txt")
if err != nil {
panic(err)
}
defer f.Close()
io.WriteString(f, form.FormId)
sendWebhook(
"<@&" + fmt.Sprint(discordConfig.RoleID) + "> Voting for the " + electionConfig.Name + " has begun! Fill out this form before the deadline to have your vote counted: " + form.ResponderUri + "\n\n" +
"All votes are **anonymous**, so please vote for people that you feel are well suited for the position.\nTo maximize the value of your vote, it is recommended to **score 2 for at least one candidate per position**.\nYou may edit your vote anytime before the deadline.\n\n" +
"Make sure you enter one of the following addresses into the \"Email\" field. **Entering an unlisted email may result in your vote being uncounted.**\n```\n" + strings.Join(eligibleVoters, "\n") + "\n```",
)
sendWebhook("BTW: Remember that your election opponents, like a match opponent, may (will) be your alliance partner (team member).")
fmt.Println("You're all set!")
os.Exit(0)
}
func handle_start_appliction(client *http.Client) {
// sanity check
if _, err := os.Stat("state/application.txt"); err == nil {
fmt.Println("`state/application.txt' already exists, meaning you've already created the application form! To reset the process, delete the `state' folder.")
os.Exit(1)
}
service, err := forms.NewService(context.Background(), option.WithHTTPClient(client))
if err != nil {
panic(err)
}
form, err := service.Forms.Create(&forms.Form{
Info: &forms.Info{
Title: electionConfig.Name + " Application",
DocumentTitle: electionConfig.Name + " Application",
},
}).Do()
if err != nil {
panic(err)
}
positionOptions := make([]*forms.Option, 0)
for _, position := range electionConfig.Positions {
positionOptions = append(positionOptions, &forms.Option{
Value: position.Name,
})
}
formRequests := []*forms.Request{{
CreateItem: &forms.CreateItemRequest{
Item: &forms.Item{
Title: "Name",
Description: "Full name please.",
QuestionItem: &forms.QuestionItem{
Question: &forms.Question{
TextQuestion: &forms.TextQuestion{},
Required: true,
ForceSendFields: []string{"TextQuestion"},
},
},
},
Location: &forms.Location{Index: 0, ForceSendFields: []string{"Index"}},
},
}, {
CreateItem: &forms.CreateItemRequest{
Item: &forms.Item{
Title: "Positions",
Description: "Select all positions that you would be willing and able to fulfill. You may select multiple. You will be considered for them in the order they appear.",
QuestionItem: &forms.QuestionItem{
Question: &forms.Question{
ChoiceQuestion: &forms.ChoiceQuestion{
Options: positionOptions,
Type: "CHECKBOX",
},
Required: true,
},
},
},
Location: &forms.Location{Index: 1, ForceSendFields: []string{"Index"}},
},
}, {
UpdateFormInfo: &forms.UpdateFormInfoRequest{
Info: &forms.Info{
Description: electionConfig.ApplicationDescription,
Title: electionConfig.Name + " Application",
DocumentTitle: electionConfig.Name + " Application",
},
UpdateMask: "*",
},
}}
_, err = service.Forms.BatchUpdate(form.FormId, &forms.BatchUpdateFormRequest{Requests: formRequests}).Do()
if err != nil {
panic(err)
}
formEditURL := "https://docs.google.com/forms/d/" + form.FormId + "/edit"
// make the election administrator make some changes
message:
fmt.Println("")
fmt.Println("Form URL: " + formEditURL)
fmt.Println("At this point (since Google is kinda poopy and doesn't have a complete Forms API)\n\t - Turn on 'Collect email addresses'\n\t - Turn on 'Allow response editing'\n\t - Turn on 'Limit to 1 response'\n\t - Link a spreadsheet & make that spreadsheet publicly viewable")
fmt.Print("When you are done, press [Enter]: ")
fmt.Scanln()
form, err = service.Forms.Get(form.FormId).Do()
if err != nil {
panic(err)
}
if form.LinkedSheetId == "" {
fmt.Println("You forgot to link a spreadsheet! I'll give you another chance.")
time.Sleep(1 * time.Second)
goto message
}
formViewURL := form.ResponderUri
sendWebhook("<@&" + fmt.Sprint(discordConfig.RoleID) + "> Candidacy applications for the " + electionConfig.Name + " are now open! Please fill out this form before the deadline: " + formViewURL + ". Before you apply, keep in mind the requirements of the board position that you are applying for.\n\n" +
"This form can be edited anytime before the application deadline.\n\n" +
"As a reminder, **bribery and extortion are grounds for your candidacy eligibility to be revoked**. This means no personal promises, goods, money, services, etc in exchange for votes or even an implication of exchange for votes.\n\n" +
"Make sure you enter one of the following email addresses into the \"Email\" field. **Entering an unlisted email may result in your candidacy not being registered.**\n```" + strings.Join(eligibleApplicants, "\n") + "\n```")
sendWebhook("Application results are updated live at https://docs.google.com/spreadsheets/d/" + form.LinkedSheetId + ".")
os.Mkdir("state", 0700)
f, err := os.Create("state/application.txt")
if err != nil {
panic(err)
}
defer f.Close()
io.WriteString(f, form.FormId)
fmt.Println("You're all set!")
os.Exit(0)
}
func handleEndVote(client *http.Client) {
// sanity check
if _, err := os.Stat("state/results.txt"); err == nil {
fmt.Println("`state/results.txt' already exists, meaning you've already sent out the results! To restart the election, delete the state folder.")
os.Exit(1)
}
var ballotID string
{
ballotIDBytes, err := os.ReadFile("state/ballot.txt")
if err != nil {
fmt.Println("`state/ballot.txt' does not exist, meaning you haven't started the vote! Use the `start-vote' command to open the ballot.")
os.Exit(1)
}
ballotID = string(ballotIDBytes)
}
service, err := forms.NewService(context.Background(), option.WithHTTPClient(client))
if err != nil {
panic(err)
}
ballot, err := service.Forms.Get(ballotID).Do()
if err != nil {
panic(err)
}
// question id => {position, candidate}
questionIDs := make(map[string][2]string)
for _, item := range ballot.Items {
if item.QuestionGroupItem != nil && item.QuestionGroupItem.Grid != nil && len(item.QuestionGroupItem.Questions) != 0 {
for _, row := range item.QuestionGroupItem.Questions {
questionIDs[row.QuestionId] = [2]string{item.Title, row.RowQuestion.Title}
}
}
}
// position => candidate => score
totalScores := make(map[string]map[string]uint)
responses, err := service.Forms.Responses.List(ballotID).Do()
if err != nil {
panic(err)
}
ineligibleVoters := []string{}
numberEligibleVoters := uint(0)
for _, resp := range responses.Responses {
isEligible := false
for _, email := range eligibleVoters {
if strings.EqualFold(resp.RespondentEmail, email) {
isEligible = true
}
}
if !isEligible {
ineligibleVoters = append(ineligibleVoters, strings.ToLower(resp.RespondentEmail))
continue
}
numberEligibleVoters += 1
for questionID, answer := range resp.Answers {
tuple := questionIDs[questionID]
position := tuple[0]
candidate := tuple[1]
score, err := strconv.ParseUint(answer.TextAnswers.Answers[0].Value, 10, 32)
if err != nil {
panic(err)
}
if totalScores[position] == nil {
totalScores[position] = make(map[string]uint)
}
totalScores[position][candidate] += uint(score)
}
}
if len(ineligibleVoters) != 0 {
fmt.Println("Ineligible voters that voted:")
for _, voter := range ineligibleVoters {
fmt.Println("\t- " + voter)
}
fmt.Print("Press [Enter] to ignore these votes, or [Ctrl-C] to fix the issue and re-run this command later: ")
fmt.Scanln()
fmt.Println()
}
sheetsService, err := sheets.NewService(context.Background(), option.WithHTTPClient(client))
if err != nil {
panic(err)
}
rowData := []*sheets.RowData{}
colData := []*sheets.DimensionProperties{}
winners := make(map[string]string)
tie := ""
tiers := []string{}
for positionIdx, position := range electionConfig.Positions {
colData = append(colData, &sheets.DimensionProperties{PixelSize: 192})
colData = append(colData, &sheets.DimensionProperties{PixelSize: 32})
type candidateTuple struct {
name string
score uint
}
candidates := []candidateTuple{}
for candidate, score := range totalScores[position.Name] {
candidates = append(candidates, candidateTuple{name: candidate, score: score})
}
sort.Slice(candidates, func(i, j int) bool {
return candidates[i].score > candidates[j].score
})
// winners
if tie == "" {
for i, candidate := range candidates {
alreadyWon := false
for _, winner := range winners {
if winner == candidate.name {
alreadyWon = true
}
}
if alreadyWon {
continue
}
if i+1 < len(candidates) && candidates[i+1].score == candidates[i].score {
tie = position.Name
for j := i; j < len(candidates); j++ {
if candidates[j].score == candidate.score {
tiers = append(tiers, candidates[j].name)
}
}
break
} else {
winners[position.Name] = candidate.name
break
}
}
}
// configure spreadsheet
for len(rowData) < len(candidates)+1 {
rowData = append(rowData, &sheets.RowData{})
}
for _, row := range rowData {
for len(row.Values) < len(electionConfig.Positions)*2 {
row.Values = append(row.Values, &sheets.CellData{})
}
}
positionName := position.Name
rowData[0].Values[positionIdx*2].UserEnteredValue = &sheets.ExtendedValue{StringValue: &positionName}
rowData[0].Values[positionIdx*2].UserEnteredFormat = &sheets.CellFormat{TextFormat: &sheets.TextFormat{Bold: true}}
for candidateIdx, candidate := range candidates {
candidateName := candidate.name
candidateScore := float64(candidate.score)
rowData[candidateIdx+1].Values[positionIdx*2].UserEnteredValue = &sheets.ExtendedValue{StringValue: &candidateName}
rowData[candidateIdx+1].Values[positionIdx*2+1].UserEnteredValue = &sheets.ExtendedValue{NumberValue: &candidateScore}
}
}
sheet, err := sheetsService.Spreadsheets.Create(&sheets.Spreadsheet{
Properties: &sheets.SpreadsheetProperties{
Title: electionConfig.Name + " Results",
},
Sheets: []*sheets.Sheet{{
Properties: &sheets.SheetProperties{Title: "Results", GridProperties: &sheets.GridProperties{
RowCount: int64(len(rowData)),
ColumnCount: int64(len(electionConfig.Positions)) * 2,
}},
Data: []*sheets.GridData{{
RowData: rowData,
ColumnMetadata: colData,
}},
}},
}).Do()
if err != nil {
panic(err)
}
fmt.Println("Ballot Form URL: https://docs.google.com/forms/d/" + ballotID + "/edit#responses")
fmt.Println("Spreadsheet URL: " + sheet.SpreadsheetUrl)
fmt.Println("At this point, make sure you do the following:")
fmt.Println("\t- Close ballot form")
fmt.Println("\t- Make spreadsheet publicly viewable")
fmt.Print("When you're done, press [Enter]: ")
fmt.Scanln()
fmt.Println()
f, err := os.Create("state/results.txt")
if err != nil {
panic(err)
}
defer f.Close()
io.WriteString(f, sheet.SpreadsheetId)
embed := &DiscordEmbed{
Title: electionConfig.Name + " Results",
Color: 0x88c0d0,
}
if tie == "" {
embed.Description = "Congratulations to our new <@&" + fmt.Sprint(discordConfig.BoardID) + ">!"
for _, position := range electionConfig.Positions {
embed.Description += "\n - **" + winners[position.Name] + "** as " + position.Name
}
} else {
embed.Description = "There will be a runoff election for " + tie + " between **" + strings.Join(tiers, "** and **") + "**."
}
embed.Fields = append(embed.Fields, &DiscordField{
Name: "Results",
Value: sheet.SpreadsheetUrl,
Inline: false,
})
embed.Fields = append(embed.Fields, &DiscordField{
Name: "Votes",
Value: fmt.Sprint(numberEligibleVoters),
Inline: true,
})
if len(ineligibleVoters) != 0 {
embed.Fields = append(embed.Fields, &DiscordField{
Name: "Ineligible Votes",
Value: fmt.Sprint(len(ineligibleVoters)),
Inline: true,
})
}
sendWebhookEmbed("<@&"+fmt.Sprint(discordConfig.RoleID)+"> Results are out! Remember that **no matter who wins, "+
"you're all part of the same team**.", embed)
fmt.Println("As a reminder, DO NOT share the raw results (who voted for who) with anyone, as that would compromise the secrecy of the ballot.")
fmt.Print("Press [Enter] if you understand: ")
fmt.Scanln()
fmt.Println()
if tie != "" {
fmt.Println("You're going to need to have a runoff election for " + tie + ". If there are only two candidates, it should be done using FPTP.")
fmt.Println("This bot will not help you with the runoff election.")
fmt.Println("After the runoff election, you should be able to deduce the winners based on the results spreadsheet.")
} else {
fmt.Println("You're all set! Make sure you update the board roles.")
}
os.Exit(0)
}
func main() {
// flag parsing
if len(os.Args) < 2 || os.Args[1] == "--help" || os.Args[1] == "-h" {
fmt.Fprintf(os.Stderr, "usage: %s [ACTION] [OPTIONS...]\n\tpossible actions: start-application, start-vote, end-vote\n", os.Args[0])
os.Exit(2)
}
subcommand := os.Args[1]
if subcommand != "start-application" && subcommand != "start-vote" && subcommand != "end-vote" {
fmt.Fprintln(os.Stderr, "invalid action. type "+os.Args[0]+" --help for more information")
os.Exit(2)
}
// credentials
var creds map[string]Credentials
file, err := ioutil.ReadFile("./creds.json")
if err != nil {
panic(err)
}
json.Unmarshal(file, &creds)
var cred Credentials
for _, c := range creds {
cred = c
}
config := &oauth2.Config{
ClientID: cred.ClientID,
ClientSecret: cred.ClientSecret,
RedirectURL: "http://127.0.0.1:4444/redirect",
Scopes: []string{
"https://www.googleapis.com/auth/forms.body",
"https://www.googleapis.com/auth/forms.responses.readonly",
"https://www.googleapis.com/auth/spreadsheets",
},
Endpoint: google.Endpoint,
}
rand.Seed(time.Now().UnixNano())
state := strconv.FormatUint(uint64(rand.Int63()), 36)
auth_url := config.AuthCodeURL(state)
// serve
fmt.Printf("Open the following URL: %s\n", "http://127.0.0.1:4444/auth")
r := mux.NewRouter()
r.HandleFunc("/redirect", func(w http.ResponseWriter, req *http.Request) {
q := req.URL.Query()
if state == q.Get("state") {
tok, err := config.Exchange(context.Background(), q.Get("code"))
if err != nil {
panic(err)
}
client := config.Client(context.Background(), tok)
switch subcommand {
case "start-application":
go handle_start_appliction(client)
io.WriteString(w, "Authorized! Return to your terminal please :)")
case "start-vote":
go handle_start_vote(client)
io.WriteString(w, "Authorized! Return to your terminal please :)")
case "end-vote":
go handleEndVote(client)
io.WriteString(w, "Authorized! Return to your terminal please :)")
}
}
})
r.Handle("/auth", http.RedirectHandler(auth_url, http.StatusTemporaryRedirect))
http.Handle("/", r)
http.ListenAndServe("localhost:4444", nil)
}