Skip to content

Commit

Permalink
delete unused variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Nzt3-gh committed Oct 26, 2023
1 parent 82393b7 commit 862b47a
Showing 1 changed file with 4 additions and 39 deletions.
43 changes: 4 additions & 39 deletions utils/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,61 +7,26 @@ import (
"encoding/hex"
"errors"
"net/http"
// "net/url"
// "path"
// "strconv"
// "strings"

// "github.com/labstack/echo/v4"
"github.com/traPtitech/go-traq"
)

const baseURL = "https://q.trap.jp/api/v3"


// RequestWebhook q.trap/jp にメッセージを送信します。
func RequestWebhook(message, secret, channelID, webhookID string, embed int) error {
// u, err := url.Parse(baseURL + "/webhooks")
// if err != nil {
// return err
// }
// u.Path = path.Join(u.Path, webhookID)
// query := u.Query()
// query.Set("embed", strconv.Itoa(embed))
// u.RawQuery = query.Encode()

// req, err := http.NewRequest(http.MethodPost, u.String(), strings.NewReader(message))
// if err != nil {
// return err
// }
// req.Header.Set(echo.HeaderContentType, echo.MIMETextPlain)
// req.Header.Set("X-TRAQ-Signature", calcSignature(message, secret))
// if channelID != "" {
// req.Header.Set("X-TRAQ-Channel-Id", channelID)
// }

// res, err := http.DefaultClient.Do(req)
// if err != nil {
// return err
// }
// if res.StatusCode >= 400 {
// return errors.New(http.StatusText(res.StatusCode))
// }

// ここから go-traq 書き換え
xTRAQSignature := calcSignature(message, secret)
configuration := traq.NewConfiguration()
apiClient := traq.NewAPIClient(configuration)
apiClient := traq.NewAPIClient(configuration)

res, err := apiClient.WebhookApi.PostWebhook(context.Background(),webhookID).XTRAQChannelId(channelID).XTRAQSignature(xTRAQSignature).Embed(int32(embed)).Body(message).Execute()
if err != nil{
res, err := apiClient.WebhookApi.PostWebhook(context.Background(), webhookID).XTRAQChannelId(channelID).XTRAQSignature(xTRAQSignature).Embed(int32(embed)).Body(message).Execute()
if err != nil {
return err
}
if res.StatusCode >= 400 {
return errors.New(http.StatusText(res.StatusCode))
}

// ここまで go-traq 書き換え

return nil
}

Expand Down

0 comments on commit 862b47a

Please sign in to comment.