Giter VIP home page Giter VIP logo

embybot's Introduction

Emby服管理bot by小草

食用教程

将项目克隆到本地

git clone https://github.com/xiaocao666tzh/EmbyBot.git && cd EmbyBot && pip3 install -r requirements.txt

修改配置文件

bot_token = "xxx"            您的机器人令牌。从@BotFather获取
db_host = 'localhost'        mysql数据库地址
db_port = 3306               数据库端口
db_user = 'xxx'              数据库用户
db_password = 'xxx'          数据库密码
db_name = 'xxx'              数据库名称
bot_name = '@xxx'            bot username
api_id = 99999999            您的电报 API ID       https://core.telegram.org/api/obtaining_api_id
api_hash = "xxx"             你的 Telegram HASH    https://core.telegram.org/api/obtaining_api_id
embyurl = 'xxx'              emby访问链接          例 https://xxxx.com:8920
embyapi = 'xxx'              进入Emby后台,找到高级-API密钥,生成一个API
groupid = -100               1:转到(https://web.telegram.org)
                             2:转到您的 Gorup 并找到您的 Gorup 链接(https://web.telegram.org/#/im?p=g154513121)
                             3:复制该号码在 g 之后并在此之前放置 (-) -154513121
channelid = -100             只需将消息从您的频道转发到此机器人:( https://telegram.me/getidsbot )
admin_list = [111]           管理员id列表
ban_channel_id = -100 建议和channelid保持一致
line = 'xxx'                 线路

安装docker

curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh && systemctl enable docker && systemctl start docker

使用docker创建数据库

mkdir /root/EmbyBot/mysql

docker run --name tg-mysql -e MYSQL_ROOT_PASSWORD=55566677852 -e MYSQL_ROOT_HOST=% -v /root/EmbyBot/mysql:/var/lib/mysql -p 3306:3306 -d mysql:8 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci

创建数据库

使用navicat连接数据库

连接mysql

创建表格

导入数据库文件

https://github.com/xiaocao666tzh/EmbyBot/blob/main/embybot.sql.gz

启动机器人

前台启动机器人 python3 embybot.py 后台启动机器人 nohup python3 embybot.py > botlog.log 2>&1 &

添加进程守护(可选,但强烈建议)

在 /usr/lib/systemd/system 下创建如下文件
https://github.com/xiaocao666tzh/EmbyBot/blob/main/embybot.service
PathToEmbybot 改为文件路径
执行命令
systemctl daemon-reload
启动bot
systemctl start embybot
重启bot
systemctl restart embybot
开机自启
systemctl enable embybot
停止bot
systemctl stop embybot

使用

发送/start 获取帮助

注意

写数据库的时候忘记写完关闭连接了,因此需要设置一个cron任务,每八小时内必须重启一次bot,否则bot会报错!

参考

https://github.com/MisakaF0406/MisakaF_Emby

鸣谢

东东,Misakaf等Emby大佬提供技术支持 Foxcoo 帮我撰写了部分的README

embybot's People

Contributors

qcgzxw avatar xiaocao666tzh avatar

Forkers

jhruan1

embybot's Issues

pd.tosql() MySQL server has gone away

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\qcgzxw\Documents\Python Venv\lib\site-packages\sqlalchemy\pool\base.py", line 763, in _finalize_fairy
fairy._reset(pool, transaction_was_reset)
File "C:\Users\qcgzxw\Documents\Python Venv\lib\site-packages\sqlalchemy\pool\base.py", line 1038, in _reset
pool._dialect.do_rollback(self)
File "C:\Users\qcgzxw\Documents\Python Venv\lib\site-packages\sqlalchemy\engine\default.py", line 683, in do_rollback
dbapi_connection.rollback()
File "C:\Users\qcgzxw\Documents\Python Venv\lib\site-packages\pymysql\connections.py", line 479, in rollback
self._execute_command(COMMAND.COM_QUERY, "ROLLBACK")
File "C:\Users\qcgzxw\Documents\Python Venv\lib\site-packages\pymysql\connections.py", line 814, in _execute_command
self._write_bytes(packet)
File "C:\Users\qcgzxw\Documents\Python Venv\lib\site-packages\pymysql\connections.py", line 759, in _write_bytes
raise err.OperationalError(
pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(10054, '远程主机强迫关闭了一个现有的连接。', None, 10054, None))")

代码重构

旧太过杂乱,维护起来极其困难。

  • 使用django orm重构数据库
  • emby单独抽象出来一个类
  • 日志模块
  • 消息队列
  • 会话
  • 目录结构整理
  • 文档整理

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.