forked from fxxkrlab/iCopy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c222f31
Showing
25 changed files
with
1,243 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
__pycache__/ | ||
.vscode/ | ||
.DS_Store/ | ||
test/ | ||
lib/ | ||
include/ | ||
bin/ | ||
pyvenv.cfg | ||
*/__pycache__/ | ||
*/conf.toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
### README | ||
|
||
* wait |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
[tg] | ||
|
||
token = "Bot API Token HERE" # get from tg::botfather | ||
|
||
usr_id = "user id HERE" # get from tg::@get_id_bot | ||
|
||
[database] | ||
|
||
db_addr = "Your database address here" # mongodb host address | ||
|
||
db_port = 27017 # mongodb connect port,default is 27017 | ||
|
||
db_name = "iCopy" # set Your mongodb collection_Name,default is "iCopy" | ||
|
||
db_user = "Your mongodb user_Name HERE" # mongodb username | ||
|
||
db_passwd = "Your mongodb user_Passwd HERE" # mongodb passwd | ||
|
||
[general] | ||
|
||
language = "cn" # cn / eng / jp,default is "cn" | ||
|
||
cloner = "fclone" # Only fclone is suitable now,Future supports: rclone / gclone / autorclone | ||
|
||
remote = "" # e.g. "fc" , "gc" , "rc", "sa" ,etc... | ||
|
||
parallel_c = "16" # customize checkers_NUM,default = "16" | ||
|
||
parallel_t = "32" # customize transfers_NUM,default = "32" | ||
|
||
min_sleep = "1ms" # customize drive-pacer-min-sleep,default = "1ms" | ||
|
||
sa_path = "/root/accounts" #Service_Accounts path,No slash at the end,default is "/root/accounts" | ||
|
||
run_args = ['--drive-server-side-across-configs', '-P','--stats=1s'] # status flags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
|
||
[cn] | ||
quick_mode = "极速模式" | ||
copy_mode = "自定义模式" | ||
mode_select_msg = "本次转存任务您选择了 ┋replace┋" #replace==待替换占位符 | ||
request_share_link = "请输入 Google Drive 分享链接 或 分享ID" | ||
is_cover = "覆盖" | ||
not_cover = "返回" | ||
is_cover_quick_msg = "QUICK\\_MODE 已存在指定快捷路径\n是否需要覆盖" | ||
insert_quick_success = "QUICK\\_MODE 指定快捷路径已设置成功" | ||
null_fav_quick = "未设置QUICK\\_MODE 转存目录\n请设置后再次尝试" | ||
ready_to_task = "转存任务准备中..." | ||
doing = "正在执行任务" | ||
done = "任务成功" | ||
current_task_id = "任务编号 : " | ||
task_start_time = "任务开始时间 : " | ||
task_finished_time = "任务结束时间 : " | ||
task_files_size = "文件总大小 : " | ||
task_files_num = "任务文件数 : " | ||
task_status = "任务状态:" | ||
elapsed_time = "总耗时 : " | ||
cancel_msg = "欢迎再次使用 iCopy" | ||
get_quick_count_invaild = "quick 模式下的快捷目录只允许存在一个" | ||
get_multi_fav_error = "请根据'/set'规则提交目录设置" | ||
get_single_fav_error = "请根据'/set rule'规则发送命令" | ||
get_multi_in_single = "多行设置请使用 '/set'" | ||
task_src_info = "[任务目标]:" | ||
task_dst_info = "[转存地址]:" | ||
|
||
[eng] | ||
quick_mode = "QUICK MODE" | ||
copy_mode = "COPY MODE" | ||
mode_select_msg = "┋replace┋ has be choosen" #replace==symbolic placeholder | ||
request_share_link = "Pls input Shared_Link or Shared_ID" | ||
is_cover = "Cover it" | ||
not_cover = "Cancel" | ||
is_cover_quick_msg = "QUICK\\_MODE The specified directory already exists\nDo you need to cover it?" | ||
insert_success = "QUICK\\_MODE specified path is setted successfully" | ||
null_fav_quick = "QUICK\\_MODE directory is not set\nPlease try again after setting" | ||
ready_to_task = "Now is Ready to Task..." | ||
doing = "Transferring" | ||
done = "Done" | ||
current_task_id = "task id : " | ||
task_start_time = "Task start time : " | ||
task_finished_time = "Task end time : " | ||
task_files_size = "Total file size : " | ||
task_files_num = "Task file num : " | ||
task_status = "task_status:" | ||
elapsed_time = "Elapsed Time : " | ||
cancel_msg = "Welcome to enjoy with iCopy again" | ||
get_quick_count_invaild = "Only ONE Dst ID can be specified under quick mode" | ||
get_multi_fav_error = "pls submit DST ID according '/set'" | ||
get_single_fav_error = "pls submit single DST ID according '/set rule'" | ||
get_multi_in_single = "pls use '/set' while modify multi DST IDs" | ||
task_src_info = "[Resource From]:" | ||
task_dst_info = "[Transfer To]:" | ||
|
||
[jp] | ||
quick_mode = "「クイックモード」" | ||
copy_mode = "「カスタマイズ モード」" | ||
mode_select_msg = "┋replace┋が選択されました" #replace==置き換え指示記号 | ||
request_share_link = "共有リンクまたは共有IDを入力してください" | ||
is_cover = "カバー" | ||
not_cover = "キャンセル" | ||
is_cover_quick_msg = "QUICK_MODE指定されたフォルダーはすでに存在します\n新しいフォルダで上書きしますか?" | ||
insert_quick_success = "QUICK_MODEで指定されたフォルダーが正常に設定されました" | ||
null_fav_quick = "QUICK\\_MODEフォルダーが設定されていません\n設定後にもう一度お試しください" | ||
ready_to_task = "任務準備中..." | ||
doing = "タスク実行中" | ||
done = "任務成功" | ||
current_task_id = "タスク番号 : " | ||
task_start_time = "タスク開始時刻 : " | ||
task_finished_time = "タスク終了時間 : " | ||
task_files_size = "ファイルサイズ : " | ||
task_files_num = "タスクファイル数 : " | ||
task_status = "タスク状態:" | ||
elapsed_time = "合計時間 : " | ||
cancel_msg = "再びiCopyへようこそ" | ||
get_quick_count_invaild = "「クイックモード」で一つフォルダーしか指定されることができない" | ||
get_multi_fav_error = "'/set'にルールをよって、フォルダーのIDを入力してください" | ||
get_single_fav_error = "'/set rule'にルールをよって、フォルダーのIDを入力してください" | ||
get_multi_in_single = "複数のフォルダーを設定する場合は、「/set」コマンドを使用してください" | ||
task_src_info = "[任務目標]:" | ||
task_dst_info = "[保存場所]:" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
### CHANGELOG | ||
|
||
* version 0.2.0-alpha.1 | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
### TODO | ||
|
||
* Before release | ||
Make full Copy MODE | ||
write CHANGELOG | ||
renew README |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/usr/bin/python3 | ||
# -*- coding: utf-8 -*- | ||
|
||
import os, sys, logging, random | ||
|
||
from glob import glob | ||
from googleapiclient import discovery | ||
from google.oauth2 import service_account | ||
from googleapiclient import errors | ||
from google.auth.transport.requests import Request | ||
|
||
from utils import load | ||
logger = logging.getLogger(__name__) | ||
class GoogleDrive: | ||
def __init__(self): | ||
service_account_file = random.choice(glob(load.cfg['general']['sa_path'] + '/*.json')) | ||
|
||
credentials = None | ||
scopes = ['https://www.googleapis.com/auth/drive'] | ||
|
||
credentials = service_account.Credentials.from_service_account_file( | ||
service_account_file, scopes=scopes) | ||
|
||
self.service = discovery.build('drive', 'v3', credentials=credentials) | ||
|
||
def drive_list(self): | ||
result = [] | ||
raw_drives = {} | ||
page_token = None | ||
|
||
while True: | ||
try: | ||
param = { | ||
'pageSize': 100, | ||
} | ||
if page_token: | ||
param['pageToken'] = page_token | ||
drives = self.service.drives().list(**param).execute() | ||
|
||
result.extend(drives['drives']) | ||
logger.debug('Received {} drives'.format(len(drives['drives']))) | ||
page_token = drives.get('nextPageToken') | ||
if not page_token: | ||
break | ||
except errors.HttpError as error: | ||
logger.warning('An error occurred: %s' % error) | ||
break | ||
|
||
for item in result: | ||
raw_drives[item['id']] = item['name'] | ||
return raw_drives | ||
|
||
|
||
|
||
def file_get_name(self, file_id): | ||
param = { | ||
'fileId': file_id, | ||
'supportsAllDrives': True, | ||
'fields': 'name, driveId', | ||
} | ||
raw_file_info = self.service.files().get(**param).execute() | ||
file_name = raw_file_info['name'] | ||
|
||
return file_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#!/usr/bin/python3 | ||
# -*- coding: utf-8 -*- | ||
|
||
import os, logging | ||
from utils import load | ||
from telegram import Bot | ||
from telegram.utils.request import Request as TGRequest | ||
from telegram.ext import ( | ||
Updater, | ||
CommandHandler, | ||
MessageHandler, | ||
Filters, | ||
CallbackQueryHandler, | ||
ConversationHandler, | ||
) | ||
from utils import ( | ||
messages as _msg, | ||
restricted as _r, | ||
get_set as _set, | ||
get_functions as _func, | ||
task_payload as _payload, | ||
) | ||
|
||
from workflow import start_workflow as _start, quick_workflow as _quick, copy_workflow as _copy | ||
from multiprocessing import Process as _mp | ||
|
||
logging.basicConfig( | ||
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.INFO | ||
) | ||
logger = logging.getLogger(__name__) | ||
|
||
# ############################### Main #################################### | ||
|
||
def main(): | ||
request = TGRequest(con_pool_size=8) | ||
bot = Bot(token=f"{load.cfg['tg']['token']}", request=request) | ||
updater = Updater(bot=bot, use_context=True) | ||
|
||
dp = updater.dispatcher | ||
|
||
# Entry Conversation | ||
conv_handler = ConversationHandler( | ||
entry_points=[ | ||
# Entry Points | ||
CommandHandler("set", _set._setting), | ||
CommandHandler("start", _start.start), | ||
CommandHandler("quick", _quick.quick), | ||
# CommandHandler("copy", copy), | ||
], | ||
states={ | ||
_set.SET_FAV_MULTI: [ | ||
# fav settings function | ||
MessageHandler(Filters.text, _set._multi_settings_recieved), | ||
], | ||
_start.CHOOSE_MODE: [ | ||
# call function judged via callback pattern | ||
CallbackQueryHandler(_quick.quick, pattern="quick"), | ||
# CallbackQueryHandler(copy, pattern="copy"), | ||
], | ||
_quick.GET_LINK: [ | ||
# get Shared_Link states | ||
MessageHandler(Filters.text, _func.get_share_link), | ||
], | ||
_set.IS_COVER_QUICK: [ | ||
CallbackQueryHandler(_func.delete_in_db_quick, pattern="cover_quick"), | ||
CallbackQueryHandler(_func.cancel, pattern="not_cover_quick"), | ||
MessageHandler(Filters.text, _func.cancel), | ||
], | ||
}, | ||
fallbacks=[CommandHandler("cancel", _func.cancel)], | ||
) | ||
|
||
dp.add_handler(conv_handler, 2) | ||
|
||
dp.add_handler(CommandHandler("ver", _func._version)) | ||
|
||
updater.start_polling() | ||
logger.info("Fxxkr LAB iCopy v0.2.0a1 Start") | ||
updater.idle() | ||
|
||
|
||
if __name__ == "__main__": | ||
progress = _mp(target=_payload.task_buffer) | ||
progress.start() | ||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
oauth2client==4.1.3 | ||
chardet==3.0.4 | ||
python_telegram_bot==12.7 | ||
google_api_python_client==1.9.3 |
Empty file.
Oops, something went wrong.