29 lines
622 B
Go
29 lines
622 B
Go
package controllers
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/sujit-baniya/fiber-boilerplate/pkg/services"
|
|
)
|
|
|
|
type TelegramController struct {
|
|
Service *services.TelegramService
|
|
}
|
|
|
|
func NewTelegramController(service *services.TelegramService) *TelegramController {
|
|
return &TelegramController{Service: service}
|
|
}
|
|
|
|
func (tc *TelegramController) SendMessage(chatID interface{}, message string) error {
|
|
if chatID == "" || message == "" {
|
|
return fmt.Errorf("chat_id and message are required")
|
|
}
|
|
|
|
err := tc.Service.SendMessage(chatID, message)
|
|
if err != nil {
|
|
return fmt.Errorf("error sending message: %v", err)
|
|
}
|
|
|
|
return nil
|
|
}
|