forked from ConnectAI-E/feishu-openai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add gpt support by directly request url
- Loading branch information
1 parent
f4a0bc3
commit 09323dc
Showing
9 changed files
with
198 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ go.work | |
.vscode | ||
.s | ||
|
||
./code/feishu_config.yaml | ||
config.yaml | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
APP_ID: cli_axxx | ||
APP_SECRET: xxx | ||
APP_ENCRYPT_KEY: xxxx | ||
APP_VERIFICATION_TOKEN: xxx | ||
OPENAI_KEY: XXX |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package services | ||
|
||
import ( | ||
"github.com/patrickmn/go-cache" | ||
"time" | ||
) | ||
|
||
type MsgService struct { | ||
cache *cache.Cache | ||
} | ||
|
||
var msgService *MsgService | ||
|
||
func (u MsgService) IfProcessed(msgId string) bool { | ||
get, b := u.cache.Get(msgId) | ||
if !b { | ||
return false | ||
} | ||
return get.(bool) | ||
} | ||
func (u MsgService) TagProcessed(msgId string) { | ||
u.cache.Set(msgId, true, time.Minute*5) | ||
} | ||
|
||
func (u MsgService) Clear(userId string) bool { | ||
u.cache.Delete(userId) | ||
return true | ||
} | ||
|
||
type MsgCacheInterface interface { | ||
IfProcessed(msg string) bool | ||
TagProcessed(msg string) | ||
} | ||
|
||
func GetMsgCache() MsgCacheInterface { | ||
if msgService == nil { | ||
msgService = &MsgService{cache: cache.New(10*time.Minute, 10*time.Minute)} | ||
} | ||
return msgService | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters