Compare commits
No commits in common. "master" and "692bcc57ea0dc01f823f6a1ffc24e4cf6a2ae93a" have entirely different histories.
master
...
692bcc57ea
@ -16,6 +16,4 @@ steps:
|
|||||||
when:
|
when:
|
||||||
status:
|
status:
|
||||||
- success
|
- success
|
||||||
branch:
|
|
||||||
- master
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
FROM golang:1.17-alpine
|
FROM golang:alpine
|
||||||
COPY . /app
|
ADD . /app
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN go get ; CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build
|
RUN go get ; CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build
|
||||||
CMD ["./Crisp_Telegram_bot"]
|
CMD ./Crisp_Telegram_bot
|
||||||
|
|
||||||
|
10
main.go
10
main.go
@ -16,6 +16,7 @@ import (
|
|||||||
var bot *tgbotapi.BotAPI
|
var bot *tgbotapi.BotAPI
|
||||||
var client *crisp.Client
|
var client *crisp.Client
|
||||||
|
|
||||||
|
// var redisClient *redis.Client
|
||||||
var config *viper.Viper
|
var config *viper.Viper
|
||||||
|
|
||||||
// CrispMessageInfo stores the original message
|
// CrispMessageInfo stores the original message
|
||||||
@ -48,9 +49,12 @@ func main() {
|
|||||||
config = utils.GetConfig()
|
config = utils.GetConfig()
|
||||||
|
|
||||||
var chat_prefix = config.GetString("prefix")
|
var chat_prefix = config.GetString("prefix")
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
log.Printf("Initializing Bot...")
|
log.Printf("Initializing Bot...")
|
||||||
|
|
||||||
bot, err = tgbotapi.NewBotAPI(config.GetString("telegram.key"))
|
bot, err = tgbotapi.NewBotAPI(config.GetString("telegram.key"))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panic(err)
|
log.Panic(err)
|
||||||
}
|
}
|
||||||
@ -80,19 +84,19 @@ func main() {
|
|||||||
|
|
||||||
// Register handler on 'message:send/text' namespace
|
// Register handler on 'message:send/text' namespace
|
||||||
reg.On("message:send/text", func(evt crisp.EventsReceiveTextMessage) {
|
reg.On("message:send/text", func(evt crisp.EventsReceiveTextMessage) {
|
||||||
text := fmt.Sprintf(`%s *%s: *%s`, chat_prefix, *evt.User.Nickname, *evt.Content)
|
text := fmt.Sprintf(`(%s) *%s(%s): *%s`, chat_prefix, *evt.User.Nickname, *evt.User.UserID, *evt.Content)
|
||||||
sendMsgToAdmins(text, *evt.WebsiteID, *evt.SessionID)
|
sendMsgToAdmins(text, *evt.WebsiteID, *evt.SessionID)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Register handler on 'message:send/file' namespace
|
// Register handler on 'message:send/file' namespace
|
||||||
reg.On("message:send/file", func(evt crisp.EventsReceiveFileMessage) {
|
reg.On("message:send/file", func(evt crisp.EventsReceiveFileMessage) {
|
||||||
text := fmt.Sprintf(`%s *%s: *[File](%s)`, chat_prefix, *evt.User.Nickname, evt.Content.URL)
|
text := fmt.Sprintf(`(%s) *%s(%s): *[File](%s)`, chat_prefix, *evt.User.Nickname, *evt.User.UserID, evt.Content.URL)
|
||||||
sendMsgToAdmins(text, *evt.WebsiteID, *evt.SessionID)
|
sendMsgToAdmins(text, *evt.WebsiteID, *evt.SessionID)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Register handler on 'message:send/animation' namespace
|
// Register handler on 'message:send/animation' namespace
|
||||||
reg.On("message:send/animation", func(evt crisp.EventsReceiveAnimationMessage) {
|
reg.On("message:send/animation", func(evt crisp.EventsReceiveAnimationMessage) {
|
||||||
text := fmt.Sprintf(`%s *%s: *[Animation](%s)`, chat_prefix, *evt.User.Nickname, evt.Content.URL)
|
text := fmt.Sprintf(`(%s) *%s(%s): *[Animation](%s)`, chat_prefix, *evt.User.Nickname, *evt.User.UserID, evt.Content.URL)
|
||||||
sendMsgToAdmins(text, *evt.WebsiteID, *evt.SessionID)
|
sendMsgToAdmins(text, *evt.WebsiteID, *evt.SessionID)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -1 +0,0 @@
|
|||||||
<script type="text/javascript">window.$crisp=[];window.CRISP_WEBSITE_ID="8635a202-94bb-49cc-a983-d69a45ca4be1";(function(){d=document;s=d.createElement("script");s.src="https://client.crisp.chat/l.js";s.async=1;d.getElementsByTagName("head")[0].appendChild(s);})();</script>
|
|
@ -18,6 +18,10 @@ func GetConfig() *viper.Viper {
|
|||||||
c.SetDefault("debug", true)
|
c.SetDefault("debug", true)
|
||||||
c.SetDefault("admins", []interface{}{})
|
c.SetDefault("admins", []interface{}{})
|
||||||
|
|
||||||
|
c.SetDefault("redis.host", "localhost:6379")
|
||||||
|
c.SetDefault("redis.db", 0)
|
||||||
|
c.SetDefault("redis.password", "")
|
||||||
|
|
||||||
c.SetDefault("crisp.identifier", "")
|
c.SetDefault("crisp.identifier", "")
|
||||||
c.SetDefault("crisp.key", "")
|
c.SetDefault("crisp.key", "")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user