feat: sys-call framework + channel.weixin stub (v1.4.0)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
50
lib/channel/weixin.js
Normal file
50
lib/channel/weixin.js
Normal file
@@ -0,0 +1,50 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* channel.weixin — WeChat login via box-side WeChat SDK.
|
||||
*
|
||||
* method: login
|
||||
* params : { callId, timeout, emit }
|
||||
* returns: abort function (called on cancel)
|
||||
*
|
||||
* emit(msg) sends a sys-call reply back to VPS:
|
||||
* action:'event', event:'qrcode', data:{ url, expire, index }
|
||||
* action:'progress', event:'scanned', data:{ status:'waiting_confirm' }
|
||||
* action:'finish', event:'success', data:{ wxid }
|
||||
* action:'finish', event:'failed', code, message
|
||||
*
|
||||
* TODO: integrate with a concrete WeChat SDK (wechaty / itchat / custom binary).
|
||||
*/
|
||||
|
||||
const log = require('../logger');
|
||||
|
||||
function login({ callId, timeout = 180, emit }) {
|
||||
log.info('weixin', `login requested callId=${callId} timeout=${timeout}`);
|
||||
|
||||
// TODO: start WeChat SDK, get QR code, watch for scan / confirm / expire
|
||||
// Example skeleton:
|
||||
//
|
||||
// const bot = startWechatyBot();
|
||||
//
|
||||
// bot.on('scan', (url, status) => {
|
||||
// emit({ action: 'event', event: 'qrcode', data: { url, expire: 30, index: ++qrIndex } });
|
||||
// });
|
||||
// bot.on('login', (user) => {
|
||||
// emit({ action: 'finish', event: 'success', data: { wxid: user.id } });
|
||||
// });
|
||||
// bot.on('error', (err) => {
|
||||
// emit({ action: 'finish', event: 'failed', code: 1001, message: err.message });
|
||||
// });
|
||||
// bot.start();
|
||||
//
|
||||
// return () => bot.stop(); // ← abort function
|
||||
|
||||
// Temporary stub: immediately report not implemented
|
||||
emit({ action: 'finish', event: 'failed', code: 501, message: 'weixin SDK not implemented' });
|
||||
|
||||
return () => {
|
||||
log.info('weixin', `login cancelled callId=${callId}`);
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = { login };
|
||||
Reference in New Issue
Block a user