Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
Voice Bot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Levatax
Voice Bot
Commits
9f389246
Commit
9f389246
authored
Aug 1, 2021
by
Ophestra
Browse files
Options
Downloads
Patches
Plain Diff
add some debug messages
parent
e4ecaec1
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
config.go
+1
-1
1 addition, 1 deletion
config.go
handler.go
+8
-1
8 additions, 1 deletion
handler.go
instance.go
+2
-0
2 additions, 0 deletions
instance.go
main.go
+17
-4
17 additions, 4 deletions
main.go
with
28 additions
and
6 deletions
config.go
+
1
−
1
View file @
9f389246
...
...
@@ -25,7 +25,7 @@ type configPayload struct {
}
func
init
()
{
flag
.
StringVar
(
&
configPath
,
"
-t
"
,
"server.conf"
,
"Specify configuration file location."
)
flag
.
StringVar
(
&
configPath
,
"
c
"
,
"server.conf"
,
"Specify configuration file location."
)
}
func
parse
()
{
...
...
This diff is collapsed.
Click to expand it.
handler.go
+
8
−
1
View file @
9f389246
...
...
@@ -16,26 +16,31 @@ var allowedChannels map[string]bool
func
handleChatInitiate
(
context
*
multiplexer
.
Context
)
{
// Lookup channel in allowed map
if
context
.
Channel
==
nil
||
!
allowedChannels
[
context
.
Channel
.
ID
]
{
log
.
Debug
(
"Chat initiate skipped on irrelevant channel."
)
return
}
// Get event
var
event
*
discordgo
.
VoiceStateUpdate
if
e
,
ok
:=
context
.
Event
.
(
*
discordgo
.
VoiceStateUpdate
);
!
ok
{
log
.
Debug
(
"Chat initiate skipped on incorrect event."
)
return
}
else
{
event
=
e
}
if
event
.
VoiceState
!=
nil
{
if
event
.
VoiceState
.
ChannelID
==
""
{
log
.
Debug
(
"Chat initiate skipped on empty channel ID."
)
return
}
}
else
{
log
.
Debug
(
"Chat initiate skipped on nil voice state."
)
return
}
// Lookup already existing channel
if
instancesUser
[
event
.
UserID
]
!=
nil
{
log
.
Debug
(
"Chat initiate skipped on existing channel owner."
)
return
}
...
...
@@ -53,12 +58,14 @@ func handleChatInitiate(context *multiplexer.Context) {
member
=
u
}
if
member
==
nil
{
log
.
Debug
(
"Chat initiate skipped on nil member."
)
return
}
// Create new instance
instance
:=
newInstance
(
member
)
if
instance
==
nil
{
log
.
Debug
(
"Chat initiate skipped on nil instance."
)
return
}
...
...
This diff is collapsed.
Click to expand it.
instance.go
+
2
−
0
View file @
9f389246
...
...
@@ -63,11 +63,13 @@ func newInstance(member *discordgo.Member) *chatInstance {
func
setupInstance
(
member
*
discordgo
.
Member
)
*
chatInstance
{
channelID
:=
guildMap
[
member
.
GuildID
]
if
channelID
==
""
{
log
.
Debug
(
"Instance setup skipped on empty channel ID."
)
return
nil
}
parentID
:=
categoryMap
[
channelID
]
if
parentID
==
""
{
log
.
Debug
(
"Instance setup skipped on emptu parent ID."
)
return
nil
}
...
...
This diff is collapsed.
Click to expand it.
main.go
+
17
−
4
View file @
9f389246
...
...
@@ -12,14 +12,27 @@ import (
"syscall"
)
var
session
*
discordgo
.
Session
var
m
=
multiplexer
.
New
()
var
system
=
multiplexer
.
NewCategory
(
"System"
,
"System-related utilities."
)
var
(
session
*
discordgo
.
Session
m
=
multiplexer
.
New
()
system
=
multiplexer
.
NewCategory
(
"System"
,
"System-related utilities."
)
verbose
bool
)
func
init
()
{
flag
.
BoolVar
(
&
verbose
,
"v"
,
false
,
"Start up with debug logging."
)
}
func
main
()
{
flag
.
Parse
()
parse
()
if
verbose
{
log
.
SetLevel
(
logrus
.
DebugLevel
)
}
else
{
log
.
SetLevel
(
logrus
.
InfoLevel
)
}
// Set discordgo log handler
discordgo
.
Logger
=
func
(
msgL
,
_
int
,
format
string
,
a
...
interface
{})
{
var
level
logrus
.
Level
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment