Skip to content

Commit

Permalink
Add the function of setting the maximum number of characters displaye…
Browse files Browse the repository at this point in the history
…d in the line
  • Loading branch information
gaowanliang committed Aug 11, 2021
1 parent bfbd890 commit 7e02ab4
Show file tree
Hide file tree
Showing 8 changed files with 252 additions and 211 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
(Currently) 🤖 A Telegram Bot that can control your Aria2 server, control server files and also upload to OneDrive / Google Drive.

## 【NOTE】
Since the author I need to prepare for my graduate exams at the moment, the development progress will be appropriately stalled, I think it is a good idea for the program, so I will keep developing it.
Since the author I need to prepare for my graduate exams at the moment, the development progress will be appropriately stalled, but I think the idea of this program is very good, so I will keep developing.
Questions or suggestions are very welcome, and although I can't focus on development on my end, I still log in to GitHub often to check out everyone's suggestions and pr.😀

## Project significance
Expand All @@ -27,6 +27,8 @@ At the same time, communication via the bot protocol facilitates use on machines

<text style="color:red;">**Note: This project is still in beta testing and the Release submitted is for testing purposes only. Downloading it now does not guarantee you stable use, nor does it guarantee that the content ticked below has been implemented. The software is only stable when the submitted version is v1.0 (v1.0 will not implement all of the features below, but it will work properly and stably).**</text>

**Only the checked content is currently implemented**

#### Download method
- [x] Aria2 control
- [x] Persistent monitoring
Expand Down
17 changes: 15 additions & 2 deletions Telegram.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
goTree "DownloadBot/src/gotree"
"fmt"
"io"
"io/ioutil"
Expand Down Expand Up @@ -34,6 +35,10 @@ func setCommands(bot *tgBotApi.BotAPI) {
Command: "myid",
Description: locText("tgCommandMyIDDes"),
},
{
Command: "setMaxLength",
Description: locText("tgCommandSetMaxLengthDes"),
},
})
}

Expand Down Expand Up @@ -200,7 +205,7 @@ func TMSelectMessage(bot *tgBotApi.BotAPI) {
fileListTreeLine := strings.Split(fileListGoTree[0].Print(), "\n")
fileListTreeLineCount := len(fileListTreeLine)
characterCount := len(text)
r, err := regexp.Compile(`[✅⬜](\d+)`)
r, err := regexp.Compile(`[✅⬜](\d+)`)
dropErr(err)
startAndEndIndex := []int{1, 0}
msgCount := 0
Expand Down Expand Up @@ -659,7 +664,7 @@ func uploadFiles(chatMsgID int, chatMsg string, bot *tgBotApi.BotAPI) {

var activeRefreshControl = 0

// activeRefresh 刷新下载进度显示
// activeRefresh refresh the download info
func activeRefresh(chatMsgID int, bot *tgBotApi.BotAPI, ticker *time.Ticker, flag int) {
var MessageID = 0
myID := toInt64(info.UserID)
Expand Down Expand Up @@ -1062,6 +1067,14 @@ func tgBot(BotKey string, wg *sync.WaitGroup) {
msg.Text = locText("commandHelpRes")
case "myid":
msg.Text = fmt.Sprintf(locText("commandMyIDRes"), update.Message.Chat.ID)
case "setMaxLength":
i, err := strconv.Atoi(strings.ReplaceAll(update.Message.Text, "/setMaxLength ", ""))
if err !=nil{
msg.Text =locText("commandSetMaxLengthHelpRes")
}else{
goTree.SetMaxLength(i)
msg.Text =locText("operationSuccess")
}
}
} else {
msg.Text = locText("doNotHavePermissionControl")
Expand Down
7 changes: 7 additions & 0 deletions docs/README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,17 @@

同时,通过机器人协议通信,方便在无法进行内网穿透的机器上进行使用,而且简化了平时使用下载程序的操作,提高了便利性。对于链接,直接向Bot发送消息就可以直接识别并下载,可以真正删除下载文件夹里的文件,是AriaNG等web面板无法做到的,作为管理下载的工具,及时通知下载完成都是非常的方便的。可以移动文件,对于通过rclone挂载硬盘的用户可以直接通过本程序进行复制粘贴等操作,无需打开ssh连接VPS进行`cp`操作,也非常的方便。

## 【注意】
由于作者我目前需要准备研究生考试,所以开发进度会适当停滞,但我认为这个程序的想法非常好,所以我会继续开发。
非常欢迎大家提出问题或建议,虽然我这边不能专注于开发,但我还是会经常登录GitHub,看看大家的建议和pr😀。

## 实现


<text style="color:red;">**注意:本项目仍处于测试阶段,提交的Release仅供测试,现在下载后并不保证您的稳定使用,也不能保证下面所勾选的内容已经被实现。当真正可以正常使用的时候,我会提交 V1.0 版本(V1.0 版本不会实现下面全部功能,但是已经可以正常稳定的使用)**</text>

**只有已勾选的内容为目前实现的内容**

#### 下载方式

- [x] Aria2 控制
Expand Down
6 changes: 6 additions & 0 deletions docs/README_zh-TW.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@

同時,通過機器人協議通信,方便在無法進行內網穿透的機器上進行使用,而且簡化了平時使用下載程式的操作,提高了便利性。對於連結,直接向Bot發送消息就可以直接識別並下載,可以真正刪除下載檔案夾裡的檔,是AriaNG等web面板無法做到的,作為管理下載的工具,及時通知下載完成都是非常的方便的。可以移動檔,對於通過rclone掛載硬碟的使用者可以直接通過本程式進行複製粘貼等操作,無需打開ssh連接VPS進行`cp`操作,也非常的方便。

## 【注意】
由於作者我目前需要準備研究生考試,所以開發進度會適當停滯,但我認為這個程式的想法非常好,所以我會繼續開發。
非常歡迎大家提出問題或建議,雖然我這邊不能專注于開發,但我還是會經常登錄GitHub,看看大家的建議和pr😀。

## 實現

<text style="color:red;">**注意:本項目仍處於測試階段,提交的Release僅供測試,現在下載後並不保證您的穩定使用,也不能保證下面所勾選的內容已經被實現。當真正可以正常使用的時候,我會提交 V1.0 版本(V1.0 版本不會實現下面全部功能,但是已經可以正常穩定的使用)**</text>

**只有已勾選的內容為目前實現的內容**

#### 下載方式

- [x] Aria2 控制
Expand Down
4 changes: 3 additions & 1 deletion i18n/active.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,7 @@
"uploadGoogleDriveComplete": "DownloadFolder upload to Google Drive complete",
"oneDriveUploadFailAndRetry": "OneDrive account `%s` \n There was a connection problem when uploading `%s`. Retrying. It's the %d times retrying",
"googleDriveUploadTip1": "OneDrive account `%s` \n Uploading `%s` \n Size:`%s` Complete: `%s`\nProgress: *『%d/%d』* \nSpeed:`%s` \nTime: `%d s`",
"tmFileTooMany": "There are too many files in torrent. The refresh will be delayed after selecting the option. Please wait patiently."
"tmFileTooMany": "There are too many files in torrent. The refresh will be delayed after selecting the option. Please wait patiently.",
"tgCommandSetMaxLengthDes": "Set the maximum number of characters displayed per line when outputting the file tree",
"commandSetMaxLengthHelpRes": "You need to enter a number along with the command that represents the maximum number of characters per line you want to display when outputting the file tree, for example:\n/setMaxLength 36"
}
Loading

0 comments on commit 7e02ab4

Please sign in to comment.