使用telegram的机器人下载文件到谷歌网盘

使用telegram的机器人下载文件到谷歌网盘 项目地址 https://github.com/lzzy12/python-aria-mirror-bot https://github.com/magneto261290/magneto-python-aria 编辑环境变量文件 生成telegraph的token python3 generate_telegraph_token.py d73ae03dd0XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXebaf2e161 填写到TELEGRAPH_TOKEN API_KEY 输入api_id API_HASH 输入 api_hash bot token输入BotFather获取到的bot的token 获得USER_SESSION_STRING AQCUOk4LsAukvKVZ9k1JK5H2Oo4EtWEJF4sQQ9RkG2fCkLWsZdk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXpy_gPZI42i70rerTWeWLD70a_cd_eHswSU1_IbFjTMexTiA2BgE 到 https://my.telegram.org/ 申请api TELEGRAM_API 填写App api_id TELEGRAM_HASH 填写App api_hash OWNER_ID 到 https://t.me/userinfobot 获取自己的Id 开启谷歌网盘授权 开启drive api https://developers.google.com/drive/api/v3/quickstart/python 安装依赖 pip3 install google-api-python-client google-auth-httplib2 google-auth-oauthlib 下载credentials.json并上传到服务器 生成token python3 generate_drive_token.py root@server:~/test/m2g/mirror-bot# python3 generate_drive_token.py Please visit this URL to authorize this application: https://accounts.google.com/o/oauth2/auth?XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Enter the authorization code: 4/5AHj9dOAl1h2Kih7zWkCCdY8VtZDrP4TxhYgQ0D4guA4CMnWXJELCD0 docker build .……

阅读全文

安装python3.9

安装python3.9 到网址找下载链接https://www.python.org/downloads/release/python-390/ 安装依赖 sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev 解压 tar -xf Python-3.X.X.tar.xz 设置并安装 which openssl //用命令查看openssl位置,设置的时候要用,不然安装好以后缺少openssl不能通过https下载包 ./configure --enable-optimizations --with-openssl=/usr/local/opt/openssl nproc //查看进程数 make -j 4 //此处的数字是进程数 sudo make altinstall (sudo make install) //make install 会直接覆盖系统的python 安装lxml遇到问题 cc -I/usr/include/libxml2 -I/usr/include/libxml2 -c /tmp/xmlXPathInitcfhhalla.c -o tmp/xmlXPathInitcfhhalla.o cc tmp/xmlXPathInitcfhhalla.o -lxml2 -o a.out error: command '/usr/bin/gcc' failed with exit code 4 有可能是内存不够,我的机器512MB不够,增加虚拟内存到2G以后安装成功……

阅读全文

nginx反向代理其他端口服务

要访问机器上除了80以外的端口需要域名加上端口链接,这样很不方便,所以就想用nginx把需要的服务代理到80端口。 nginx的配置文件在/etc/nginx/下,新增的网站服务的配置可以直接写下conf.d或者sites-enabled下面。具体可以查看nginx的nginx.conf配置文件中关于Virtual Host Configs的设置 一个比较好的安排配置文件的方法是:在sites-available中保存所有的配置,然后复制需要的配置到sited-enabled启用配置。 假设新建一个newserver配置文件 server { listen 80; server_name {domainname}.com; location / { proxy_pass http://127.0.0.1:8081;#add the port your service are listening proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } 软链接到sites-enabled cd /etc/nginx cp sites-available/newserver sites-enabled/ ……

阅读全文

使用windows terminal

在尝试了几个windows的终端后,还是觉得windows terminal最好用。 windows terminal 链接 https://github.com/microsoft/terminal defaultProfile填写配置对应的guid就可以设置默认配置。所有的配置在profiles中。 安装好git之后,windows可以使用bash了。 { "acrylicOpacity" : 0.9, "closeOnExit" : true, "colorScheme" : "Solarized Light", "commandline" : "C:\\Program Files\\Git\\bin\\bash.exe", "cursorColor" : "#1100fc", "cursorShape" : "bar", "fontFace" : "Consolas", "fontSize" : 12, "guid" : "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", "historySize" : 9001, "icon" : "C:\\Program Files\\Git\\mingw64\\share\\git\\git-for-windows.ico", "name" : "bash", "padding" : "0, 0, 0, 0", "snapOnInput" : true, "startingDirectory" : "%USERPROFILE%", "useAcrylic" : true } ……

阅读全文

使用expect和ssh登录服务器

expect可以帮助我们 自动化完成一些交互操作。 使用expect来执行ssh命令 编写脚本 #!/usr/bin/expect #sshlogin.exp set timeout 30 set host "192.168.1.8" set username "your_username" set password "yout_password" spawn ssh $username@$host #expect "*password:*" {send "$password\r"} expect { "*password:" {send "$password\r"} } interact 给脚本权限 chmod 755 运行脚本 ./sshlogin.exp 使用一行命令直接运行 expect -c 'spawn ssh {{username}}@{{host}}; expect "*password:*"; send "{{password}}\r"; interact' references: https://en.wikipedia.org/wiki/Expect https://stackoverflow.com/questions/3149367/how-to-get-expect-c-to-work-in-single-line-rather-than-script……

阅读全文

用键盘切换戴尔显示器输入源

到戴尔官网下载驱动 https://www.dell.com/support/home/en-us/drivers/driversdetails?driverid=6wgwy 下载autohotkey https://www.autohotkey.com/ 新建脚本 #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. ; #Warn ; Enable warnings to assist with detecting common errors. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. ^F11:: Run, "C:\Program Files (x86)\Dell\Dell Display Manager\ddm.exe" /1:SetActiveInput DP1 Return ^F12:: Run, "C:\Program Files (x86)\Dell\Dell Display Manager\ddm.exe" /1:SetActiveInput HDMI Return /斜杠后面的数字是显示器的序号,有的情况下不能成功切换显示器,把后面参数1替换成2就可以了,目前不清楚序号的规律。……

阅读全文

tmux使用

安装 sudo apt-get install tmux 启动tmux tmux 命令 tmux ls #查看到当前在运行的所有tmux sessions会话 tmux attach #进入上次退出的会话 tmux attach -t {{number}} #进入会话 tmux new -s <session-name> #新建会话 tmux kill-session -t {{number}} #结束会话 常用快捷键 先输入ctrl-b 然后用下面按键执行操作 d 离开会话,会话会运行在后台……

阅读全文

ssh端口转发

修改公网机器的配置 修改sshd_config vim /etc/ssh/sshd_config #GatewayPorts no => GatewayPorts yes #重启ssh服务 sudo /etc/init.d/ssh stop root@localhost:~# sudo /etc/init.d/ssh start 内网机器端口转发(假设内网的机器端口80要转发到公网机器的9091端口上) ssh -NR 9091:0.0.0.0:80 root@remote_ip ……

阅读全文

用nginx部署flask

安装uWSGI https://uwsgi-docs.readthedocs.io/en/latest/WSGIquickstart.html apt-get install build-essential python3-dev pip3 install uwsgi 使用uWSGI 运行 运行uwsgi,假设有run.py并且使用python3 run.py可以运行项目 uwsgi --socket 0.0.0.0:5000 --protocol=http -w run:app 配置文件 创建uwsgi.ini [uwsgi] module = run:app master = true processes = 5 http = 0.0.0.0:5000 使用配置文件运行 uwsgi --ini uwsgi.ini 如果要使用nginx,应该使用socket [uwsgi] module = run:app master = true processes = 5 socket = /tmp/flask.sock chmod-socket = 666 chdir = {path} logto = {path} 添加一个服务 使用systemd systemd 文件的路径在 /etc/systemd/system 创建一个文件uwsgiproject.service [Unit] Description=uWSGI instance to serve myproject After=network.……

阅读全文

禁止cloudflare以外的ip访问nginx的网站

添加一个文件cf.conf,里面记录的是允许访问的ip # https://www.cloudflare.com/ips # IPv4 allow 173.245.48.0/20; allow 103.21.244.0/22; allow 103.22.200.0/22; allow 103.31.4.0/22; allow 141.101.64.0/18; allow 108.162.192.0/18; allow 190.93.240.0/20; allow 188.114.96.0/20; allow 197.234.240.0/22; allow 198.41.128.0/17; allow 162.158.0.0/15; allow 104.16.0.0/12; allow 172.64.0.0/13; allow 131.0.72.0/22; # IPv6 allow 2400:cb00::/32; allow 2606:4700::/32; allow 2803:f800::/32; allow 2405:b500::/32; allow 2405:8100::/32; allow 2a06:98c0::/29; allow 2c0f:f248::/32; 修改 /etc/nginx/sites-available/default中的内容,添加include cf.conf和deny all location / { include /etc/nginx/cf.conf; deny all; # First attempt to serve request as file, then # as directory, then fall back to displaying a 404.……

阅读全文