1 Star 1 Fork 10

zhaosongbing/G49shouting

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
AutoSignMachine.js 2.28 KB
一键复制 编辑 原始数据 按行查看 历史
2368693074 提交于 2021-03-09 12:14 . Add files via upload
const yargs = require('yargs/yargs')
const os = require('os')
const path = require('path')
const log = require('./utils/log')
function registerEvn(argvs) {
if (argvs.notify_sckey) {
// Server酱 SCKEY
process.env['notify_sckey'] = argvs.notify_sckey
}
if (argvs.notify_sctkey) {
// Server酱 SCKEY
process.env['notify_sctkey'] = argvs.notify_sctkey
}
if (argvs.notify_dingtalk_token) {
// dingtalk access_token
process.env['notify_dingtalk_token'] = argvs.notify_dingtalk_token
}
// see https://api.telegram.org/bot[[argvs.notify_tele_bottoken]]/getUpdates
// see @getuserID
if (argvs.notify_tele_bottoken && argvs.notify_tele_chatid) {
// 机器人TOKEN
process.env['notify_tele_bottoken'] = argvs.notify_tele_bottoken
// CHAT ID
process.env['notify_tele_chatid'] = argvs.notify_tele_chatid
}
if (argvs.notify_pushplus_token) {
// Server酱 SCKEY
process.env['notify_pushplus_token'] = argvs.notify_pushplus_token
}
if ('verbose' in argvs) {
process.env['asm_verbose'] = 'true'
}
// 统一环境变量
if ('TENCENTCLOUD_RUNENV' in process.env && process.env.TENCENTCLOUD_RUNENV === 'SCF') { // 腾讯云函数
process.env['asm_func'] = 'true'
process.env['asm_code_dir'] = process.env.USER_CODE_ROOT.replace(/[\/|\\]$/gi, "") + '/'
process.env['asm_save_data_dir'] = path.join('/tmp', '.AutoSignMachine')
} else if ('FC_FUNC_CODE_PATH' in process.env) { // 阿里云函数计算
process.env['asm_func'] = 'true'
process.env['asm_code_dir'] = process.env.FC_FUNC_CODE_PATH.replace(/[\/|\\]$/gi, "") + '/'
process.env['asm_save_data_dir'] = path.join('/tmp', '.AutoSignMachine')
} else {
process.env['asm_func'] = 'false'
process.env['asm_code_dir'] = ''
process.env['asm_save_data_dir'] = path.join(os.homedir(), '.AutoSignMachine')
}
}
/**
* 命令执行入口
*/
var AutoSignMachine_Run = (argv) => {
argv = (argv || process.argv).slice(2)
let argvs = yargs(argv)
.commandDir('commands')
.demand(1)
.config('config', 'JSON配置文件路径')
.help()
.alias('h', 'help')
.locale('en')
.showHelpOnFail(true, '使用--help查看有效选项')
.epilog('copyright 2020 LunnLew')
.argv;
registerEvn(argvs)
}
module.exports = {
run: AutoSignMachine_Run
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhaosongbing/G49shouting.git
git@gitee.com:zhaosongbing/G49shouting.git
zhaosongbing
G49shouting
G49shouting
main

搜索帮助

0d507c66 1850385 C8b1a773 1850385