MCPcopy
hub / github.com/liangliangyy/DjangoBlog / handler

Method handler

servermanager/robot.py:142–179  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

140 self.session[self.userid] = info
141
142 def handler(self):
143 info = self.message.content
144
145 if self.userinfo.isAdmin and info.upper() == 'EXIT':
146 self.userinfo = WxUserInfo()
147 self.save_session()
148 return "退出成功"
149 if info.upper() == 'ADMIN':
150 self.userinfo.isAdmin = True
151 self.save_session()
152 return "输入管理员密码"
153 if self.userinfo.isAdmin and not self.userinfo.isPasswordSet:
154 passwd = settings.WXADMIN
155 if settings.TESTING:
156 passwd = '123'
157 if passwd.upper() == get_sha256(get_sha256(info)).upper():
158 self.userinfo.isPasswordSet = True
159 self.save_session()
160 return "验证通过,请输入命令或者要执行的命令代码:输入helpme获得帮助"
161 else:
162 if self.userinfo.Count >= 3:
163 self.userinfo = WxUserInfo()
164 self.save_session()
165 return "超过验证次数"
166 self.userinfo.Count += 1
167 self.save_session()
168 return "验证失败,请重新输入管理员密码:"
169 if self.userinfo.isAdmin and self.userinfo.isPasswordSet:
170 if self.userinfo.Command != '' and info.upper() == 'Y':
171 return cmd_handler.run(self.userinfo.Command)
172 else:
173 if info.upper() == 'HELPME':
174 return cmd_handler.get_help()
175 self.userinfo.Command = info
176 self.save_session()
177 return "确认执行: " + info + " 命令?"
178
179 return ChatGPT.chat(info)
180
181
182class WxUserInfo():

Callers 2

test_validate_commentMethod · 0.95
echoFunction · 0.95

Calls 6

save_sessionMethod · 0.95
get_sha256Function · 0.90
WxUserInfoClass · 0.85
runMethod · 0.80
get_helpMethod · 0.80
chatMethod · 0.80

Tested by 1

test_validate_commentMethod · 0.76