update router.js, consider more than 1 whitespaces in bot cmd
This commit is contained in:
		
							parent
							
								
									2bb7b1abbf
								
							
						
					
					
						commit
						de9a6950f5
					
				@ -51,7 +51,7 @@ router.post('/api/gdurl/tgbot', async ctx => {
 | 
				
			|||||||
  if (callback_query) {
 | 
					  if (callback_query) {
 | 
				
			||||||
    const { id, data } = callback_query
 | 
					    const { id, data } = callback_query
 | 
				
			||||||
    const chat_id = callback_query.from.id
 | 
					    const chat_id = callback_query.from.id
 | 
				
			||||||
    const [action, fid, target] = data.split(' ')
 | 
					    const [action, fid, target] = data.split(' ').filter(v => v)
 | 
				
			||||||
    if (action === 'count') {
 | 
					    if (action === 'count') {
 | 
				
			||||||
      if (counting[fid]) return sm({ chat_id, text: fid + ' 正在統計,請稍候' })
 | 
					      if (counting[fid]) return sm({ chat_id, text: fid + ' 正在統計,請稍候' })
 | 
				
			||||||
      counting[fid] = true
 | 
					      counting[fid] = true
 | 
				
			||||||
@ -89,7 +89,7 @@ router.post('/api/gdurl/tgbot', async ctx => {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
  if (text.startsWith('/help')) return send_help(chat_id)
 | 
					  if (text.startsWith('/help')) return send_help(chat_id)
 | 
				
			||||||
  if (text.startsWith('/bm')) {
 | 
					  if (text.startsWith('/bm')) {
 | 
				
			||||||
    const [cmd, action, alias, target] = text.split(' ').map(v => v.trim())
 | 
					    const [cmd, action, alias, target] = text.split(' ').map(v => v.trim()).filter(v => v)
 | 
				
			||||||
    if (!action) return send_all_bookmarks(chat_id)
 | 
					    if (!action) return send_all_bookmarks(chat_id)
 | 
				
			||||||
    if (action === 'set') {
 | 
					    if (action === 'set') {
 | 
				
			||||||
      if (!alias || !target) return sm({ chat_id, text: '標籤名和dstID不能為空' })
 | 
					      if (!alias || !target) return sm({ chat_id, text: '標籤名和dstID不能為空' })
 | 
				
			||||||
@ -115,7 +115,7 @@ router.post('/api/gdurl/tgbot', async ctx => {
 | 
				
			|||||||
      delete counting[fid]
 | 
					      delete counting[fid]
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  } else if (text.startsWith('/copy')) {
 | 
					  } else if (text.startsWith('/copy')) {
 | 
				
			||||||
    let target = text.replace('/copy', '').replace(' -u', '').trim().split(' ').map(v => v.trim())[1]
 | 
					    let target = text.replace('/copy', '').replace(' -u', '').trim().split(' ').map(v => v.trim()).filter(v => v)[1]
 | 
				
			||||||
    target = get_target_by_alias(target) || target
 | 
					    target = get_target_by_alias(target) || target
 | 
				
			||||||
    if (target && !validate_fid(target)) return sm({ chat_id, text: `目標ID ${target} 格式不正確` })
 | 
					    if (target && !validate_fid(target)) return sm({ chat_id, text: `目標ID ${target} 格式不正確` })
 | 
				
			||||||
    const update = text.endsWith(' -u')
 | 
					    const update = text.endsWith(' -u')
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user