Skip to content

Commit

Permalink
Merge pull request #13 from fxxkrlab/develop
Browse files Browse the repository at this point in the history
Update version 0.2.0-beta.6.1(merged from develop branch)
  • Loading branch information
fxxkrlab authored Jul 26, 2020
2 parents b661a0b + d439e00 commit 115df17
Show file tree
Hide file tree
Showing 17 changed files with 403 additions and 145 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[![iCopy Telegram-Bot](https://img.shields.io/badge/iCopy-Telegram%20BOT-red?style=flat-square&logo=appveyor)](https://bbs.jsu.net/c/official-project/icopy/6)
[![Programming Language](https://img.shields.io/badge/LANGUAGE-Python%203.6%2B-success?style=flat-square&logo=appveyor)](https://bbs.jsu.net/c/official-project/icopy/6)
[![Version](https://img.shields.io/badge/Version-0.2.0--beta.6-ff69b4?style=flat-square&logo=appveyor)](https://bbs.jsu.net/c/official-project/icopy/6)
[![Version](https://img.shields.io/badge/Version-0.2.0--beta.6.1-ff69b4?style=flat-square&logo=appveyor)](https://bbs.jsu.net/c/official-project/icopy/6)
[![License](https://img.shields.io/github/license/fxxkrlab/iCopy?style=flat-square&logo=appveyor)](https://bbs.jsu.net/c/official-project/icopy/6)
[![DATABASE](https://img.shields.io/badge/DATABASE-MongoDB-brightgreen?style=flat-square&logo=appveyor)](https://github.com/mongodb/mongo)
[![Stars](https://img.shields.io/github/stars/fxxkrlab/iCopy?style=flat-square&logo=appveyor)](https://github.com/fxxkrlab/iCopy)
Expand Down
11 changes: 7 additions & 4 deletions config/text.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,15 @@ task_is_in_queue = "任务正在队列中"
finished_could_be_check = "只能查询已完成的任务"
finished_could_be_dedupe = "只能对已完成的任务进行去重"
support_error = "指定的任务不支持查询"
request_target_folder = "请选择目标盘 或 文件夹"
request_target_folder = "请选择目标收藏夹"
ready_to_purge = "正在准备清空回收站"
purging = "正在清空回收站,请耐心等待\n如果同时存在复制任务,则会影响复制与清空回收站双方的准确性"
purging_done = "已清空回收站"
request_dedupe_mode = "请选择去重模式 规则"
ready_to_dedupe = "正在准备文件去重"
deduping = "正在执行去重文件,请耐心等待\n如果同时存在复制任务,则会影响复制与文件去重双方的准确性"
deduping_done = "文件去重已完成"
is_folder_not_drive = "被选择的收藏夹是一个'文件夹'不是'团队盘'\n无法清空回收站"

[eng]
start = "Hi! replace . Welcome to use iCopy" #replace==symbolic placeholder
Expand Down Expand Up @@ -156,6 +157,7 @@ request_dedupe_mode = "Please select to dedupe mode rule"
ready_to_dedupe = "Ready to dedupe"
deduping = "In deduping task, pls wait \nIf there is a copy task, it will affect the accuracy of both copy and dedupe"
deduping_done = "The task is be deduped"
is_folder_not_drive = "The selected favorites is a 'folder' not a 'shared drive'\n Can not be purged"

[jp]
start = "Hi! replace . iCopyへようこそ" #replace==置き換え指示記号
Expand Down Expand Up @@ -228,10 +230,11 @@ finished_could_be_check = "既に完了した任務しか調べられない"
finished_could_be_dedupe = "すでに完了したタスクのみが重複ファイルの除去を行うことができる"
support_error = "指定の任務の照会を支持しない"
request_target_folder = "目標フォルダーを選んでください"
ready_to_purge = "空のごみ箱を清算する準備をしています"
purging = "空のごみ箱をクリアしています\n同時にコピーの任務がある場合、コピーと空のごみ箱の両方の正確さに影響します"
ready_to_purge = "ごみ箱を空にする準備をしています"
purging = "ごみ箱をクリアしています\n同時にコピーの任務がある場合、コピーとごみ箱を空にすることの両方の正確さに影響します"
purging_done = "既にごみ箱を空にした"
request_dedupe_mode = "重複除外モードのルールを選択してください"
ready_to_dedupe = "重複ファイルを除去する準備をしています"
deduping = "重複ファイルを除去しています。\n同時にコピーの任務がある場合、コピーと重複除外の両方の正確さに影響します"
deduping_done = "重複ファイルの除去が完了しました"
deduping_done = "重複ファイルの除去が完了しました"
is_folder_not_drive = "選択されたお気に入りは「フォルダ」ではなく「シェアドライバ」で\nゴミ箱を空にできない"
49 changes: 49 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,54 @@
# iCopy v0.2 CHANGELOG

## version 0.2.0-beta.6.1

+ Update :
+ ADD : "/dedupe" Now you can choose favorites to dedupe
+ CHANGE : Move the stage tag uniformly to new file “utils/callback_stage.py"

+ Fixbugs :
+ Judge select favorites if is shared drive when you use "/purge" mode.
+ Separately define bot variables in asynchronous-process to prevent errors in connecting Telegram.

+ Root Command:

+ start - nothing just say hello
+ menu - main entry point
quick - quick mode
copy - full mode
set - customize settings
task - task query
reset - restore task
size - just size task
dedupe - dedupe drives and folders
purge - delete files and folder in specified fav trash bin
cancel - cancel TG conversation
kill - kill task which is in processing
ver - check iCopy version
restart - restart iCopy

+ Child Command:

+ set - customize settings
┖ set - batch way
┖ set rule - rules
┖ fav|quick +/- id - single way
┖ set purge - purge favorites
+ size - size query
┖ size - size the shared resource
┖ size id - size specified task
┖ size fav - size specified favorites
+ dedupe - dedupe drives and folders
┖ dedupe - dedupe specified favorites
┖ dedupe id - dedupe specified task via task id
+ task - task query
┖ task - task in processing
┖ task list - future 10 tasks
┖ task id - show the specified task
+ reset - restore task
┖ reset - restore current task
┖ reset id - restore the specified task

## version 0.2.0-beta.6

+ Update :
Expand Down
14 changes: 4 additions & 10 deletions docs/develop_update.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
# DEVELOP UPDATE CHANGELOG

## v0.2.0-beta.6 finished
## v0.2.0-beta.6.1

+ ADD : insert more details into Database and more initialization data
+ ADD : feedback dst endpoint link when task end normally
+ ADD : 2 Group in RegEX
+ ADD : "/task id" only support the task which is start after v0.2.0b6
+ ADD : mark tasks that have been reset in the database
+ ADD : "/size id" & "/size fav"
+ ADD : "/purge" to empty shared drive trash bin
+ ADD : "/dedupe id" to dedupe task

Fixbugs:

+ FIX : "/purge" Determines whether it is a “shared drive" or a "folder"
33 changes: 22 additions & 11 deletions iCopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
get_functions as _func,
task_box as _box,
task_payload as _payload,
callback_stage as _stage,
)

from workflow import (
Expand All @@ -45,6 +46,13 @@


def main():
'''
defualt path:
_set.SET_FAV_MULTI,_start.CHOOSE_MODE,_quick.GET_LINK,_set.IS_COVER_QUICK,
_copy.GET_DST,_size.COOK_ID,_regex.REGEX_IN,_regex.REGEX_GET_DST,
_size.COOK_FAV_TO_SIZE,_purge.COOK_FAV_PURGE,_dedupe.COOK_ID_DEDU,
_dedupe.COOK_FAV_DEDU,_stage.FAV_PRE_DEDU_INFO
'''
### bot define
request = TGRequest(con_pool_size=8)
bot = Bot(token=f"{load.cfg['tg']['token']}", request=request)
Expand Down Expand Up @@ -81,45 +89,48 @@ def main():
Filters.regex(pattern=load.regex_entry_pattern), _regex.regex_entry
),
],

states={
_set.SET_FAV_MULTI: [
_stage.SET_FAV_MULTI: [
# fav settings function
MessageHandler(Filters.text, _set._multi_settings_recieved),
],
_start.CHOOSE_MODE: [
_stage.CHOOSE_MODE: [
# call function judged via callback pattern
CallbackQueryHandler(_quick.quick, pattern="quick"),
CallbackQueryHandler(_copy.copy, pattern="copy"),
],
_quick.GET_LINK: [
_stage.GET_LINK: [
# get Shared_Link states
MessageHandler(Filters.text, _func.get_share_link),
],
_set.IS_COVER_QUICK: [
_stage.IS_COVER_QUICK: [
# cover quick setting
CallbackQueryHandler(_func.modify_quick_in_db, pattern="cover_quick"),
CallbackQueryHandler(_func.cancel, pattern="not_cover_quick"),
MessageHandler(Filters.text, _func.cancel),
],
_copy.GET_DST: [
_stage.GET_DST: [
# request DST
CallbackQueryHandler(_copy.request_srcinfo),
],
_size.COOK_ID: [
_stage.COOK_ID: [
# request to COOK ID
MessageHandler(Filters.text, _size.size_handle),
],
_regex.REGEX_IN: [
_stage.REGEX_IN: [
# regex in choose mode
CallbackQueryHandler(_regex.regex_callback, pattern=r"quick|copy|size"),
],
_regex.REGEX_GET_DST: [
_stage.REGEX_GET_DST: [
# regex copy end
CallbackQueryHandler(_regex.regex_copy_end),
],
_size.COOK_FAV_TO_SIZE: [CallbackQueryHandler(_size.pre_cook_fav_to_size),],
_purge.COOK_FAV_PURGE: [CallbackQueryHandler(_purge.pre_to_purge),],
_dedupe.COOK_ID_DEDU: [CallbackQueryHandler(_dedupe.dedupe_mode),],
_stage.COOK_FAV_TO_SIZE: [CallbackQueryHandler(_size.pre_cook_fav_to_size),],
_stage.COOK_FAV_PURGE: [CallbackQueryHandler(_purge.pre_to_purge),],
_stage.COOK_ID_DEDU: [CallbackQueryHandler(_dedupe.dedupe_mode),],
_stage.COOK_FAV_DEDU: [CallbackQueryHandler(_dedupe.dedupe_fav_mode),],
_stage.FAV_PRE_DEDU_INFO: [CallbackQueryHandler(_dedupe.pre_favdedu_info)],
},
fallbacks=[CommandHandler("cancel", _func.cancel)],
)
Expand Down
21 changes: 21 additions & 0 deletions utils/callback_stage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-

from telegram.ext import ConversationHandler

(
SET_FAV_MULTI,
CHOOSE_MODE,
GET_LINK,
IS_COVER_QUICK,
GET_DST,
COOK_ID,
REGEX_IN,
REGEX_GET_DST,
COOK_FAV_TO_SIZE,
COOK_FAV_PURGE,
COOK_ID_DEDU,
COOK_FAV_DEDU,
FAV_PRE_DEDU_INFO,

) = range(13)
36 changes: 25 additions & 11 deletions utils/dedupe_payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,31 @@ def dedupe_task(
{"_id": int(dedu_task_id)}, {"$set": {"last_dedupe_time": last_dedupe_time,}},
)

deduped_msg = (
" ༺ ✪iCopy✪ ༻ | "
+ "🏳️" + _text[_lang]["current_task_id"]
+ str(dedu_task_id)
+ "\n\n"
+ '<a href="{}">{}</a>'.format(dedu_link, dedu_name)
+ "\n["
+ dedu_id
+ "]\n\n"
+ _text[_lang]["deduping_done"]
)
if dedu_task_id == 0:
deduped_msg = (
" ༺ ✪iCopy✪ ༻ | "
+ "🏳️"
+ " FAVORITES"
+ "\n\n"
+ '<a href="{}">{}</a>'.format(dedu_link, dedu_name)
+ "\n["
+ dedu_id
+ "]\n\n"
+ _text[_lang]["deduping_done"]
)

else:
deduped_msg = (
" ༺ ✪iCopy✪ ༻ | "
+ "🏳️" + _text[_lang]["current_task_id"]
+ str(dedu_task_id)
+ "\n\n"
+ '<a href="{}">{}</a>'.format(dedu_link, dedu_name)
+ "\n["
+ dedu_id
+ "]\n\n"
+ _text[_lang]["deduping_done"]
)

bot.edit_message_text(
chat_id=dedu_chat_id,
Expand Down
8 changes: 5 additions & 3 deletions utils/get_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
get_set as _set,
task_box as _box,
task_payload as _payload,
callback_stage as _stage,
)
from workflow import copy_workflow as _copy
from utils.load import _lang, _text
Expand All @@ -20,7 +21,7 @@
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.INFO
)
logger = logging.getLogger(__name__)

'''
(
SET_FAV_MULTI,
CHOOSE_MODE,
Expand All @@ -33,8 +34,9 @@
COOK_FAV_TO_SIZE,
COOK_FAV_PURGE,
COOK_ID_DEDU,
) = range(11)

COOK_FAV_DEDU,
) = range(12)
'''
regex1 = r"[-\w]{11,}"
regex2 = r"[-\w]"
judge_folder_len = [28, 33]
Expand Down
14 changes: 8 additions & 6 deletions utils/get_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
messages as _msg,
restricted as _r,
keyboard as _KB,
callback_stage as stage,
)
from telegram.ext import ConversationHandler
from telegram import ParseMode
from utils.load import _lang, _text
from drive.gdrive import GoogleDrive as _gd

'''
(
SET_FAV_MULTI,
CHOOSE_MODE,
Expand All @@ -25,8 +26,9 @@
COOK_FAV_TO_SIZE,
COOK_FAV_PURGE,
COOK_ID_DEDU,
) = range(11)

COOK_FAV_DEDU,
) = range(12)
'''
pick_quick = []
pick_fav = []
unpick_fav = []
Expand All @@ -46,7 +48,7 @@ def _setting(update, context):
_msg.set_multi_fav_guide(_lang), parse_mode=ParseMode.MARKDOWN_V2
)

return SET_FAV_MULTI
return _stage.SET_FAV_MULTI

if "purge" == entry_cmd[4:]:
fav_count = load.db_counters.find_one({"_id": "fav_count_list"})
Expand Down Expand Up @@ -134,7 +136,7 @@ def _setting(update, context):
reply_markup=_KB.is_cover_keyboard(),
)

return IS_COVER_QUICK
return _stage.IS_COVER_QUICK

elif "quick-" == each[:6]:
_func.delete_in_db_quick
Expand Down Expand Up @@ -249,7 +251,7 @@ def _multi_settings_recieved(update, context):
reply_markup=_KB.is_cover_keyboard(),
)

return IS_COVER_QUICK
return _stage.IS_COVER_QUICK

elif _tmp_quick_counter < 1:
pass
Expand Down
2 changes: 1 addition & 1 deletion utils/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


### local version
_version = "v0.2.0-beta.6"
_version = "v0.2.0-beta.6.1"

_cfgFile_RAW = os.path.abspath(os.path.join("config", "conf.toml"))
cfg = toml.load(_cfgFile_RAW)
Expand Down
Loading

0 comments on commit 115df17

Please sign in to comment.