-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
40 lines (32 loc) · 1.1 KB
/
Copy pathmain.go
File metadata and controls
40 lines (32 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Your Go server will:
// Handle incoming Slack events. -> Slacker based implemnentation
// Forward user messages to the Gemini API. ->
// Send Gemini's responses back to Slack.
// Get env variables from a env file
// A new route for slack absed events
// a new function to send request to gemini and then get the response and then
// a new function to display back to slack
package main
import (
"github.com/PadamMantry04/Go_SlackBot/config"
Gemini "github.com/PadamMantry04/Go_SlackBot/handler"
"github.com/PadamMantry04/Go_SlackBot/logger"
"github.com/PadamMantry04/Go_SlackBot/slack"
)
func main() {
// Initialize logger
log := logger.InitLogger()
// Load environment variables
env := config.LoadEnv()
cs := Gemini.SetUpGemini(env.GEMINI_API_KEY) // returns a chat session
// Start the Slack bot
bot := slack.NewBot(env.BOT_ID, env.SLACK_BOT_TOKEN, env.SLACK_APP_TOKEN)
bot.Log = &log
slack.RegisterGeminiCommand(bot, cs)
// Start listening for Slack events
err := bot.Start()
if err != nil {
bot.Log.Fatal().Err(err).Msg("Failed to start Slack bot")
bot.Log.Fatal().AnErr("Error:", err)
}
}