Skip to content

Commit

Permalink
refactor: go folder structure (#501)
Browse files Browse the repository at this point in the history
  • Loading branch information
barbequeorbarbecue authored Jul 13, 2024
1 parent 223e480 commit cad5a37
Show file tree
Hide file tree
Showing 57 changed files with 336 additions and 336 deletions.
2 changes: 1 addition & 1 deletion apps/discord-bot/cmd/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/bwmarrin/discordgo"
"github.com/senchabot-opensource/monorepo/apps/discord-bot/internal/handler"
"github.com/senchabot-opensource/monorepo/apps/discord-bot/internal/service"
twsrvc "github.com/senchabot-opensource/monorepo/packages/gosenchabot/service/twitch"
twsrvc "github.com/senchabot-opensource/monorepo/service/twitch"
)

func main() {
Expand Down
6 changes: 3 additions & 3 deletions apps/discord-bot/internal/command/addcommand.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (

"github.com/bwmarrin/discordgo"
"github.com/senchabot-opensource/monorepo/command"
"github.com/senchabot-opensource/monorepo/packages/gosenchabot/models"
"github.com/senchabot-opensource/monorepo/model"
)

func (c *commands) AddCommandCommand(context context.Context, m *discordgo.MessageCreate, commandName string, params []string) (*models.CommandResponse, error) {
msgData := &models.MessageData{
func (c *commands) AddCommandCommand(context context.Context, m *discordgo.MessageCreate, commandName string, params []string) (*model.CommandResponse, error) {
msgData := &model.MessageData{
PlatformEntityID: m.GuildID,
UserName: m.Author.Username,
}
Expand Down
6 changes: 3 additions & 3 deletions apps/discord-bot/internal/command/addcommandalias.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (

"github.com/bwmarrin/discordgo"
"github.com/senchabot-opensource/monorepo/command"
"github.com/senchabot-opensource/monorepo/packages/gosenchabot/models"
"github.com/senchabot-opensource/monorepo/model"
)

func (c *commands) AddCommandAliasCommand(context context.Context, m *discordgo.MessageCreate, commandName string, params []string) (*models.CommandResponse, error) {
msgData := &models.MessageData{
func (c *commands) AddCommandAliasCommand(context context.Context, m *discordgo.MessageCreate, commandName string, params []string) (*model.CommandResponse, error) {
msgData := &model.MessageData{
PlatformEntityID: m.GuildID,
UserName: m.Author.Username,
}
Expand Down
6 changes: 3 additions & 3 deletions apps/discord-bot/internal/command/cmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (

"github.com/bwmarrin/discordgo"
"github.com/senchabot-opensource/monorepo/command"
"github.com/senchabot-opensource/monorepo/packages/gosenchabot/models"
"github.com/senchabot-opensource/monorepo/model"
)

func (c *commands) CmdsCommand(context context.Context, m *discordgo.MessageCreate, commandName string, params []string) (*models.CommandResponse, error) {
msgData := &models.MessageData{
func (c *commands) CmdsCommand(context context.Context, m *discordgo.MessageCreate, commandName string, params []string) (*model.CommandResponse, error) {
msgData := &model.MessageData{
PlatformEntityID: m.GuildID,
UserName: m.Author.Username,
}
Expand Down
10 changes: 5 additions & 5 deletions apps/discord-bot/internal/command/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import (
"github.com/bwmarrin/discordgo"
"github.com/senchabot-opensource/monorepo/apps/discord-bot/internal/command/helpers"
"github.com/senchabot-opensource/monorepo/apps/discord-bot/internal/service"
"github.com/senchabot-opensource/monorepo/packages/gosenchabot"
"github.com/senchabot-opensource/monorepo/packages/gosenchabot/models"
"github.com/senchabot-opensource/monorepo/helper"
"github.com/senchabot-opensource/monorepo/model"
)

type CommandFunc func(context context.Context, s *discordgo.Session, i *discordgo.InteractionCreate, service service.Service)

type CommandMap map[string]CommandFunc

type SysCommandFunc func(context context.Context, m *discordgo.MessageCreate, commandName string, params []string) (*models.CommandResponse, error)
type SysCommandFunc func(context context.Context, m *discordgo.MessageCreate, commandName string, params []string) (*model.CommandResponse, error)

type SysCommandMap map[string]SysCommandFunc

Expand Down Expand Up @@ -120,7 +120,7 @@ func (c *commands) Run(ctx context.Context, cmdName string, params []string, m *
}
if cmdData != nil {
cmdVar := helpers.GetCommandVariables(c.dS, cmdData, m)
formattedCommandContent := gosenchabot.FormatCommandContent(cmdVar)
formattedCommandContent := helper.FormatCommandContent(cmdVar)
c.Respond(ctx, m, cmdName, formattedCommandContent)
return
}
Expand Down Expand Up @@ -150,7 +150,7 @@ func (c *commands) Run(ctx context.Context, cmdName string, params []string, m *
}

cmdVar := helpers.GetCommandVariables(c.dS, cmdData, m)
formattedCommandContent := gosenchabot.FormatCommandContent(cmdVar)
formattedCommandContent := helper.FormatCommandContent(cmdVar)
c.Respond(ctx, m, cmdName, formattedCommandContent)
// GLOBAL COMMANDS
}
Expand Down
6 changes: 3 additions & 3 deletions apps/discord-bot/internal/command/deletecommand.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (

"github.com/bwmarrin/discordgo"
"github.com/senchabot-opensource/monorepo/command"
"github.com/senchabot-opensource/monorepo/packages/gosenchabot/models"
"github.com/senchabot-opensource/monorepo/model"
)

func (c *commands) DeleteCommandCommand(context context.Context, m *discordgo.MessageCreate, commandName string, params []string) (*models.CommandResponse, error) {
msgData := &models.MessageData{
func (c *commands) DeleteCommandCommand(context context.Context, m *discordgo.MessageCreate, commandName string, params []string) (*model.CommandResponse, error) {
msgData := &model.MessageData{
PlatformEntityID: m.GuildID,
UserName: m.Author.Username,
}
Expand Down
6 changes: 3 additions & 3 deletions apps/discord-bot/internal/command/deletecommandalias.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (

"github.com/bwmarrin/discordgo"
"github.com/senchabot-opensource/monorepo/command"
"github.com/senchabot-opensource/monorepo/packages/gosenchabot/models"
"github.com/senchabot-opensource/monorepo/model"
)

func (c *commands) DeleteCommandAliasCommand(context context.Context, m *discordgo.MessageCreate, commandName string, params []string) (*models.CommandResponse, error) {
msgData := &models.MessageData{
func (c *commands) DeleteCommandAliasCommand(context context.Context, m *discordgo.MessageCreate, commandName string, params []string) (*model.CommandResponse, error) {
msgData := &model.MessageData{
PlatformEntityID: m.GuildID,
UserName: m.Author.Username,
}
Expand Down
6 changes: 3 additions & 3 deletions apps/discord-bot/internal/command/deltwitch.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/senchabot-opensource/monorepo/apps/discord-bot/internal/service"
"github.com/senchabot-opensource/monorepo/apps/discord-bot/internal/service/streamer"
"github.com/senchabot-opensource/monorepo/config"
"github.com/senchabot-opensource/monorepo/packages/gosenchabot"
"github.com/senchabot-opensource/monorepo/helper"
)

func (c *commands) DelTwitchCommand(ctx context.Context, s *discordgo.Session, i *discordgo.InteractionCreate, service service.Service) {
Expand All @@ -19,7 +19,7 @@ func (c *commands) DelTwitchCommand(ctx context.Context, s *discordgo.Session, i
case "streamer":
options = options[0].Options
twitchUsername := options[0].StringValue()
twitchUsername = gosenchabot.ParseTwitchUsernameURLParam(twitchUsername)
twitchUsername = helper.ParseTwitchUsernameURLParam(twitchUsername)

response0, uInfo := streamer.GetTwitchUserInfo(twitchUsername)
if response0 != "" {
Expand Down Expand Up @@ -113,7 +113,7 @@ func (c *commands) DelTwitchCommand(ctx context.Context, s *discordgo.Session, i
case "custom-content":
options = options[0].Options
twitchUsername := options[0].StringValue()
twitchUsername = gosenchabot.ParseTwitchUsernameURLParam(twitchUsername)
twitchUsername = helper.ParseTwitchUsernameURLParam(twitchUsername)

response0, uInfo := streamer.GetTwitchUserInfo(twitchUsername)
if response0 != "" {
Expand Down
10 changes: 5 additions & 5 deletions apps/discord-bot/internal/command/helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"strings"

"github.com/bwmarrin/discordgo"
"github.com/senchabot-opensource/monorepo/packages/gosenchabot"
"github.com/senchabot-opensource/monorepo/packages/gosenchabot/models"
"github.com/senchabot-opensource/monorepo/helper"
"github.com/senchabot-opensource/monorepo/model"
)

func GetCommandVariables(dS *discordgo.Session, cmdData *models.BotCommand, m *discordgo.MessageCreate) *models.CommandVariable {
func GetCommandVariables(dS *discordgo.Session, cmdData *model.BotCommand, m *discordgo.MessageCreate) *model.CommandVariable {
var channelName string
chData, err := dS.Channel(m.ChannelID)
if err != nil {
Expand All @@ -20,7 +20,7 @@ func GetCommandVariables(dS *discordgo.Session, cmdData *models.BotCommand, m *d
channelName = chData.Name
}

return &models.CommandVariable{
return &model.CommandVariable{
CommandContent: cmdData.CommandContent,
UserName: m.Author.Username,
CurrentDate: &m.Timestamp,
Expand All @@ -39,7 +39,7 @@ func ParseMessage(message string) (string, []string) {

params := splitMsg[1:]

if !gosenchabot.CheckIfCommand(cmdName) {
if !helper.CheckIfCommand(cmdName) {
return "", nil
}

Expand Down
6 changes: 3 additions & 3 deletions apps/discord-bot/internal/command/purge.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/bwmarrin/discordgo"
"github.com/senchabot-opensource/monorepo/apps/discord-bot/internal/service"
"github.com/senchabot-opensource/monorepo/config"
"github.com/senchabot-opensource/monorepo/packages/gosenchabot"
"github.com/senchabot-opensource/monorepo/helper"
)

const FOURTEEN_DAYS = 24 * 14
Expand Down Expand Up @@ -52,14 +52,14 @@ func (c *commands) PurgeCommand(ctx context.Context, s *discordgo.Session, i *di
switch options[0].Name {
case "message-content":
for _, m := range messages {
if gosenchabot.CheckTimeOlderThan(m.Timestamp, FOURTEEN_DAYS) && gosenchabot.ContainsLowerCase(m.Content, optionValue) {
if helper.CheckTimeOlderThan(m.Timestamp, FOURTEEN_DAYS) && helper.ContainsLowerCase(m.Content, optionValue) {
messageIDs = append(messageIDs, m.ID)
}
}
content = "containing the characters `" + optionValue + "`"
case "username":
for _, m := range messages {
if gosenchabot.CheckTimeOlderThan(m.Timestamp, FOURTEEN_DAYS) && gosenchabot.ContainsLowerCase(m.Author.Username, optionValue) {
if helper.CheckTimeOlderThan(m.Timestamp, FOURTEEN_DAYS) && helper.ContainsLowerCase(m.Author.Username, optionValue) {
messageIDs = append(messageIDs, m.ID)
}
}
Expand Down
6 changes: 3 additions & 3 deletions apps/discord-bot/internal/command/settwitch.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/senchabot-opensource/monorepo/apps/discord-bot/internal/service"
"github.com/senchabot-opensource/monorepo/apps/discord-bot/internal/service/streamer"
"github.com/senchabot-opensource/monorepo/config"
"github.com/senchabot-opensource/monorepo/packages/gosenchabot"
"github.com/senchabot-opensource/monorepo/helper"
)

func (c *commands) SetTwitchCommand(ctx context.Context, s *discordgo.Session, i *discordgo.InteractionCreate, service service.Service) {
Expand All @@ -23,7 +23,7 @@ func (c *commands) SetTwitchCommand(ctx context.Context, s *discordgo.Session, i
twitchUsername := options[0].StringValue()

commandUsername := i.Member.User.Username
twitchUsername = gosenchabot.ParseTwitchUsernameURLParam(twitchUsername)
twitchUsername = helper.ParseTwitchUsernameURLParam(twitchUsername)

response0, uInfo := streamer.GetTwitchUserInfo(twitchUsername)
if response0 != "" {
Expand Down Expand Up @@ -128,7 +128,7 @@ func (c *commands) SetTwitchCommand(ctx context.Context, s *discordgo.Session, i
case "custom-content":
options = options[0].Options
twitchUsername := options[0].StringValue()
twitchUsername = gosenchabot.ParseTwitchUsernameURLParam(twitchUsername)
twitchUsername = helper.ParseTwitchUsernameURLParam(twitchUsername)
annoContent := options[1].StringValue()

response0, uInfo := streamer.GetTwitchUserInfo(twitchUsername)
Expand Down
4 changes: 2 additions & 2 deletions apps/discord-bot/internal/command/sozluk.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (

"github.com/bwmarrin/discordgo"
"github.com/senchabot-opensource/monorepo/command"
"github.com/senchabot-opensource/monorepo/packages/gosenchabot/models"
"github.com/senchabot-opensource/monorepo/model"
)

func (c *commands) SozlukCommand(context context.Context, m *discordgo.MessageCreate, commandName string, params []string) (*models.CommandResponse, error) {
func (c *commands) SozlukCommand(context context.Context, m *discordgo.MessageCreate, commandName string, params []string) (*model.CommandResponse, error) {
return command.SozlukCommand(params)

}
Expand Down
6 changes: 3 additions & 3 deletions apps/discord-bot/internal/command/updatecommand.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (

"github.com/bwmarrin/discordgo"
"github.com/senchabot-opensource/monorepo/command"
"github.com/senchabot-opensource/monorepo/packages/gosenchabot/models"
"github.com/senchabot-opensource/monorepo/model"
)

func (c *commands) UpdateCommandCommand(context context.Context, m *discordgo.MessageCreate, commandName string, params []string) (*models.CommandResponse, error) {
msgData := &models.MessageData{
func (c *commands) UpdateCommandCommand(context context.Context, m *discordgo.MessageCreate, commandName string, params []string) (*model.CommandResponse, error) {
msgData := &model.MessageData{
PlatformEntityID: m.GuildID,
UserName: m.Author.Username,
}
Expand Down
10 changes: 5 additions & 5 deletions apps/discord-bot/internal/service/event/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ import (
"time"

"github.com/bwmarrin/discordgo"
"github.com/senchabot-opensource/monorepo/packages/gosenchabot"
twsrvc "github.com/senchabot-opensource/monorepo/packages/gosenchabot/service/twitch"
"github.com/senchabot-opensource/monorepo/helper"
twsrvc "github.com/senchabot-opensource/monorepo/service/twitch"
)

func CreateLiveStreamScheduledEvent(s *discordgo.Session, msgContent string, msgEmbeds []*discordgo.MessageEmbed, guildId string) {
url := gosenchabot.GetURL("twitch.tv", msgContent)
url := helper.GetURL("twitch.tv", msgContent)
if url == "" && len(msgEmbeds) > 0 {
url = msgEmbeds[0].URL
}

username := gosenchabot.ParseTwitchUsernameURLParam(url)
username := helper.ParseTwitchUsernameURLParam(url)
if url == "" || username == "" {
return
}
Expand Down Expand Up @@ -59,7 +59,7 @@ func CheckLiveStreamScheduledEvents(s *discordgo.Session) {
continue
}

twitchUsername := gosenchabot.ParseTwitchUsernameURLParam(e.EntityMetadata.Location)
twitchUsername := helper.ParseTwitchUsernameURLParam(e.EntityMetadata.Location)
isLive, streamTitle := twsrvc.CheckTwitchStreamStatus(twitchUsername)
if len(streamTitle) > 100 {
streamTitle = streamTitle[0:90]
Expand Down
Loading

0 comments on commit cad5a37

Please sign in to comment.