Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix some problem #74

Open
wants to merge 74 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
5f323ce
修改说明
vitaminx Jun 30, 2020
2ebdf2d
跟新更高效的脚本
vitaminx Jul 1, 2020
322417a
一键脚本改版
vitaminx Jul 1, 2020
6bd7c5c
Merge pull request #5 from vitaminx/vitaminx-patch-gdutilsinstall.sh-2.0
vitaminx Jul 1, 2020
a4daca2
Delete gdutilsinstall.sh
vitaminx Jul 1, 2020
dec3202
改版脚本错误修复
vitaminx Jul 1, 2020
7919b11
Merge pull request #6 from vitaminx/vitaminx-patch-gdutilsinstall.sh-2.1
vitaminx Jul 1, 2020
9026cab
nginx配置格式修改
vitaminx Jul 1, 2020
a86fdb3
Update gdutilsinstall.sh
vitaminx Jul 1, 2020
0c86a64
Update gdutilsinstall.sh
vitaminx Jul 1, 2020
a1264df
分脚本
vitaminx Jul 1, 2020
4eb211b
增加分脚本说明
vitaminx Jul 1, 2020
b5dab5e
Update gdutilscsinstall.sh
vitaminx Jul 1, 2020
4d7e665
Update gdutilscsinstall.sh
vitaminx Jul 1, 2020
d2089ba
未格式化
vitaminx Jul 1, 2020
0634d2d
未格式化
vitaminx Jul 1, 2020
1534cf1
格式化重新上传
vitaminx Jul 1, 2020
b57da42
格式错误
vitaminx Jul 1, 2020
1a307e4
格式错误
vitaminx Jul 1, 2020
833633c
修改换行符错误
vitaminx Jul 1, 2020
eb145be
Delete gdutilsinstall.sh
vitaminx Jul 1, 2020
16b5a31
Delete gdutilsbotinstall.sh
vitaminx Jul 1, 2020
8eed170
简化输入!
vitaminx Jul 1, 2020
cca1d0d
Delete gdutilsbotinstall.sh
vitaminx Jul 1, 2020
29c3bff
Delete gdutilsinstall.sh
vitaminx Jul 1, 2020
12945a4
更新绑定telegram ID
vitaminx Jul 1, 2020
f7cc2f1
终于支持绑定telegram的id了
vitaminx Jul 2, 2020
92f0a96
一键脚本说明
vitaminx Jul 2, 2020
3ce2ad9
Delete 批注 2020-07-02 123957.png
vitaminx Jul 2, 2020
29f7aa1
一键脚本说明
vitaminx Jul 2, 2020
1106ff8
test
vitaminx Jul 2, 2020
f73cc04
Delete 2020-07-02 123957.png
vitaminx Jul 2, 2020
ba07307
update tg.js gd.js by @iwestlin
liaojack8 Jul 3, 2020
e9e37d1
update readme
liaojack8 Jul 3, 2020
45c9955
translate tg.js, add percentage in task content, add one more button …
liaojack8 Jul 3, 2020
fae19ac
translate
liaojack8 Jul 3, 2020
ed246ab
translate router.js and add one more func. for tg_bot button
liaojack8 Jul 3, 2020
9265931
Update readme.md
liaojack8 Jul 3, 2020
97e7352
Update readme.md
liaojack8 Jul 4, 2020
5f42472
use ssl in nginx
liaojack8 Jul 4, 2020
85ccba7
update readme, and fix auto install sctript.
liaojack8 Jul 5, 2020
8e83c65
Update readme.md
liaojack8 Jul 5, 2020
33a8bdf
Update readme.md
liaojack8 Jul 5, 2020
8623faf
stop task while no sa token available and use_sa is true
liaojack8 Jul 5, 2020
ec71af7
pm2 start w/ args to prevent crash
liaojack8 Jul 5, 2020
b4f7409
Update readme.md
liaojack8 Jul 5, 2020
3f2bc21
Update readme.md
liaojack8 Jul 5, 2020
010c23a
Update readme.md
liaojack8 Jul 5, 2020
6fe42e3
add -D option to ./copy, means do not create new root while copying b…
liaojack8 Jul 5, 2020
5b67053
rm teamdrive: true by @iwestlin
liaojack8 Jul 5, 2020
cbcdeb5
add forceRefresh=true when call gtoken.getToken by @iwestlin
liaojack8 Jul 5, 2020
a12656e
更新config.js 可自訂sa路徑
liaojack8 Jul 5, 2020
a7602d9
fix
liaojack8 Jul 5, 2020
3b94cca
fix idiot problem
liaojack8 Jul 5, 2020
1327616
config.js can setting sa path, and install w/ my repo in script.
liaojack8 Jul 6, 2020
8d89d02
Update readme.md
liaojack8 Jul 6, 2020
136f929
fix problem in scripts
liaojack8 Jul 6, 2020
a731dc3
Merge branch 'master' of https://github.com/liaojack8/gd-utils-cht
liaojack8 Jul 6, 2020
ea8b6ad
fix problems in scripts
liaojack8 Jul 6, 2020
757c5f1
fix.
liaojack8 Jul 6, 2020
6f59f7c
can set copy dstID in config.js
liaojack8 Jul 6, 2020
83db45e
update readme.md
liaojack8 Jul 6, 2020
31ca1ea
update readme
liaojack8 Jul 6, 2020
54965cf
update bookmark func
liaojack8 Jul 6, 2020
0c867ff
Update config.js
liaojack8 Jul 6, 2020
a3b0c2c
修正tg bot按鈕顯示
liaojack8 Jul 6, 2020
2b05a01
let user can set the number of buttons per column in config.js
liaojack8 Jul 6, 2020
17f3a1a
Update readme.md
liaojack8 Jul 6, 2020
a8700a2
Merge branch 'master' of https://github.com/liaojack8/gd-utils-cht
liaojack8 Jul 6, 2020
db3a110
update readme
liaojack8 Jul 6, 2020
41b028c
修正tg,js中的誤植:`auth.js`, 並讓用戶可以自定義每列的按鈕數
liaojack8 Jul 6, 2020
ad67904
Let users can set the num of button per cols, and the path of SA json…
liaojack8 Jul 7, 2020
1b82b7e
fix SA_PATH in config.js
liaojack8 Jul 7, 2020
ecd5ed9
Update gd.js
liaojack8 Jul 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@ const AUTH = { // 如果您拥有service account的json授权文件,可将其
tg_whitelist: ['your_tg_username'] // 你的tg username(t.me/username),bot只会执行这个列表里的用户所发送的指令
}

module.exports = { AUTH, PARALLEL_LIMIT, RETRY_LIMIT, TIMEOUT_BASE, TIMEOUT_MAX, LOG_DELAY, PAGE_SIZE, DEFAULT_TARGET }
const BUTTON_LEVEL = 1 // Default as 1, all number large than 2 will be judge as 2.

const SA_PATH = '../sa' // Default as '../sa'

module.exports = { AUTH, PARALLEL_LIMIT, RETRY_LIMIT, TIMEOUT_BASE, TIMEOUT_MAX, LOG_DELAY, PAGE_SIZE, DEFAULT_TARGET, BUTTON_LEVEL, SA_PATH }
4 changes: 2 additions & 2 deletions src/gd.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const HttpsProxyAgent = require('https-proxy-agent')
const { GoogleToken } = require('gtoken')
const handle_exit = require('signal-exit')

const { AUTH, RETRY_LIMIT, PARALLEL_LIMIT, TIMEOUT_BASE, TIMEOUT_MAX, LOG_DELAY, PAGE_SIZE, DEFAULT_TARGET } = require('../config')
const { AUTH, RETRY_LIMIT, PARALLEL_LIMIT, TIMEOUT_BASE, TIMEOUT_MAX, LOG_DELAY, PAGE_SIZE, DEFAULT_TARGET, SA_PATH } = require('../config')
const { db } = require('../db')
const { make_table, make_tg_table, make_html, summary } = require('./summary')

Expand All @@ -18,7 +18,7 @@ const { https_proxy } = process.env
const axins = axios.create(https_proxy ? { httpsAgent: new HttpsProxyAgent(https_proxy) } : {})

const SA_BATCH_SIZE = 1000
const SA_FILES = fs.readdirSync(path.join(__dirname, '../sa')).filter(v => v.endsWith('.json'))
const SA_FILES = fs.readdirSync(path.join(__dirname, SA_PATH)).filter(v => v.endsWith('.json'))
SA_FILES.flag = 0
let SA_TOKENS = get_sa_batch()

Expand Down
46 changes: 43 additions & 3 deletions src/tg.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const { AUTH, DEFAULT_TARGET, USE_PERSONAL_AUTH } = require('../config')
const { tg_token } = AUTH
const gen_link = (fid, text) => `<a href="https://drive.google.com/drive/folders/${fid}">${text || fid}</a>`

if (!tg_token) throw new Error('请先在auth.js里设置tg_token')
if (!tg_token) throw new Error('请先在config.js里设置tg_token')
const { https_proxy } = process.env
const axins = axios.create(https_proxy ? { httpsAgent: new HttpsProxyAgent(https_proxy) } : {})

Expand Down Expand Up @@ -92,7 +92,23 @@ function get_target_by_alias (alias) {
}

function send_choice ({ fid, chat_id }) {
return sm({
if(BUTTON_LEVEL == 1){
return sm({
chat_id,
text: `识别出分享ID ${fid},请选择动作`,
reply_markup: {
inline_keyboard: [
[
{ text: '文件统计', callback_data: `count ${fid}` }
],
[
{ text: '开始复制', callback_data: `copy ${fid}` }
]
].concat(gen_bookmark_choices(fid))
}
})
}else{
return sm({
chat_id,
text: `识别出分享ID ${fid},请选择动作`,
reply_markup: {
Expand All @@ -103,7 +119,31 @@ function send_choice ({ fid, chat_id }) {
]
].concat(gen_bookmark_choices(fid))
}
})
})
}
}

// console.log(gen_bookmark_choices())
function gen_bookmark_choices (fid) {
let level = 1
if (BUTTON_LEVEL > 2){
level = 2
}else{
level = BUTTON_LEVEL
}
const gen_choice = v => ({text: `复制到 ${v.alias}`, callback_data: `copy ${fid} ${v.alias}`})
const records = db.prepare('select * from bookmark').all()
db.close()
const result = []
for (let i = 0; i < records.length; i++) {
const line = [gen_choice(records[i])]
for(let j = 0; j < level-1; j ++){
if (records[i+1]) line.push(gen_choice(records[i+1]))
i++
}
result.push(line)
}
return result
}

// console.log(gen_bookmark_choices())
Expand Down