E5BotForSQLite/README.md

156 lines
5.6 KiB
Markdown
Raw Normal View History

# E5SubBot
2020-06-17 17:39:01 +08:00
![](https://img.shields.io/github/go-mod/go-version/iyear/E5SubBot?style=flat-square)
![](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/README_zhCN.md)
2020-03-28 22:01:36 +08:00
A Simple Telebot for E5 Renewal
2020-06-17 17:39:01 +08:00
`Golang` + `MySQL`
DEMO: https://t.me/E5Sub_bot (all new functions will be tested in DEMO)
2020-06-17 17:39:01 +08:00
Communication: [Telegram Group](https://t.me/e5subbot)
2020-06-17 17:39:01 +08:00
## 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>
2020-06-17 17:39:01 +08:00
## Feature
2020-06-17 17:39:01 +08:00
- Automatically Renew E5 Subscription(Customizable Frequency)
- Manageable Simple Account System
- Available Task Execution Feedback
- Convenient Authorization
2020-03-29 13:38:30 +08:00
2020-06-17 17:39:01 +08:00
## Principle
2020-04-03 15:17:06 +08:00
2020-06-17 17:39:01 +08:00
E5 subscription is a subscription for developers, as long as the related API is called, it may be renewed
2020-03-29 13:38:30 +08:00
2020-06-17 17:39:01 +08:00
Calling [Outlook ReadMail API](https://docs.microsoft.com/en-us/graph/api/user-list-messages?view=graph-rest-1.0&tabs=http) to renew, does not guarantee the renewal effect.
2020-03-29 13:38:30 +08:00
2020-06-17 17:39:01 +08:00
## Usage
2020-03-29 13:38:30 +08:00
2020-06-17 17:39:01 +08:00
1. Type `/bind` in the robot dialog
2. Click the link sent by the robot and register the Microsoft application, log in with the E5 master account or the same domain account, and obtain `client_secret`. **Click to go back to Quick Start**, get `client_id`
3. Copy `client_secret` and `client_id` and reply to bot in the format of `client_id(space)client_secret`
(Pay attention to spaces)
4. Click on the authorization link sent by the robot and log in with the `E5` master account or the same domain account
5. After authorization, it will jump to `http://localhost/e5sub……` (will prompt webpage error, just copy the link)
6. Copy the link, and reply `link(space)alias (used to manage accounts)` in the robot dialog
For example: `http://localhost/e5sub/?code=abcd MyE5`, wait for the robot to bind and then complete
2020-03-29 13:38:30 +08:00
2020-06-17 17:39:01 +08:00
## Deploy Your Own Bot
2020-04-12 09:15:18 +08:00
2020-06-17 17:39:01 +08:00
Bot creation tutorial : [Microsoft](https://docs.microsoft.com/en-us/azure/bot-service/bot-service-channel-connect-telegram?view=azure-bot-service-4.0)
2020-04-12 09:10:22 +08:00
2020-06-17 17:39:01 +08:00
### Docker Deployment
Thanks to [@kzw200015](https://github.com/kzw200015) for providing help in `Dockerfile` and `Docker`
2020-04-12 09:10:22 +08:00
2020-06-17 17:39:01 +08:00
If it fails to start for the first time, use `docker-compose restart` to restart
2020-04-12 09:10:22 +08:00
```bash
mkdir ./e5bot && wget --no-check-certificate -O ./e5bot/config.yml https://raw.githubusercontent.com/iyear/E5SubBot/master/config.yml.example
vi ./e5bot/config.yml
wget --no-check-certificate https://raw.githubusercontent.com/iyear/E5SubBot/master/docker-compose.yml
docker-compose up -d
```
2020-06-17 17:39:01 +08:00
### Binary Deployment
2020-03-29 13:38:30 +08:00
2020-06-17 17:39:01 +08:00
Download the binary files of the corresponding system on the [Releases](https://github.com/iyear/E5SubBot/releases) page and upload it to the server
2020-03-29 13:38:30 +08:00
2020-06-17 17:39:01 +08:00
Windows: Start `E5SubBot.exe` in `cmd`
2020-03-29 13:38:30 +08:00
Linux:
```bash
screen -S e5sub
2020-04-04 15:36:44 +08:00
chmod 773 E5SubBot
./E5SubBot
2020-03-29 13:38:30 +08:00
(Ctrl A+D)
```
2020-06-17 17:39:01 +08:00
### Compile
2020-03-29 13:38:30 +08:00
2020-06-17 17:39:01 +08:00
Download the source code and install the GO environment
2020-03-29 13:38:30 +08:00
```shell
2020-04-12 09:10:22 +08:00
go build
```
2020-06-17 17:39:01 +08:00
## Configuration
2020-06-17 17:39:01 +08:00
Create `config.yml` in the same directory, encoded as `UTF-8`
2020-06-17 17:39:01 +08:00
Configuration Template:
2020-03-29 13:38:30 +08:00
```yaml
2020-06-17 17:39:01 +08:00
bot_token: YOUR_BOT_TOKEN
2020-03-29 13:38:30 +08:00
socks5: 127.0.0.1:1080
2020-06-17 17:39:01 +08:00
notice: "first line \n second line"
2020-04-03 15:17:06 +08:00
admin: 66666,77777,88888
2020-04-12 09:10:22 +08:00
errlimit: 5
2020-04-03 15:17:06 +08:00
cron: "1 */3 * * *"
2020-03-29 13:38:30 +08:00
bindmax: 3
mysql:
host: 127.0.0.1
port: 3306
user: e5sub
password: e5sub
database: e5sub
```
2020-06-17 17:39:01 +08:00
`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|
### Command
2020-04-12 09:15:18 +08:00
```
2020-06-17 17:39:01 +08:00
/my View bound account information
/bind Bind new account
/unbind Unbind account
/export Export account information (JSON format)
/help help
/task Manually execute a task (Bot Administrator)
/log Get the most recent log file (Bot Administrator)
2020-04-12 09:15:18 +08:00
```
2020-06-17 17:39:01 +08:00
## Others
> Feedback time is not as expected
2020-04-18 22:37:47 +08:00
2020-06-17 17:39:01 +08:00
Change the server time zone, use `/task` to manually perform a task to refresh time.
2020-04-18 22:37:47 +08:00
2020-06-17 17:39:01 +08:00
> ERROR:Can't create more than max_prepared_stmt_count statements (current value: 16382).
2020-04-12 09:10:22 +08:00
2020-06-17 17:39:01 +08:00
Failure to close `db` leads to triggering `mysql` concurrency limit, please update to `v0.1.9`.
2020-04-12 09:10:22 +08:00
2020-06-17 17:39:01 +08:00
> Long running crash
2020-04-12 09:10:22 +08:00
2020-06-17 17:39:01 +08:00
Suspected memory leak. Not yet resolved, please run the daemon or restart Bot regularly.
2020-03-29 13:38:30 +08:00
2020-04-12 09:10:22 +08:00
## Third-Party
2020-06-17 17:39:01 +08:00
- [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
- ……
## License
2020-03-29 13:38:30 +08:00
2020-04-04 17:13:23 +08:00
GPLv3