fix: issues
This commit is contained in:
3
.vscode/launch.json
vendored
3
.vscode/launch.json
vendored
@@ -13,7 +13,8 @@
|
||||
"args": [
|
||||
"export",
|
||||
"--alias",
|
||||
"yunpanshare"
|
||||
"yunpanshare",
|
||||
"--history",
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
@@ -15,7 +15,7 @@ func (t *TClient) Channel(ctx context.Context, channel *tg.Channel, cfg *Channel
|
||||
|
||||
request := &tg.MessagesGetHistoryRequest{
|
||||
Peer: inputPeer,
|
||||
Limit: 1,
|
||||
Limit: 10,
|
||||
}
|
||||
|
||||
if modeHistory { // 提供此ID供遍历历史消息
|
||||
|
||||
@@ -17,6 +17,9 @@ type ChannelConfig struct {
|
||||
}
|
||||
|
||||
func NewChannelConfig(channelID int64) *ChannelConfig {
|
||||
if channelID == 0 {
|
||||
panic("channel id is required")
|
||||
}
|
||||
return &ChannelConfig{ID: channelID}
|
||||
}
|
||||
|
||||
@@ -53,7 +56,7 @@ func (c *ChannelConfig) file(_ context.Context) (string, error) {
|
||||
// if file not exists then create it
|
||||
if _, err := os.Stat(channelConfigFile); os.IsNotExist(err) {
|
||||
// create config file
|
||||
data, _ := json.Marshal(&ChannelConfig{ID: channelID})
|
||||
data, _ := json.Marshal(c)
|
||||
if err := os.WriteFile(channelConfigFile, data, 0o644); err != nil {
|
||||
return "", errors.Wrap(err, "write channel config")
|
||||
}
|
||||
|
||||
@@ -47,7 +47,11 @@ func exportCmd(ctx context.Context) error {
|
||||
}
|
||||
}
|
||||
|
||||
cfg := NewChannelConfig(channel.ID)
|
||||
if channel.GetID() == 0 {
|
||||
return errors.New("channel not found")
|
||||
}
|
||||
|
||||
cfg := NewChannelConfig(channel.GetID())
|
||||
if err := cfg.Read(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user