Compare commits
38 commits
Author | SHA1 | Date | |
---|---|---|---|
20b2e75c9c | |||
c8539b048e | |||
39a5d2543b | |||
fb6596f72f | |||
d28f3318e4 | |||
440eaf8853 | |||
ee2b6b522c | |||
734c8cc199 | |||
1b5da461ef | |||
11add65d0e | |||
ccd6dc8ce0 | |||
092207c172 | |||
f4d008b25c | |||
396cbb1911 | |||
1626c0ead5 | |||
5c7fcfbc04 | |||
8c4aaa65fe | |||
65d5ae07e3 | |||
6bbd97c9d9 | |||
d16c51d01a | |||
966e8d2d7a | |||
7954c3d31d | |||
67cc9d0463 | |||
781f30207d | |||
5d53280e3c | |||
a099c6fec6 | |||
93eb243167 | |||
1cd7e8ea5e | |||
0e1cb1e4d9 | |||
1868e82330 | |||
d1dd661b9a | |||
1e6022df08 | |||
9a020253de | |||
090a1cdc33 | |||
d4b7880715 | |||
7997128fd0 | |||
5ffbac8dd2 | |||
be2cc7ddfa |
7 changed files with 73 additions and 33 deletions
23
.drone.yml
23
.drone.yml
|
@ -1,23 +0,0 @@
|
|||
kind: pipeline
|
||||
name: default
|
||||
|
||||
steps:
|
||||
- name: docker
|
||||
image: plugins/docker
|
||||
settings:
|
||||
registry:
|
||||
from_secret: CI_REGISTRY
|
||||
username:
|
||||
from_secret: CI_REGISTRY_USER
|
||||
password:
|
||||
from_secret: CI_REGISTRY_PASSWORD
|
||||
repo:
|
||||
from_secret: CI_APP_IMAGE
|
||||
tags:
|
||||
- latest
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- push
|
||||
branch:
|
||||
- master
|
51
.gitea/workflows/deploy.yml
Normal file
51
.gitea/workflows/deploy.yml
Normal file
|
@ -0,0 +1,51 @@
|
|||
name: default
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: docker:dind
|
||||
options: --privileged
|
||||
steps:
|
||||
- name: Set Up Dependencies
|
||||
run: apk add --no-cache nodejs bash curl
|
||||
|
||||
- name: Start Docker
|
||||
run: |
|
||||
dockerd-entrypoint.sh &
|
||||
|
||||
until docker info > /dev/null 2>&1; do
|
||||
echo "Waiting for Docker daemon..."
|
||||
sleep 1
|
||||
done
|
||||
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Login to Docker Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: git.neur0tx.site
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.DOCKER_PUSH_TOKEN }}
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: git.neur0tx.site/neur0toxine/vegapokerbot:latest
|
||||
|
||||
- name: Deploy
|
||||
uses: actions/ssh-action@v1
|
||||
with:
|
||||
host: ${{ secrets.DEPLOYER_HOST }}
|
||||
username: ${{ secrets.DEPLOYER_USERNAME }}
|
||||
key: ${{ secrets.DEPLOYER_KEY }}
|
||||
port: ${{ secrets.DEPLOYER_PORT }}
|
||||
script: bash vegapokerbot.sh
|
|
@ -24,7 +24,7 @@ func (c *Chat) ByID(id uint64) (*model.Chat, error) {
|
|||
|
||||
func (c *Chat) ByTelegramID(id int64) (*model.Chat, error) {
|
||||
var chat model.Chat
|
||||
if err := c.db.Model(model.Chat{TelegramID: id}).First(&chat).Error; err != nil {
|
||||
if err := c.db.Model(&model.Chat{}).Where("telegram_id = ?", id).First(&chat).Error; err != nil {
|
||||
return nil, util.HandleRecordNotFound(err)
|
||||
}
|
||||
return &chat, nil
|
||||
|
@ -32,7 +32,7 @@ func (c *Chat) ByTelegramID(id int64) (*model.Chat, error) {
|
|||
|
||||
func (c *Chat) ByTelegramIDWithIntegrations(id int64) (*model.Chat, error) {
|
||||
var chat model.Chat
|
||||
if err := c.db.Model(model.Chat{TelegramID: id}).Preload("Integrations").First(&chat).Error; err != nil {
|
||||
if err := c.db.Model(&model.Chat{}).Where("telegram_id = ?", id).Preload("Integrations").First(&chat).Error; err != nil {
|
||||
return nil, util.HandleRecordNotFound(err)
|
||||
}
|
||||
return &chat, nil
|
||||
|
@ -47,6 +47,9 @@ func (c *Chat) ByIDWithIntegrations(id uint64) (*model.Chat, error) {
|
|||
}
|
||||
|
||||
func (c *Chat) Save(chat *model.Chat) error {
|
||||
if chat.ID == 0 {
|
||||
return c.db.Create(chat).Error
|
||||
}
|
||||
return c.db.Model(chat).Save(chat).Error
|
||||
}
|
||||
|
||||
|
|
|
@ -16,13 +16,16 @@ func NewIntegration(db *gorm.DB) *Integration {
|
|||
|
||||
func (r *Integration) LoadForChatAndType(chatID uint64, typ model.IntegrationType) (*model.Integration, error) {
|
||||
var integration model.Integration
|
||||
if err := r.db.Model(model.Integration{ChatID: chatID, Type: typ}).First(&integration).Error; err != nil {
|
||||
if err := r.db.Model(&model.Integration{}).Where(`chat_id = ? and "type" = ?`, chatID, typ).First(&integration).Error; err != nil {
|
||||
return nil, util.HandleRecordNotFound(err)
|
||||
}
|
||||
return &integration, nil
|
||||
}
|
||||
|
||||
func (r *Integration) Save(integration *model.Integration) error {
|
||||
if integration.ID == 0 {
|
||||
return r.db.Create(integration).Error
|
||||
}
|
||||
return r.db.Model(integration).Save(integration).Error
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ func (u *User) ByID(id uint64) (*model.User, error) {
|
|||
|
||||
func (u *User) ByTelegramID(id int64) (*model.User, error) {
|
||||
var user model.User
|
||||
if err := u.db.Model(model.User{TelegramID: id}).First(&user).Error; err != nil {
|
||||
if err := u.db.Model(&model.User{}).Where("telegram_id = ?", id).First(&user).Error; err != nil {
|
||||
return nil, util.HandleRecordNotFound(err)
|
||||
}
|
||||
return &user, nil
|
||||
|
@ -32,7 +32,7 @@ func (u *User) ByTelegramID(id int64) (*model.User, error) {
|
|||
|
||||
func (u *User) ByTelegramIDs(ids []int64) ([]model.User, error) {
|
||||
var users []model.User
|
||||
if err := u.db.Model(model.User{}).Where("telegram_id in (?)", ids).Find(&users).Error; err != nil {
|
||||
if err := u.db.Model(&model.User{}).Where("telegram_id in (?)", ids).Find(&users).Error; err != nil {
|
||||
return nil, util.HandleRecordNotFound(err)
|
||||
}
|
||||
return users, nil
|
||||
|
@ -47,5 +47,8 @@ func (u *User) ByIDWithChats(id uint64) (*model.User, error) {
|
|||
}
|
||||
|
||||
func (u *User) Save(user *model.User) error {
|
||||
if user.ID == 0 {
|
||||
return u.db.Create(user).Error
|
||||
}
|
||||
return u.db.Model(user).Save(user).Error
|
||||
}
|
||||
|
|
|
@ -41,18 +41,21 @@ func (h *Poll) Handle(wh telego.Update) error {
|
|||
return err
|
||||
}
|
||||
loc := h.Localizer(user.Language)
|
||||
_ = loc
|
||||
if len(wh.Message.Entities) == 0 ||
|
||||
(len(wh.Message.Entities) > 0 && wh.Message.Entities[0].Type != telego.EntityTypeBotCommand) ||
|
||||
(len(wh.Message.Entities) > 0 && wh.Message.Entities[0].Offset != 0) {
|
||||
return nil
|
||||
}
|
||||
|
||||
taskInfo := strings.TrimSpace(wh.Message.Text[wh.Message.Entities[0].Length:])
|
||||
if taskInfo == "" && wh.Message.ReplyToMessage != nil {
|
||||
taskInfo = wh.Message.ReplyToMessage.Text
|
||||
}
|
||||
|
||||
var (
|
||||
taskID int
|
||||
canRedmine bool
|
||||
)
|
||||
taskInfo := strings.TrimSpace(wh.Message.Text[wh.Message.Entities[0].Length:])
|
||||
if taskInfo != "" {
|
||||
for _, integrationData := range chat.Integrations {
|
||||
id, info := integration.New(integrationData, h.App.Log()).GetTaskInfo(taskInfo)
|
||||
|
|
|
@ -44,7 +44,7 @@ func (p Payload) Vote() (val Vote) {
|
|||
}
|
||||
|
||||
func (p Payload) KeyboardChoice() (val KBChooserData) {
|
||||
if p.Action != PayloadActionVote {
|
||||
if p.Action != PayloadActionChooseKeyboard {
|
||||
return
|
||||
}
|
||||
_ = json.Unmarshal(p.Data, &val)
|
||||
|
@ -65,7 +65,7 @@ type Member struct {
|
|||
}
|
||||
|
||||
type KBChooserData struct {
|
||||
Type uint8 `json:"k"`
|
||||
Type int64 `json:"k"`
|
||||
}
|
||||
|
||||
type Vote struct {
|
||||
|
@ -83,7 +83,7 @@ func NewKeyboardChooserPayload(userID, chatID int64, kbType uint8) *Payload {
|
|||
User: userID,
|
||||
Chat: chatID,
|
||||
Data: marshal(KBChooserData{
|
||||
Type: kbType,
|
||||
Type: int64(kbType),
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue