MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / UpdateTelegramConfig

Method UpdateTelegramConfig

agent/app/service/agents_channels.go:109–145  ·  view source on GitHub ↗
(req dto.AgentTelegramConfigUpdateReq)

Source from the content-addressed store, hash-verified

107}
108
109func (a AgentService) UpdateTelegramConfig(req dto.AgentTelegramConfigUpdateReq) error {
110 agent, install, err := a.loadAgentAndInstall(req.AgentID)
111 if err != nil {
112 return err
113 }
114 if agent.AgentType == constant.AppHermesAgent {
115 return updateHermesChannelConfig(agent, install, func(confDir string) error {
116 return writeHermesTelegramChannelConfig(confDir, dto.AgentTelegramConfig{
117 Enabled: req.Enabled,
118 DmPolicy: req.DmPolicy,
119 AllowFrom: req.AllowFrom,
120 RequireMention: req.RequireMention,
121 GroupPolicy: req.GroupPolicy,
122 GroupAllowFrom: req.GroupAllowFrom,
123 Proxy: req.Proxy,
124 Streaming: req.Streaming,
125 DefaultAccount: req.DefaultAccount,
126 Bots: req.Bots,
127 })
128 })
129 }
130 return a.mutateAgentConfig(req.AgentID, func(_ *model.Agent, _ *model.AppInstall, conf map[string]interface{}) error {
131 setTelegramConfig(conf, dto.AgentTelegramConfig{
132 Enabled: req.Enabled,
133 DmPolicy: req.DmPolicy,
134 AllowFrom: req.AllowFrom,
135 RequireMention: req.RequireMention,
136 GroupPolicy: req.GroupPolicy,
137 GroupAllowFrom: req.GroupAllowFrom,
138 Proxy: req.Proxy,
139 Streaming: req.Streaming,
140 DefaultAccount: req.DefaultAccount,
141 Bots: req.Bots,
142 })
143 return nil
144 })
145}
146
147func (a AgentService) GetDiscordConfig(req dto.AgentIDReq) (*dto.AgentDiscordConfig, error) {
148 agent, _, err := a.loadAgentAndInstall(req.AgentID)

Callers

nothing calls this directly

Calls 5

loadAgentAndInstallMethod · 0.95
mutateAgentConfigMethod · 0.95
setTelegramConfigFunction · 0.85

Tested by

no test coverage detected