Skip to content

Commit

Permalink
Modify documents
Browse files Browse the repository at this point in the history
  • Loading branch information
iyear committed Jul 6, 2021
1 parent f85de1b commit e25dab3
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 111 deletions.
64 changes: 26 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,21 @@
![](https://img.shields.io/badge/license-GPL-lightgrey.svg?style=flat-square)
![](https://img.shields.io/github/v/release/iyear/E5SubBot?color=green&style=flat-square)

English | [简体中文](https://github.com/iyear/E5SubBot/blob/master/README_zhCN.md)
English | [简体中文](https://github.com/iyear/E5SubBot/blob/master/README_zhCN.md) | [交流群组](https://t.me/e5subbot)

A Simple Telebot for E5 Renewal

`Golang` + `MySQL`

DEMO: https://t.me/E5Sub_bot (all new functions will be tested in DEMO)

Communication: [Telegram Group](https://t.me/e5subbot)

## Preview
<center class="half">
<img src="https://raw.githubusercontent.com/iyear/E5SubBot/master/pics/bind.JPG" width="200"/><img src="https://raw.githubusercontent.com/iyear/E5SubBot/master/pics/my.JPG" width="200"/><img src="https://raw.githubusercontent.com/iyear/E5SubBot/master/pics/task.JPG" width="200"/>
</center>
DEMO: https://t.me/E5Sub_bot

## Feature

- Automatically Renew E5 Subscription(Customizable Frequency)
- Manageable Simple Account System
- Available Task Execution Feedback
- Convenient Authorization

- Use concurrency to speed up

## Principle

Expand Down Expand Up @@ -60,15 +53,16 @@ docker-compose up -d
```
### Binary Deployment

Download the binary files of the corresponding system on the [Releases](https://github.com/iyear/E5SubBot/releases) page and upload it to the server
Download the binary files of the corresponding system on the [Releases](https://github.com/iyear/E5SubBot/releases) page
and upload it to the server

Windows: Start `E5SubBot.exe` in `cmd`
Windows: Start `E5SubBot.exe`

Linux:
Linux:

```bash
screen -S e5sub
chmod 773 E5SubBot
chmod +x E5SubBot
./E5SubBot
(Ctrl A+D)
```
Expand All @@ -77,7 +71,7 @@ chmod 773 E5SubBot
Download the source code and install the GO environment

```shell
go build
git clone https://github.com/iyear/E5SubBot.git && cd E5SubBot && go build
```

## Configuration
Expand All @@ -91,6 +85,7 @@ bot_token: YOUR_BOT_TOKEN
socks5: 127.0.0.1:1080
notice: "first line \n second line"
admin: 66666,77777,88888
goroutine: 10
errlimit: 5
cron: "1 */3 * * *"
bindmax: 3
Expand All @@ -100,21 +95,25 @@ mysql:
user: e5sub
password: e5sub
database: e5sub
table: users
```
`bindmax`, `notice`, `admin`, `errlimit` can be hot updated, just update `config.yml` to save.
| Configuration | Explanation|
| ---- | ---- |
| bot_token | Change to your own `BotToken` |
| socks5 | `Socks5` proxy,if you do not need ,you should delete it. For example: `127.0.0.1:1080` |
|notice|Announcement. Merged into `/help`|
|admin|The administrator's `tgid`, go to https://t.me/userinfobot to get it, separated by `,`; Administrator permissions: manually call the task, get the total feedback of the task|
|errlimit|The maximum number of errors for a single account, automatically unbind the single account and send a notification when it is full, without limiting the number of errors, change the value to a negative number `(-1)`; all errors will be cleared after the bot restarts|
|cron|API call frequency, using `cron` expression|
|bindmax|Maximum number of bindable|
|mysql|Mysql configuration, please create database in advance|
`bindmax`, `notice`, `admin`,`goroutine`, `errlimit` can be hot updated, just update `config.yml` to save.

| Configuration | Explanation|Default|
| ---- | ---- |----|
| bot_token | Change to your own `BotToken` |-|
| socks5 | `Socks5` proxy,if you do not need ,you should delete it. For example: `127.0.0.1:1080` |-|
|notice|Announcement. Merged into `/help`|-|
|admin|The administrator's `tgid`, go to https://t.me/userinfobot to get it, separated by `,`; Administrator permissions: manually call the task, get the total feedback of the task|-|
|goroutine|Concurrent number, don’t be too big|10|
|errlimit|The maximum number of errors for a single account, automatically unbind the single account and send a notification when it is full, without limiting the number of errors, change the value to a negative number `(-1)`; all errors will be cleared after the bot restarts|5|
|cron|API call frequency, using `cron` expression|-|
|bindmax|Maximum number of bindable|5|
|mysql|Mysql configuration, please create database in advance(If you upgrade the old version, please set table to users, otherwise the data table cannot be read)|-|

### Command

```
/my View bound account information
/bind Bind new account
Expand All @@ -141,25 +140,14 @@ Suspected memory leak. Not yet resolved, please run the daemon or restart Bot re
https://t.me/e5subbot/5201
## Third-Party
- [Telebot](https://gopkg.in/tucnak/telebot)
- [Mysql_driver](https://github.com/go-sql-driver/mysql)
- [Gjson](https://github.com/tidwall/gjson)
- [Cron](https://github.com/robfig/cron/)
- [Viper](https://github.com/spf13/viper)
- [Goreleaser](https://https://github.com/goreleaser/goreleaser)
## Contributing
- Provide documentation in other languages
- Provide help for code operation
- Suggests user interaction
- ……
## More Functions
If you still want to support new features, please use FeatHub to vote. We will consider the voting results and other factors to determine the development priority.
[![Feature Requests](https://cloud.githubusercontent.com/assets/390379/10127973/045b3a96-6560-11e5-9b20-31a2032956b2.png)](http://feathub.com/NervJS/taro)
[![Feature Requests](https://feathub.com/iyear/E5SubBot?format=svg)](https://feathub.com/iyear/E5SubBot)
If you still want to support new features, please initiate an issue.
## License
Expand Down
89 changes: 26 additions & 63 deletions README_zhCN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,22 @@
![](https://img.shields.io/badge/license-GPL-lightgrey.svg?style=flat-square)
![](https://img.shields.io/github/v/release/iyear/E5SubBot?color=green&style=flat-square)

[English](https://github.com/iyear/E5SubBot) | 简体中文
[English](https://github.com/iyear/E5SubBot) | 简体中文 | [交流群组](https://t.me/e5subbot)

A Simple Telebot for E5 Renewal

`Golang` + `MySQL`

DEMO: https://t.me/E5Sub_bot (长期运行,所有新功能会在DEMO测试)
DEMO: https://t.me/E5Sub_bot

[交流群组](https://t.me/e5subbot)

## 预览
<center class="half">
<img src="https://raw.githubusercontent.com/iyear/E5SubBot/master/pics/bind.JPG" width="200"/><img src="https://raw.githubusercontent.com/iyear/E5SubBot/master/pics/my.JPG" width="200"/><img src="https://raw.githubusercontent.com/iyear/E5SubBot/master/pics/task.JPG" width="200"/>
</center>

## 特性

- 自动续订E5订阅(可自定义的调用频率)
- 可管理的简易账户系统
- 完善的任务执行反馈
- 极为方便的授权方式
- 使用并发加快运行速度


## 原理
Expand Down Expand Up @@ -61,13 +56,13 @@ docker-compose up -d

[Releases](https://github.com/iyear/E5SubBot/releases)页面下载对应系统的二进制文件,上传至服务器

Windows: `cmd`中启动 `E5SubBot.exe`
Windows: 启动 `E5SubBot.exe`

Linux:
Linux:

```bash
screen -S e5sub
chmod 773 E5SubBot
chmod +x E5SubBot
./E5SubBot
(Ctrl A+D)
```
Expand All @@ -76,7 +71,7 @@ chmod 773 E5SubBot
下载源码,安装GO环境

```shell
go build
git clone https://github.com/iyear/E5SubBot.git && cd E5SubBot && go build
```

## 部署配置
Expand All @@ -90,6 +85,7 @@ bot_token: YOUR_BOT_TOKEN
socks5: 127.0.0.1:1080
notice: "第一行\n第二行"
admin: 66666,77777,88888
goroutine: 10
errlimit: 5
cron: "1 */3 * * *"
bindmax: 3
Expand All @@ -99,21 +95,25 @@ mysql:
user: e5sub
password: e5sub
database: e5sub
table: users
```
`bindmax`,`notice`,`admin`,`errlimit`可热更新,直接更新`config.yml`保存即可
| 配置项 | 说明 |
| ---- | ---- |
| bot_token | 更换为自己的`BotToken` |
| socks5 | `Socks5`代理,不需要删去即可.例如:`127.0.0.1:1080` |
|notice|公告.合并至`/help`|
|admin|管理员`tgid`,前往 https://t.me/userinfobot 获取,用`,`隔开;管理员权限: 手动调用任务,获得任务总反馈|
|errlimit|单账户最大出错次数,满后自动解绑单账户并发送通知,不限制错误次数将值改为负数`(-1)`即可;bot重启后会清零所有错误次数|
|cron|API调用频率,使用cron表达式|
|bindmax|最大可绑定数|
|mysql|mysql配置,请提前创建数据库|
`bindmax`,`notice`,`admin`,`goroutine`,`errlimit`可热更新,直接更新`config.yml`保存即可

| 配置项 | 说明 |默认值|
| ---- | ---- | ---- |
| bot_token | 更换为自己的`BotToken` | -|
| socks5 | `Socks5`代理,不需要删去即可.例如:`127.0.0.1:1080` |-|
|notice|公告.合并至`/help`|-|
|admin|管理员`tgid`,前往 https://t.me/userinfobot 获取,用`,`隔开;管理员权限: 手动调用任务,获得任务总反馈|-|
|goroutine|并发数,不要过大|10|
|errlimit|单账户最大出错次数,满后自动解绑单账户并发送通知,不限制错误次数将值改为负数`(-1)`即可;bot重启后会清零所有错误次数|5|
|cron|API调用频率,使用cron表达式|-|
|bindmax|最大可绑定数|5|
|mysql|mysql配置,请提前创建数据库(旧版本升级请设置table为users,否则读不到数据表)|-|

### 命令

```
/my 查看已绑定账户信息
/bind 绑定新账户
Expand Down Expand Up @@ -143,54 +143,17 @@ mysql:
> 无法通过Bot创建应用程序
https://t.me/e5subbot/5201
## 更多功能
如果你还想支持新的特性,请使用 FeatHub 进行投票,我们将综合考虑投票结果等因素来确定开发的优先级。
[![Feature Requests](https://cloud.githubusercontent.com/assets/390379/10127973/045b3a96-6560-11e5-9b20-31a2032956b2.png)](http://feathub.com/NervJS/taro)
如果你还想支持新的特性,请发起issue.
[![Feature Requests](https://feathub.com/iyear/E5SubBot?format=svg)](https://feathub.com/iyear/E5SubBot)
## 做出贡献
- 提供其他语言的文档
- 为代码运行提供帮助
- 对用户交互提出建议
- ……
## 小总结
#### 得到了什么?
- git的基本操作:add,commit,pull,push.但是对代码合并与冲突解决没有得到足够的实践和深入
- github版本库方面的使用(issue,pull request...),还有一些没玩过
- 体验了Docker Hub 的自动构建
- sql的CRUD,但都只是浮于表面,有时间再去琢磨
- telegram bot的golang基本框架和一些有意思的玩法
- 一些著名第三方库(viper,gjson)的基本用法
- docker以及docker-compose的基本用法
- 一些工具:gox;goreleaser的基本用法
- ……
#### 还缺点什么?
- 对`CGO`知难而退,编译各种出错。下个项目如果用到`sqlite`一定解决`CGO`交叉编译
- `DockerFile` 还不会写
- 对项目的概念和意识不太行,目录太乱,随缘写全局变量
- 看`telebot`的文档还好,看`stackflow` 只能看看代码。搜索还是习惯性带中文导致`stackflow`很难出现,降低了解决问题的效率
#### 最后
从2020.3.28开发至2020.4.12,一共经历14天,利用课余时间最终完成。
就要开学了,因为马上步入高三,学习紧迫,遂不再进行功能开发。
项目差不多就停更了,最多也就是每个星期看看issue、tg群组,修一修bug
**DEMO依旧能保持服务水平,不会因为个人问题在这段时间停止运行**
如果一年后还有人在用,一定会继续
## Third-Party
- [telebot](https://gopkg.in/tucnak/telebot)
- [mysql_driver](https://github.com/go-sql-driver/mysql)
- [gjson](https://github.com/tidwall/gjson)
- [cron](https://github.com/robfig/cron/)
- [viper](https://github.com/spf13/viper)
- [goreleaser](https://https://github.com/goreleaser/goreleaser)
## License
Expand Down
4 changes: 3 additions & 1 deletion config.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ bot_token: xxx
#socks5: 127.0.0.1:1080
bindmax: 3
admin: 555,666,777
goroutine: 10
errlimit: 5
notice: "aaa\nbbb"
cron: "1 */3 * * *"
Expand All @@ -11,4 +12,5 @@ mysql:
port: 3306
user: root
password: root
database: e5sub
database: e5sub
table: users
1 change: 0 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ func InitConfig() {
viper.SetDefault("errlimit", 5)
viper.SetDefault("bindmax", 5)
viper.SetDefault("goroutine", 10)
viper.SetDefault("bindmax", 5)

BindMaxNum = viper.GetInt("bindmax")
MaxErrTimes = viper.GetInt("errlimit")
Expand Down
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ require (
github.com/spf13/viper v1.6.2
github.com/tidwall/gjson v1.6.0
github.com/tidwall/pretty v1.0.1 // indirect
go.uber.org/automaxprocs v1.4.0
go.uber.org/zap v1.10.0
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e
gopkg.in/natefinch/lumberjack.v2 v2.0.0
gopkg.in/tucnak/telebot.v2 v2.0.0-20200328014118-dd123e949ee1
gorm.io/driver/sqlite v1.1.4
gorm.io/gorm v1.21.3
gorm.io/driver/mysql v1.1.1
gorm.io/gorm v1.21.9
)
Loading

0 comments on commit e25dab3

Please sign in to comment.