- move initial response to middleware;
- projects parent channel as conf var; - finish moving Interfaces to the middleware;
This commit is contained in:
parent
98f401c6f4
commit
e668e0b50d
|
|
@ -28,6 +28,17 @@ type DiscordOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkPrivateMessaging(s *discordgo.Session, i *discordgo.InteractionCreate) error {
|
func checkPrivateMessaging(s *discordgo.Session, i *discordgo.InteractionCreate) error {
|
||||||
|
// Моментальный ответ для избежания столкновения с протуханием токена
|
||||||
|
initialResponse := discordgo.InteractionResponse{
|
||||||
|
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||||
|
Data: &discordgo.InteractionResponseData{
|
||||||
|
Flags: discordgo.MessageFlagsEphemeral,
|
||||||
|
Content: "👩🍳 Cooking your query..",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
s.InteractionRespond(i.Interaction, &initialResponse)
|
||||||
|
|
||||||
dchan, err := s.Channel(i.ChannelID)
|
dchan, err := s.Channel(i.ChannelID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -117,12 +117,6 @@ func (c *client) HandleTaskButtons() Component {
|
||||||
|
|
||||||
func (c *client) handleTaskButton(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
func (c *client) handleTaskButton(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||||
|
|
||||||
// Send an empty interaction response; ----------------------------------------------------------------
|
|
||||||
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
|
||||||
Type: discordgo.InteractionResponseUpdateMessage,
|
|
||||||
Data: &discordgo.InteractionResponseData{},
|
|
||||||
})
|
|
||||||
|
|
||||||
// Get assignee value; ---------------------------------------------------------------------------------
|
// Get assignee value; ---------------------------------------------------------------------------------
|
||||||
user := i.Member.User.Mention()
|
user := i.Member.User.Mention()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,17 +37,6 @@ func (c *client) createFolderHandler(s *discordgo.Session, i *discordgo.Interact
|
||||||
nameOption string = "folder_name"
|
nameOption string = "folder_name"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Моментальный ответ для избежания столкновения с протуханием токена
|
|
||||||
initialResponse := discordgo.InteractionResponse{
|
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
|
||||||
Data: &discordgo.InteractionResponseData{
|
|
||||||
Flags: discordgo.MessageFlagsEphemeral,
|
|
||||||
Content: "👩🍳 Cooking your query..",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
s.InteractionRespond(i.Interaction, &initialResponse)
|
|
||||||
|
|
||||||
// Определение переменной для ответа
|
// Определение переменной для ответа
|
||||||
var result string = "unexpected result"
|
var result string = "unexpected result"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,16 +57,6 @@ func (c *client) createRepoHandler(s *discordgo.Session, i *discordgo.Interactio
|
||||||
buildRepo = "build_repo"
|
buildRepo = "build_repo"
|
||||||
nameOption = "repo_name"
|
nameOption = "repo_name"
|
||||||
)
|
)
|
||||||
// Моментальный ответ для избежания столкновения с протуханием токена
|
|
||||||
initialResponse := discordgo.InteractionResponse{
|
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
|
||||||
Data: &discordgo.InteractionResponseData{
|
|
||||||
Flags: discordgo.MessageFlagsEphemeral,
|
|
||||||
Content: "👩🍳 Cooking your query..",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
s.InteractionRespond(i.Interaction, &initialResponse)
|
|
||||||
|
|
||||||
// Определение переменной для ответа
|
// Определение переменной для ответа
|
||||||
var result string = "unexpected result"
|
var result string = "unexpected result"
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"ticket-pimp/internal/domain"
|
"ticket-pimp/internal/domain"
|
||||||
|
"ticket-pimp/internal/helpers"
|
||||||
|
|
||||||
"github.com/bwmarrin/discordgo"
|
"github.com/bwmarrin/discordgo"
|
||||||
)
|
)
|
||||||
|
|
@ -21,17 +22,6 @@ func (c *client) GetInfo() Command {
|
||||||
|
|
||||||
func (c *client) getInfo(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
func (c *client) getInfo(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||||
|
|
||||||
// Моментальный ответ для избежания столкновения с протуханием токена
|
|
||||||
initialResponse := discordgo.InteractionResponse{
|
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
|
||||||
Data: &discordgo.InteractionResponseData{
|
|
||||||
Flags: discordgo.MessageFlagsEphemeral,
|
|
||||||
Content: "👩🍳 Cooking your query..",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
s.InteractionRespond(i.Interaction, &initialResponse)
|
|
||||||
|
|
||||||
var result string
|
var result string
|
||||||
|
|
||||||
// Get channel from the request
|
// Get channel from the request
|
||||||
|
|
@ -79,17 +69,6 @@ func (c *client) InitProjectFromChannel(minLength int) Command {
|
||||||
|
|
||||||
func (c *client) initProjectFromChannel(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
func (c *client) initProjectFromChannel(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||||
|
|
||||||
// Моментальный ответ для избежания столкновения с протуханием токена
|
|
||||||
initialResponse := discordgo.InteractionResponse{
|
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
|
||||||
Data: &discordgo.InteractionResponseData{
|
|
||||||
Flags: discordgo.MessageFlagsEphemeral,
|
|
||||||
Content: "👩🍳 Cooking your query..",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
s.InteractionRespond(i.Interaction, &initialResponse)
|
|
||||||
|
|
||||||
var result string
|
var result string
|
||||||
|
|
||||||
// Get channel from the request
|
// Get channel from the request
|
||||||
|
|
@ -160,17 +139,6 @@ func (c *client) CreateTicketHandler(repoNameMinLength int) Command {
|
||||||
|
|
||||||
func (c *client) createTicketHandler(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
func (c *client) createTicketHandler(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||||
|
|
||||||
// Моментальный ответ для избежания столкновения с протуханием токена
|
|
||||||
initialResponse := discordgo.InteractionResponse{
|
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
|
||||||
Data: &discordgo.InteractionResponseData{
|
|
||||||
Flags: discordgo.MessageFlagsEphemeral,
|
|
||||||
Content: "👩🍳 Cooking your query..",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
s.InteractionRespond(i.Interaction, &initialResponse)
|
|
||||||
|
|
||||||
var result string
|
var result string
|
||||||
// Access options in the order provided by the user.
|
// Access options in the order provided by the user.
|
||||||
options := i.ApplicationCommandData().Options
|
options := i.ApplicationCommandData().Options
|
||||||
|
|
@ -197,8 +165,8 @@ func (c *client) createTicketHandler(s *discordgo.Session, i *discordgo.Interact
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
edit := discordgo.ChannelEdit{
|
edit := discordgo.ChannelEdit{
|
||||||
Name: p.ShortName,
|
Name: p.ShortName + "-" + helpers.Cut(option.StringValue()),
|
||||||
ParentID: "1150719794853716028",
|
ParentID: c.conf.IsProjectChannel,
|
||||||
}
|
}
|
||||||
|
|
||||||
dchan, err = s.ChannelEdit(dchan.ID, &edit)
|
dchan, err = s.ChannelEdit(dchan.ID, &edit)
|
||||||
|
|
@ -210,7 +178,7 @@ func (c *client) createTicketHandler(s *discordgo.Session, i *discordgo.Interact
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("message send problem: %v\n", err)
|
log.Printf("message send problem: %v\n", err)
|
||||||
}
|
}
|
||||||
result = "Project " + p.ShortName + "Was created"
|
result = "Project " + p.ShortName + " was created"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,12 +27,12 @@ func InitRouter(wc controller.WorkflowController, conf *domain.DiscordConfig, tg
|
||||||
r.conf = conf
|
r.conf = conf
|
||||||
|
|
||||||
r.Commands = append(r.Commands,
|
r.Commands = append(r.Commands,
|
||||||
// r.CreateRepoHandler(3),
|
r.CreateRepoHandler(3),
|
||||||
// r.CreateFolderHandler(3),
|
r.CreateFolderHandler(3),
|
||||||
r.Ping(),
|
r.Ping(),
|
||||||
// r.CreateTicketHandler(3),
|
r.CreateTicketHandler(3),
|
||||||
// r.InitProjectFromChannel(3),
|
r.InitProjectFromChannel(3),
|
||||||
// r.GetInfo(),
|
r.GetInfo(),
|
||||||
)
|
)
|
||||||
r.Components = append(r.Components,
|
r.Components = append(r.Components,
|
||||||
r.HandleTaskButtons(),
|
r.HandleTaskButtons(),
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,10 @@ package handler
|
||||||
import (
|
import (
|
||||||
"ticket-pimp/adapters"
|
"ticket-pimp/adapters"
|
||||||
"ticket-pimp/internal/controller"
|
"ticket-pimp/internal/controller"
|
||||||
"ticket-pimp/internal/services"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Handler struct {
|
type Handler struct {
|
||||||
git services.IGit
|
git adapters.IGit
|
||||||
cloud adapters.ICloud
|
cloud adapters.ICloud
|
||||||
coda adapters.ICoda
|
coda adapters.ICoda
|
||||||
key string
|
key string
|
||||||
|
|
@ -16,7 +15,7 @@ type Handler struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewHandler(
|
func NewHandler(
|
||||||
git services.IGit,
|
git adapters.IGit,
|
||||||
cloud adapters.ICloud,
|
cloud adapters.ICloud,
|
||||||
coda adapters.ICoda,
|
coda adapters.ICoda,
|
||||||
controller *controller.WorkflowController,
|
controller *controller.WorkflowController,
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ package controller
|
||||||
import (
|
import (
|
||||||
"ticket-pimp/adapters"
|
"ticket-pimp/adapters"
|
||||||
"ticket-pimp/internal/domain"
|
"ticket-pimp/internal/domain"
|
||||||
"ticket-pimp/internal/services"
|
|
||||||
"ticket-pimp/internal/storage/db"
|
"ticket-pimp/internal/storage/db"
|
||||||
|
|
||||||
"github.com/bwmarrin/discordgo"
|
"github.com/bwmarrin/discordgo"
|
||||||
|
|
@ -11,7 +10,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type WorkflowController struct {
|
type WorkflowController struct {
|
||||||
IGit services.IGit
|
IGit adapters.IGit
|
||||||
ICloud adapters.ICloud
|
ICloud adapters.ICloud
|
||||||
ICoda adapters.ICoda
|
ICoda adapters.ICoda
|
||||||
pool *pgxpool.Pool
|
pool *pgxpool.Pool
|
||||||
|
|
@ -20,7 +19,7 @@ type WorkflowController struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWorkflowController(
|
func NewWorkflowController(
|
||||||
git services.IGit,
|
git adapters.IGit,
|
||||||
cloud adapters.ICloud,
|
cloud adapters.ICloud,
|
||||||
coda adapters.ICoda,
|
coda adapters.ICoda,
|
||||||
pool *pgxpool.Pool,
|
pool *pgxpool.Pool,
|
||||||
|
|
|
||||||
|
|
@ -14,13 +14,6 @@ type Coda struct {
|
||||||
Config domain.CodaConfig
|
Config domain.CodaConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
type ICoda interface {
|
|
||||||
ListDocs()
|
|
||||||
CreateApp(task domain.CodaApplication)
|
|
||||||
CreateTask(title string, desc string, creatorName string, creatorID string) (string, error)
|
|
||||||
GetRowLink(id string) (string, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewCodaClient(conf domain.CodaConfig) *Coda {
|
func NewCodaClient(conf domain.CodaConfig) *Coda {
|
||||||
|
|
||||||
client := NewClient().
|
client := NewClient().
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,6 @@ type Git struct {
|
||||||
conf *domain.GitConfig
|
conf *domain.GitConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
type IGit interface {
|
|
||||||
CreateRepo(name string) (*domain.Git, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewGit(conf domain.GitConfig) *Git {
|
func NewGit(conf domain.GitConfig) *Git {
|
||||||
headers := map[string]string{
|
headers := map[string]string{
|
||||||
"Accept": "application/vnd.github+json",
|
"Accept": "application/vnd.github+json",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue