Compare commits

..

No commits in common. "master" and "remove-forwarding-to-crisp" have entirely different histories.

5 changed files with 14 additions and 9 deletions

View File

@ -16,6 +16,4 @@ steps:
when:
status:
- success
branch:
- master

View File

@ -1,6 +1,6 @@
FROM golang:1.17-alpine
COPY . /app
FROM golang:alpine
ADD . /app
WORKDIR /app
RUN go get ; CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build
CMD ["./Crisp_Telegram_bot"]
CMD ./Crisp_Telegram_bot

10
main.go
View File

@ -16,6 +16,7 @@ import (
var bot *tgbotapi.BotAPI
var client *crisp.Client
// var redisClient *redis.Client
var config *viper.Viper
// CrispMessageInfo stores the original message
@ -48,9 +49,12 @@ func main() {
config = utils.GetConfig()
var chat_prefix = config.GetString("prefix")
var err error
log.Printf("Initializing Bot...")
bot, err = tgbotapi.NewBotAPI(config.GetString("telegram.key"))
if err != nil {
log.Panic(err)
}
@ -80,19 +84,19 @@ func main() {
// Register handler on 'message:send/text' namespace
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)
})
// Register handler on 'message:send/file' namespace
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)
})
// Register handler on 'message:send/animation' namespace
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)
})
},

View File

@ -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>

View File

@ -18,6 +18,10 @@ func GetConfig() *viper.Viper {
c.SetDefault("debug", true)
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.key", "")