Documentation
¶
Overview ¶
Package sender 는 채널 종류마다 메시지를 실제로 보내는 어댑터다 — Slack Incoming Webhook, Telegram Bot API, SMTP.
공통 규칙 두 가지. 하나, 오류 문구에 비밀(웹훅 URL · 봇 토큰 · 비밀번호)을 싣지 않는다 — 문구가 발송 이력과 화면에 그대로 남는다. 둘, 실패를 다시 보낼 만한 것(네트워크 · 5xx · 429)과 설정이 틀린 것으로 나눠 port.SendError 로 돌려준다.
Index ¶
Constants ¶
const DefaultTelegramAPIURL = "https://api.telegram.org"
DefaultTelegramAPIURL 은 Telegram Bot API 주소다. 사내 프록시나 Local Bot API Server 를 쓰면 NULLUS_TELEGRAM_API_URL 로 바꾼다.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EmailSender ¶
type EmailSender struct {
// contains filtered or unexported fields
}
EmailSender 는 SMTP 로 보낸다. 서버 · 보안 방식 · 계정은 채널 설정, 비밀번호가 Secret 이다.
- starttls: 평문으로 붙어 STARTTLS 로 올린다. 서버가 STARTTLS 를 광고하지 않으면 **보내지 않는다** (평문으로 내려가면 비밀번호와 본문이 그대로 흐른다).
- tls: 처음부터 TLS 로 붙는다(465).
- none: 암호화하지 않는다. 도메인 검증이 인증과 함께 쓰지 못하게 막는다(사내 릴레이 전용).
인증은 PLAIN 을 먼저, 없으면 LOGIN 을 쓴다(Office 365 는 LOGIN 만 연다).
func NewEmailSender ¶
func NewEmailSender() *EmailSender
type SlackSender ¶
type SlackSender struct {
// contains filtered or unexported fields
}
SlackSender 는 Slack Incoming Webhook 으로 보낸다. 웹훅 URL 이 채널의 Secret 이다.
본문은 text 하나(mrkdwn)다 — 웹훅은 text 를 mrkdwn 으로 그리고, 블록 없이도 알림 미리보기에 같은 문구가 뜬다. Slack 호환 웹훅(Mattermost 등)도 text 를 받는다.
func NewSlackSender ¶
func NewSlackSender(client *http.Client) *SlackSender
type TelegramSender ¶
type TelegramSender struct {
// contains filtered or unexported fields
}
TelegramSender 는 Bot API 의 sendMessage 로 보낸다. 봇 토큰이 채널의 Secret, chat_id 가 설정이다.
func NewTelegramSender ¶
func NewTelegramSender(baseURL string, client *http.Client) *TelegramSender