Skip to content

Commit

Permalink
Merge pull request #300 from ewohltman/develop
Browse files Browse the repository at this point in the history
Update Discord Gateway Intents
  • Loading branch information
ewohltman committed Oct 19, 2020
2 parents 4ae5b5a + d53e5ef commit d413ee5
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 25 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/pullRequest.yml
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.15
uses: actions/setup-go@v1
uses: actions/setup-go@v2
with:
go-version: 1.15
id: go
Expand All @@ -18,12 +18,12 @@ jobs:
languages: go

- name: Check out code
uses: actions/checkout@v1
uses: actions/checkout@v2

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v1.2.1
uses: golangci/golangci-lint-action@v2
with:
version: v1.27
version: v1.31

- name: Run tests
run: make test
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/pushToMaster.yml
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.15
uses: actions/setup-go@v1
uses: actions/setup-go@v2
with:
go-version: 1.15
id: go
Expand All @@ -21,12 +21,12 @@ jobs:
languages: go

- name: Check out code
uses: actions/checkout@v1
uses: actions/checkout@v2

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v1.2.1
uses: golangci/golangci-lint-action@v2
with:
version: v1.27
version: v1.31

- name: Run tests
run: make test
Expand Down
7 changes: 4 additions & 3 deletions cmd/ephemeral-roles/ephemeral-roles.go
Expand Up @@ -28,8 +28,9 @@ import (

const (
ephemeralRoles = "ephemeral-roles"
monitorInterval = 10 * time.Second
contextTimeout = 1 * time.Minute
monitorInterval = 10 * time.Second
discordIntents = discordgo.IntentsAllWithoutPrivileged | discordgo.IntentsGuildMembers
)

type environmentVariables struct {
Expand All @@ -48,7 +49,7 @@ type environmentVariables struct {
}

func (envVars *environmentVariables) parseShardID() error {
shardIDRegEx := regexp.MustCompile(`-[0-9].*$`)
shardIDRegEx := regexp.MustCompile(`-\d.*$`)

shardIDString := shardIDRegEx.FindString(envVars.InstanceName)
shardIDString = strings.TrimPrefix(shardIDString, "-")
Expand Down Expand Up @@ -81,7 +82,7 @@ func startSession(
session.ShardID = envVars.shardID
session.ShardCount = envVars.ShardCount
session.LogLevel = discordgo.LogError
session.Identify.Intents = discordgo.MakeIntent(discordgo.IntentsAllWithoutPrivileged)
session.Identify.Intents = discordgo.MakeIntent(discordIntents)

callbackMetrics := monitor.NewMetrics(&monitor.Config{
Log: log,
Expand Down
6 changes: 2 additions & 4 deletions go.mod
Expand Up @@ -2,21 +2,19 @@ module github.com/ewohltman/ephemeral-roles

go 1.15

replace github.com/bwmarrin/discordgo => github.com/ewohltman/discordgo v0.20.3-0.20200827215255-9e7ef1322884
replace github.com/bwmarrin/discordgo => github.com/ewohltman/discordgo v0.20.3-0.20201016153228-9042d383c330

require (
github.com/HdrHistogram/hdrhistogram-go v0.9.0 // indirect
github.com/bwmarrin/discordgo v0.22.0
github.com/caarlos0/env v3.5.0+incompatible
github.com/kz/discordrus v1.2.0
github.com/opentracing/opentracing-go v1.2.0
github.com/prometheus/client_golang v1.7.1
github.com/prometheus/common v0.13.0 // indirect
github.com/prometheus/client_golang v1.8.0
github.com/sirupsen/logrus v1.7.0
github.com/uber/jaeger-client-go v2.25.0+incompatible
github.com/uber/jaeger-lib v2.4.0+incompatible
go.uber.org/atomic v1.7.0 // indirect
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a // indirect
golang.org/x/sys v0.0.0-20200909081042-eff7692f9009 // indirect
google.golang.org/protobuf v1.25.0 // indirect
)
18 changes: 12 additions & 6 deletions go.sum
Expand Up @@ -58,8 +58,8 @@ github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaB
github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/ewohltman/discordgo v0.20.3-0.20200827215255-9e7ef1322884 h1:dYAjhXxyxuXIYO4xzYfg4LibAOTt/dcEePcd/6X8+Nc=
github.com/ewohltman/discordgo v0.20.3-0.20200827215255-9e7ef1322884/go.mod h1:phiR86AY7EEYiDst9ocktQmUDsBGhl96BCtWj+u2s64=
github.com/ewohltman/discordgo v0.20.3-0.20201016153228-9042d383c330 h1:kmrvwMX7beo0XDV4NZniB8v4fokl5zys+srpE94wT20=
github.com/ewohltman/discordgo v0.20.3-0.20201016153228-9042d383c330/go.mod h1:phiR86AY7EEYiDst9ocktQmUDsBGhl96BCtWj+u2s64=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4=
github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20=
Expand Down Expand Up @@ -97,6 +97,8 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM=
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
Expand Down Expand Up @@ -237,6 +239,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn
github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og=
github.com/prometheus/client_golang v1.7.1 h1:NTGy1Ja9pByO+xAeH/qiWnLrKtr3hJPNjaVUwnjpdpA=
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
github.com/prometheus/client_golang v1.8.0 h1:zvJNkoCFAnYFNC24FV8nW4JdRJ3GIFcLbg65lL/JDcw=
github.com/prometheus/client_golang v1.8.0/go.mod h1:O9VU6huf47PktckDQfMTX0Y8tY0/7TSWwj+ITvv0TnM=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 h1:idejC8f05m9MGOsuEi1ATq9shN03HrxNkD/luQvxCv8=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
Expand All @@ -252,15 +256,17 @@ github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8
github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA=
github.com/prometheus/common v0.10.0 h1:RyRA7RzGXQZiW+tGMr7sxa85G1z0yOpM1qq5c8lNawc=
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
github.com/prometheus/common v0.13.0 h1:vJlpe9wPgDRM1Z+7Wj3zUUjY1nr6/1jNKyl7llliccg=
github.com/prometheus/common v0.13.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s=
github.com/prometheus/common v0.14.0 h1:RHRyE8UocrbjU+6UvRzwi6HjiDfxrrBU91TtbKzkGp4=
github.com/prometheus/common v0.14.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s=
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.2 h1:6LJUbpNm42llc4HRCuvApCSWB/WfhuNo9K98Q9sNGfs=
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
github.com/prometheus/procfs v0.1.3 h1:F0+tqvhOksq22sc6iCHF5WGlWjdwj92p0udFh1VFBS8=
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
github.com/prometheus/procfs v0.2.0 h1:wH4vA7pcjKuZzjF7lM8awk4fnuJO6idemZXoKnULUx4=
github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
Expand Down Expand Up @@ -388,8 +394,8 @@ golang.org/x/sys v0.0.0-20200406155108-e3b113bbe6a4/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1 h1:ogLJMz+qpzav7lGMh10LMvAkM/fAoGlaiiHYiFYdm80=
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200909081042-eff7692f9009 h1:W0lCpv29Hv0UaM1LXb9QlBHLNP8UFfcKjblhVCWftOM=
golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211 h1:9UQO31fZ+0aKQOFldThf7BKPMJTiBfWycGh/u3UoO88=
golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/callbacks/voiceStateUpdate.go
Expand Up @@ -91,7 +91,7 @@ func (config *Config) parseEvent(
}
}

channel, err := session.State.GuildChannel(voiceState.GuildID, voiceState.ChannelID)
channel, err := session.State.Channel(voiceState.ChannelID)
if err != nil {
return nil, &ChannelNotFound{
Guild: guild,
Expand Down Expand Up @@ -157,7 +157,7 @@ func (config *Config) logRevoke(ctx context.Context, session *discordgo.Session,

guild := callbackError.InGuild()
if guild != nil {
log = log.WithField("Guild", guild.Name)
log = log.WithField("guild", guild.Name)
}

member := callbackError.ForMember()
Expand Down
9 changes: 9 additions & 0 deletions internal/pkg/logging/logging.go
Expand Up @@ -4,6 +4,7 @@
package logging

import (
"io"
"os"
"strings"
"sync"
Expand Down Expand Up @@ -80,6 +81,14 @@ func New(options ...OptionFunc) *Logger {
return logger
}

// OptionalOutput returns an OptionFunc to configure a *Logger to set where log
// messages should output to.
func OptionalOutput(output io.Writer) OptionFunc {
return func(logger *Logger) {
logger.Logger.SetOutput(output)
}
}

// OptionalShardID returns an OptionFunc to configure a *Logger to include a
// shardID field.
func OptionalShardID(shardID int) OptionFunc {
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/logging/logging_test.go
Expand Up @@ -83,6 +83,7 @@ func TestLogger_UpdateDiscordrus(t *testing.T) {
func TestLogger_DiscordGoLogf(t *testing.T) {
log := testLogger()
log.DiscordrusWebHookURL = ""
log.UpdateDiscordrus()
log.UpdateLevel(logrus.InfoLevel.String())

logLevels := []int{
Expand Down Expand Up @@ -132,14 +133,13 @@ func TestLocale_Format(t *testing.T) {

func testLogger() *Logger {
log := New(
OptionalOutput(ioutil.Discard),
OptionalShardID(0),
OptionalLogLevel("info"),
OptionalTimezoneLocation("xyz"),
OptionalTimezoneLocation("America/New_York"),
OptionalDiscordrus("test"),
)

log.Logger.SetOutput(ioutil.Discard)

return log
}

0 comments on commit d413ee5

Please sign in to comment.