type
status
date
slug
summary
tags
category
icon
password
Property
Sep 2, 2022 11:34 AM
想到telegram bot可以实现出的图直接上云,于是就想写一bot实现喂给它prompt和seed直接出图。
用的是telegram.bot 这个R包,在运行以下脚本时要确保自己已经配好conda env可以跑SD的txt2img.py。同时需要在.Renviron 中加一行:R_TELEGRAM_BOT_your_bot=your_token
为了确保bot不让路人都能运行,请在usr_list里输入你授权可以用的用户的chatid,如不清楚可以在telegram上@userinfobot

Telegram_bot.R

运行和停止脚本

可写一个监听的脚本让它自动重启。

定时清空log和图

因为图已经在TG上了,本地就没必要存了,设定和log 一起定时清空

log_clean.sh

chmod a+x log_clean.sh
sudo crontab -e
0 0 * * * sh /home/wyih/Projects/stable-diffusion/log_clean.sh

运行效果

notion image
notion image
notion image
notion image
反应速度还可以。加seed可以生成一样的图。