update
This commit is contained in:
19
callback.py
19
callback.py
@@ -30,7 +30,18 @@ def save_encoded_image(b64_image: str, output_path: str):
|
|||||||
image_file.write(base64.b64decode(b64_image))
|
image_file.write(base64.b64decode(b64_image))
|
||||||
|
|
||||||
|
|
||||||
|
# bot发消息到tg群组
|
||||||
|
def sendTg(message):
|
||||||
|
baseUrl="https://api.telegram.org/bot"
|
||||||
|
toekn="558659722:AAENA3v8gKq7R7_nsr8V58Iu-_Z6BWx2SCw"
|
||||||
|
chat_id="-861577609"
|
||||||
|
text=message
|
||||||
|
url=f'{baseUrl}{toekn}/sendMessage?chat_id={chat_id}&text={text}'
|
||||||
|
try:
|
||||||
|
r = requests.get(url)
|
||||||
|
except:
|
||||||
|
print('请检查网络代理')
|
||||||
|
# https://api.telegram.org/bot558659722:AAENA3v8gKq7R7_nsr8V58Iu-_Z6BWx2SCw/sendMessage?chat_id=-861577609&text=1234
|
||||||
|
|
||||||
DEVICE = "cuda"
|
DEVICE = "cuda"
|
||||||
DEVICE_ID = "0"
|
DEVICE_ID = "0"
|
||||||
@@ -190,6 +201,7 @@ async def img(
|
|||||||
if ('/img' in query) is True:
|
if ('/img' in query) is True:
|
||||||
query=query.replace('/img', '')
|
query=query.replace('/img', '')
|
||||||
prompt=query
|
prompt=query
|
||||||
|
|
||||||
txt2img_url = 'http://127.0.0.1:7861/sdapi/v1/txt2img'
|
txt2img_url = 'http://127.0.0.1:7861/sdapi/v1/txt2img'
|
||||||
data = {'prompt': prompt}
|
data = {'prompt': prompt}
|
||||||
res = submit_post(txt2img_url, data)
|
res = submit_post(txt2img_url, data)
|
||||||
@@ -197,7 +209,7 @@ async def img(
|
|||||||
now =str(time.time())
|
now =str(time.time())
|
||||||
save_encoded_image(res.json()['images'][0], f'img/{now}.png')
|
save_encoded_image(res.json()['images'][0], f'img/{now}.png')
|
||||||
# 网络图片
|
# 网络图片
|
||||||
response=f'#web_img https://aiimg.yidooplanet.com/{now}.png'
|
response=f'#web_img http://aiimg.yidooplanet.com/{now}.png'
|
||||||
print('response',response)
|
print('response',response)
|
||||||
# return responseimg
|
# return responseimg
|
||||||
|
|
||||||
@@ -216,9 +228,6 @@ async def img(
|
|||||||
print('ArithmeticError',ArithmeticError)
|
print('ArithmeticError',ArithmeticError)
|
||||||
prompt = ""
|
prompt = ""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# log日志
|
# log日志
|
||||||
# now = datetime.datetime.now()
|
# now = datetime.datetime.now()
|
||||||
# time = now.strftime("%Y-%m-%d %H:%M:%S")
|
# time = now.strftime("%Y-%m-%d %H:%M:%S")
|
||||||
|
|||||||
Reference in New Issue
Block a user