Giter Site home page Giter Site logo

iyear / e5subbot Goto Github PK

View Code? Open in Web Editor NEW
1.0K 19.0 310.0 463 KB

🤖 Telebot for E5 Renewal

Home Page: https://t.me/E5Sub_bot

License: GNU General Public License v3.0

Go 97.43% Dockerfile 2.30% Makefile 0.27%
telebot e5-renewal golang office365 telegram-bot

e5subbot's Introduction

logo

E5SubBot

A Simple Telebot for E5 Renewal


English | 简体中文 | Telegram Chat

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

E5 subscription is a subscription for developers, as long as the related API is called, it may be renewed

Calling Outlook ReadMail API to renew, does not guarantee the renewal effect.

Usage

  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

Deploy Your Own Bot

Bot creation tutorial : Microsoft

Docker(Recommended)

Docker Deployment used sqlite as database

Support amd64 386 arm64 arm/v6 arm/v7 arch

#launch,you can set the time zone you want
docker run --name e5sub -e TZ="Asia/Shanghai" --restart=always -d iyear/e5subbot:latest

#view logs
docker logs -f e5sub

#set config
docker cp PATH/TO/config.yml e5sub:/config.yml
docker restart e5sub

#import db
docker cp PATH/TO/DATA.db e5sub:/data.db
docker restart e5sub

#backup db
docker cp e5sub:/data.db .

#backup config
docker cp e5sub:/config.yml .

Binary Deployment

Download the binary files of the corresponding system on the Releases page and upload it to the server

Windows: Start E5SubBot.exe

Linux:

screen -S e5sub
chmod +x E5SubBot
./E5SubBot
(Ctrl A+D)

Compile

Download the source code and install the GO environment

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

Configuration

Create config.yml in the same directory, encoded as UTF-8

Configuration Template:

bot_token: YOUR_BOT_TOKEN
# socks5: 127.0.0.1:1080
bindmax: 999
goroutine: 20
admin: 111,222,333
errlimit: 999
notice: |-
   aaa
   bbb
   ccc
cron: "1 */1 * * *"
db: sqlite
table: users
# mysql:
#    host: 127.0.0.1
#    port: 3306
#    user: root
#    password: pwd
#    database: e5sub
# ssl_mode is only required when the database requires a SSL connection (e.g. TiDB Cloud)
#    ssl_mode: PREFERRED
sqlite:
   db: data.db

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
db mysql or sqlite , Indicates the database type used and sets the corresponding configuration -
table Table name (set table to users when upgrading the old version; otherwise, the data table cannot be read) -
mysql To configure mysql, create a database in advance -
sqlite sqlite configuration -

Command

/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)

Others

Feedback time is not as expected

Change the server time zone, use /task to manually perform a task to refresh time.

ERROR:Can't create more than max_prepared_stmt_count statements (current value: 16382).

Failure to close db leads to triggering mysql concurrency limit, please update to v0.1.9.

Long running crash

Suspected memory leak. Not yet resolved, please run the daemon or restart Bot regularly.

Unable to create application via bot

https://t.me/e5subbot/5201

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 initiate an issue.

License

GPLv3

e5subbot's People

Contributors

boris1993 avatar dependabot[bot] avatar iyear avatar kzw200015 avatar minoliu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

e5subbot's Issues

Docker 起不来

stdout: ______ _____ _____ _ ____ _
stdout: | | / | | | | _ \ | |
stdout: | |
| || (
_ | |_ | |
) | ___ | |

stdout: | | |
\
| | | | '
| _ < / _ | |
stdout: | |
) |) | || | |) | |) | () | |_
stdout: ||// _,|_./|____/ __/ __|
stdout:
stdout: 【E5Sub】2022/06/14 23:14:35 main.go:76: Read Config……
stdout: 【E5Sub】2022/06/14 23:14:35 main.go:94: Connect MySQL Success!
stdout: 【E5Sub】2022/06/14 23:14:35 main.go:96: dial tcp :0: connect: connection refused

自动执行任务报错但没提示

我今天突然想起来去看看机器人的日志,发现自动执行的全都大量报错“control.go:156: Send Result ERROR: api error: Unauthorized (401)”和“ control.go:109: api error: Unauthorized (401)”,但是机器人发给我的结果却显示没有出错的账号,如图所示:
image
但是我手动执行任务的时候却又没有报错,如图:
image
不知道这是什么情况

docker-compose.yml mysql should not expose 3306 port

Hello
目前的yml是把mysql映射到主機3306 port上
因此主機是public IP的話 有很大的機會受到攻擊
可以把ports(L5-L6)刪掉, 只要config的host是使用mysql容器名稱連接就不會有問題

mysql:
image: mariadb:10.4.12
ports:
- 3306:3306
command: --character-set-server=utf8mb4
volumes:
- ./mysql/data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: e5sub
restart: always
container_name: mysql

最新源码,config里error limit设为-1失效Bug

Docker部署,版本0.4.0

errlimit: 被设置为-1时应该为忽略错误,不主动清退;但实际疑似会清退所有注册的账户?

(我只绑了一个,admin 敲 /task 后结果为 1/1 成功->错误账户为空,但被清退,改errlimit为999并重启后恢复正常)

在执行时出现了错误 MailboxNotEnabledForRESTAPI

首先用pdf配置并绑定成功但是执行错误,使用自动配置并绑定成功但是执行错误, 都是相同的错误
您的帐户 xx 在执行时出现了错误
您可以选择解绑该用户
错误: {"code":"MailboxNotEnabledForRESTAPI","message":"The mailbox is either inactive, soft-deleted, or is hosted on-premise.","innerError":{"date":"2023-01-05T03:01:23","request-id":"xxx","client-request-id":"xxx"}}

Deprecation of deeplink to register applications with Microsoft Identity Platform

Dear developer, I am Yuan Zhou, a product manager in Azure identity team. We found that your app is using deeplink to apps.dev.microsoft.com to register applications with the Microsoft Identity Platform. This is not an official API and we want to notify you that we are deprecating this method in 30 days. You can use official Azure API to create applications instead. Please don't hesitate to reach out to me if you have any questions. Thanks!

对于数据储存方式的一点建议

大部分情况下,我认为一个小工具不需要和MySQL捆绑,使用轻量级的Sqlite会更好,如果担心对C库的依赖也可以考虑使用json来储存数据

0.3.0 预发布版本 bot被用户blocked问题

当用户在微软控制台手动禁用bot时 bot发送请求会返回以下日志:

{"L":"ERROR","T":"2021-07-07T02:57:58.269Z","C":"bots/sender.go:76","M":"failed to send msg","error":"api error: bot was blocked by the user (401)","id":"xxxxxxxxxxx"}

但是此异常并未进入bot的失败列表,多次失败无法成功解绑。

无法运行

直接在命令行执行,跑不起来,提示“【E5Sub】2021/05/10 13:30:25 main.go:132: http.Post failed: Post https://api.telegram.org/bot1878110893:AAEP57mATZAicmlCyUoCl4yQ2H5qyVinUj0/getMe: dial tcp 108.160.165.147:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.”,但是我把报错里面的那个网址复制出来在浏览器粘贴,能访问,显示“{"ok":true,"result":{"id":1878110893,"is_bot":true,"first_name":"E5_BA7JCM_TEST","username":"ba7jcm_bot","can_join_groups":true,"can_read_all_group_messages":false,"supports_inline_queries":false}}”

完整运行日志我输出到这个txt里了:
1.txt

建议增加自用特权模式

您好,可否增加一个特权模式,只响应 admin 参数中用户发来的消息,因为自建打算只给自己使用

出现了个bug

今天上线发现自动解绑了 又绑定了下 发现一执行就解绑了 除了e5之外都正常 望修

更改任务循环运行模式

目前任务使用 cron 设置循环运行频率,但运行时间固定易导致续订失败。建议支持其他的计划任务方式,或者支持修改 cron 表达式后实际执行的命令。

关于编译/二进制文件的建议

  1. 我用的最新版的二进制文件(linux),在arm64平台上无法运行。希望能增加各个平台的二进制文件(虽然能编译吧)

  2. 然后我根据README上的教程编译后,用go build main.go,报错:
    # command-line-arguments ./main.go:50:23: undefined: bStart ./main.go:51:20: undefined: bMy ./main.go:52:22: undefined: bBind1 ./main.go:53:24: undefined: bUnBind ./main.go:54:24: undefined: bExport ./main.go:55:22: undefined: bHelp ./main.go:56:24: undefined: bOnText ./main.go:58:22: undefined: bTask ./main.go:59:21: undefined: bLog ./main.go:64:40: undefined: SignTask ./main.go:64:40: too many errors
    我在网上搜了一下,好像用go build *.go就可以通过go语言编译了,希望能在readme里能改正一下(我不懂go语言,如有出错望指正)

服务器运行报错怎么办…

输入 ./E5SubBot
报错如下

[root@Linux]# ./E5SubBot
2020/06/07 15:20:54 While parsing config: yaml: line 22: mapping values are not allowed in this context
ERROR
panic: While parsing config: yaml: line 22: mapping values are not allowed in this context

goroutine 1 [running]:                                                           
main.CheckErr(0xa3efa0, 0xc00010c760, 0xc00010c760)
        E:/GoProjects/E5SubBot/main/util.go:26 +0x101
main.init.0()
        E:/GoProjects/E5SubBot/main/handle.go:54 +0xb5

配置文件如下:

#bindmax,notice,admin,errlimit可热更新,直接更新config.yml保存即可
##更换为自己的BotToken

bot_token: 10219xxxx1:AAGfUFn3SnERpxFTzAxxxxxxx

##不需要socks5代理删去即可
socks5: 127.0.0.1:1080

##公告,合并至/help
notice: "第一行\n第二行"
##管理员tgid,前往https://t.me/userinfobot获取,用,隔开
##管理员权限: 手动调用任务,获得任务总反馈
admin: 991535xxx1
##任务最大出错次数,满后自动解绑账户并发送通知,无限次数将值改为负数(-1)即可 
##以ms账户为单位,不会解绑所有账户(只解绑错误账户) 
##主要为了减少资源浪费.bot重启后会清零所有错误次数 
errlimit: 5
##API调用频率,使用cron表达式
cron: "1 */3 * * *"
##最大可绑定数
bindmax: 3                                                                       ##mysql配置,请提前创建数据库
mysql:                                                                            
          host: 127.0.0.1                                                                    
          port: 3306                                                                         
          user: e5sub
          password: e5sub                                                                  
          database: e5sub

是不是此程序已经无法使用了?

Application registrations portal has been deprecated for registering and managing converged applications since May 2019 and this functionality will be removed starting July 2022. We recommend that you manage your existing applications and register new applications by using the App registrations (now Generally Available) experience in the Azure portal. Go to the Azure portal
image

V0.3开发计划

V0.3可能是E5SubBot最后一个版本。主要是代码的重构和稳定性的提升,在功能方面不会做太多的变化。
该版本数据表结构与V0.2不再兼容,需要手动迁移。

将在7月左右开发完成,大致框架查看 dev 分支

大致开发计划如下:

  1. gorm代替原生sql操作,采用 sqlite 作为数据库。
  2. 分包解耦, client 单独写类。
  3. zap作为logger并采取日志切分,优化错误输出,取消 /log 命令
  4. go-i18n作为国际化第三方库,采用 toml 格式。
  5. sling 作为网络请求库。
  6. 请求成功一次即清空该 Client 当前 errorTimes

任何新的建议欢迎提出

一点小建议及时间显示问题

1.机器人查看账户信息的时候能否显示所有日志?或者把日志log在服务器里
2.tg里显示的调用时间好像不是北京时间
3.建议调用间隔改成随机,太规律容易被发现

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.