File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
src/plugins/wechat-bot/wechat/task Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 29
29
开关端口转发:<code >op dkzf {on/off} {端口号}</code >
30
30
<br >
31
31
重启:<code >op reboot</code >
32
+ <br >
33
+ 获取公网ip:<code >op ip</code >
32
34
</details >
Original file line number Diff line number Diff line change @@ -146,11 +146,34 @@ async function restartRouter() {
146
146
}
147
147
}
148
148
149
+ // 获取公网ip
150
+ async function getPublicIp ( ) {
151
+ try {
152
+ const { stdout, stderr } = await sshIns . execCommand ( 'curl -s https://ip.3322.net/' )
153
+ if ( stderr ) {
154
+ return Promise . reject ( stderr )
155
+ }
156
+ await wechatBotIns . sendByTarget ( {
157
+ targetKey : 'wxid' ,
158
+ targetValue : wxData . wxid ,
159
+ content : stdout
160
+ } )
161
+ } catch ( e ) {
162
+ await wechatBotIns . sendByTarget ( {
163
+ targetKey : 'wxid' ,
164
+ targetValue : wxData . wxid ,
165
+ content : 'get public ip fail'
166
+ } )
167
+ return Promise . reject ( e )
168
+ }
169
+ }
170
+
149
171
// 指令映射方法
150
172
const fnMap = {
151
173
dkzf : portForwardSwitch ,
152
174
dkzfls : portForwardList ,
153
- reboot : restartRouter
175
+ reboot : restartRouter ,
176
+ ip : getPublicIp
154
177
}
155
178
156
179
async function handleOpenwrt ( data ) {
You can’t perform that action at this time.
0 commit comments