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
910763c4
Commit
910763c4
authored
Aug 21, 2024
by
贾浩@五瓣科技
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update chat info
parent
6300183e
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
2 deletions
+51
-2
messenger.go
messenger/messenger.go
+10
-0
messenger_test.go
messenger/messenger_test.go
+2
-2
chat.go
server/chat.go
+24
-0
router.go
server/router.go
+2
-0
chat.go
service/chat.go
+13
-0
No files found.
messenger/messenger.go
View file @
910763c4
...
@@ -78,6 +78,16 @@ func (m *Messenger) ExistGroupChat(userId, chatId int64) (exist bool, err error)
...
@@ -78,6 +78,16 @@ func (m *Messenger) ExistGroupChat(userId, chatId int64) (exist bool, err error)
}
}
}
}
func
(
m
*
Messenger
)
GetChatInfo
(
chatId
int
)
(
title
,
name
string
,
err
error
)
{
chat
,
err
:=
m
.
bot
.
GetChat
(
tgbotapi
.
ChatInfoConfig
{
ChatConfig
:
tgbotapi
.
ChatConfig
{
ChatID
:
int64
(
chatId
)}})
if
err
!=
nil
{
log
.
WithError
(
err
)
.
Error
(
"get chat info error"
)
return
}
return
chat
.
Title
,
chat
.
UserName
,
nil
}
func
(
m
*
Messenger
)
handleNewUser
(
msg
*
tgbotapi
.
Message
)
(
caught
bool
)
{
func
(
m
*
Messenger
)
handleNewUser
(
msg
*
tgbotapi
.
Message
)
(
caught
bool
)
{
for
_
,
user
:=
range
msg
.
NewChatMembers
{
for
_
,
user
:=
range
msg
.
NewChatMembers
{
log
.
WithFields
(
log
.
Fields
{
log
.
WithFields
(
log
.
Fields
{
...
...
messenger/messenger_test.go
View file @
910763c4
...
@@ -8,7 +8,7 @@ func TestFunc(t *testing.T) {
...
@@ -8,7 +8,7 @@ func TestFunc(t *testing.T) {
token
:=
"6507972032:AAFAjaNz70ibA42kSH7k2gblyIQa1gWJiW0"
token
:=
"6507972032:AAFAjaNz70ibA42kSH7k2gblyIQa1gWJiW0"
m
:=
NewMessenger
(
token
,
nil
)
m
:=
NewMessenger
(
token
,
nil
)
m
.
ExistGroupChat
(
6689160806
,
-
1002174503961
)
//
m.ExistGroupChat(6689160806, -1002174503961)
m
.
Start
(
)
m
.
GetChatInfo
(
-
1002174503961
)
}
}
server/chat.go
0 → 100644
View file @
910763c4
package
server
import
(
"sdk_api/constant"
"strconv"
"github.com/gin-gonic/gin"
)
func
getChat
(
c
*
gin
.
Context
)
{
_chatId
:=
c
.
Query
(
"chatId"
)
chatId
,
_
:=
strconv
.
Atoi
(
_chatId
)
if
chatId
==
0
{
c
.
JSON
(
200
,
withError
(
constant
.
InvalidParam
))
return
}
title
,
username
,
err
:=
srv
.
GetChatInfo
(
chatId
)
if
err
!=
nil
{
c
.
JSON
(
200
,
withError
(
constant
.
InternalError
))
return
}
c
.
JSON
(
200
,
withSuccess
(
gin
.
H
{
"title"
:
title
,
"username"
:
username
}))
}
server/router.go
View file @
910763c4
...
@@ -17,4 +17,6 @@ func initRouter(e *gin.Engine) {
...
@@ -17,4 +17,6 @@ func initRouter(e *gin.Engine) {
user
.
GET
(
"/active"
,
active
)
user
.
GET
(
"/active"
,
active
)
}
}
v1
.
GET
(
"/chat"
,
getChat
)
}
}
service/chat.go
0 → 100644
View file @
910763c4
package
service
import
(
log
"github.com/sirupsen/logrus"
)
func
(
s
*
Service
)
GetChatInfo
(
chatId
int
)
(
title
,
name
string
,
err
error
)
{
title
,
name
,
err
=
s
.
msger
.
GetChatInfo
(
chatId
)
if
err
!=
nil
{
log
.
WithError
(
err
)
.
Error
(
"get chat info error"
)
}
return
}
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