Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
aon-tg-messenger
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Odysseus
aon-tg-messenger
Commits
7bed51d2
Commit
7bed51d2
authored
Nov 12, 2024
by
贾浩@五瓣科技
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update premium check
parent
6978ce5a
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
10 additions
and
13 deletions
+10
-13
dao.go
dao/dao.go
+0
-3
go.mod
go.mod
+1
-1
go.sum
go.sum
+2
-2
messenger.go
messenger/messenger.go
+3
-3
user.go
server/user.go
+2
-2
user.go
service/user.go
+2
-2
No files found.
dao/dao.go
View file @
7bed51d2
...
...
@@ -23,9 +23,6 @@ func New(_c *config.Config) (dao *Dao, err error) {
c
:
_c
,
}
// dsn := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8mb4&parseTime=True",
// _c.MySQL.User, _c.MySQL.Password, _c.MySQL.Host, _c.MySQL.Port, _c.MySQL.Database)
// dsn := fmt.Sprintf("host=%s user=%s password=%s dbname=%s port=%d sslmode=verify-ca sslrootcert=ca.crt",
dsn
:=
fmt
.
Sprintf
(
"host=%s user=%s password=%s dbname=%s port=%d"
,
_c
.
PGSQL
.
Host
,
_c
.
PGSQL
.
User
,
_c
.
PGSQL
.
Password
,
_c
.
PGSQL
.
Database
,
_c
.
PGSQL
.
Port
,
...
...
go.mod
View file @
7bed51d2
...
...
@@ -6,7 +6,7 @@ require (
github.com/BurntSushi/toml v0.3.1
github.com/gin-contrib/cors v1.7.2
github.com/gin-gonic/gin v1.10.0
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.
1
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.
2-0.20221020003057-99503a71186f
github.com/golang-jwt/jwt/v5 v5.2.1
github.com/sirupsen/logrus v1.9.0
github.com/tidwall/gjson v1.17.1
...
...
go.sum
View file @
7bed51d2
...
...
@@ -28,8 +28,8 @@ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJn
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8=
github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.
1 h1:wG8n/XJQ07TmjbITcGiUaOtXxdrINDz1b0J1w0SzqDc
=
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.
1
/go.mod h1:A2S0CWkNylc2phvKXWBBdD3K0iGnDBGbzRpISP2zBl8=
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.
2-0.20221020003057-99503a71186f h1:s4aF4gKdCrJGRBWW8mUHIzjQ3PClFfZYA7gfH++aJ+E
=
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.
2-0.20221020003057-99503a71186f
/go.mod h1:A2S0CWkNylc2phvKXWBBdD3K0iGnDBGbzRpISP2zBl8=
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk=
...
...
messenger/messenger.go
View file @
7bed51d2
...
...
@@ -57,7 +57,7 @@ func (m *Messenger) Start() {
}
}
func
(
m
*
Messenger
)
ExistGroupChat
(
userId
,
chatId
int64
)
(
exist
bool
,
err
error
)
{
func
(
m
*
Messenger
)
ExistGroupChat
(
userId
,
chatId
int64
)
(
exist
,
premium
bool
,
err
error
)
{
mem
,
err
:=
m
.
bot
.
GetChatMember
(
tgbotapi
.
GetChatMemberConfig
{
ChatConfigWithUser
:
tgbotapi
.
ChatConfigWithUser
{
ChatID
:
chatId
,
...
...
@@ -71,9 +71,9 @@ func (m *Messenger) ExistGroupChat(userId, chatId int64) (exist bool, err error)
switch
{
case
mem
.
HasLeft
(),
mem
.
WasKicked
()
:
return
false
,
nil
return
false
,
false
,
nil
default
:
return
true
,
nil
return
true
,
mem
.
User
.
IsPremium
,
nil
}
}
...
...
server/user.go
View file @
7bed51d2
...
...
@@ -19,12 +19,12 @@ func isJoined(c *gin.Context) {
return
}
joined
,
err
:=
srv
.
IsJoined
(
userId
,
chatId
)
joined
,
premium
,
err
:=
srv
.
IsJoined
(
userId
,
chatId
)
if
err
!=
nil
{
c
.
JSON
(
200
,
withError
(
constant
.
InternalError
))
return
}
c
.
JSON
(
200
,
withSuccess
(
gin
.
H
{
"joined"
:
joined
}))
c
.
JSON
(
200
,
withSuccess
(
gin
.
H
{
"joined"
:
joined
,
"isPremium"
:
premium
}))
return
}
...
...
service/user.go
View file @
7bed51d2
...
...
@@ -6,8 +6,8 @@ import (
log
"github.com/sirupsen/logrus"
)
func
(
s
*
Service
)
IsJoined
(
userId
,
chatId
int
)
(
joined
bool
,
err
error
)
{
joined
,
err
=
s
.
msger
.
ExistGroupChat
(
int64
(
userId
),
int64
(
chatId
))
func
(
s
*
Service
)
IsJoined
(
userId
,
chatId
int
)
(
joined
,
premium
bool
,
err
error
)
{
joined
,
premium
,
err
=
s
.
msger
.
ExistGroupChat
(
int64
(
userId
),
int64
(
chatId
))
if
err
!=
nil
{
log
.
WithError
(
err
)
.
Error
(
"exist group chat error"
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment