Delete bot.py
Browse files
bot.py
DELETED
|
@@ -1,101 +0,0 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import base64
|
| 3 |
-
import random
|
| 4 |
-
import requests
|
| 5 |
-
from io import BytesIO
|
| 6 |
-
from telegram import Update
|
| 7 |
-
from telegram.ext import ApplicationBuilder, CommandHandler, ContextTypes
|
| 8 |
-
|
| 9 |
-
BOT_TOKEN = "7584662674:AAGO3YzvG6-bG6nvvBAc_r1Nmr0D8JsUSfY"
|
| 10 |
-
A1111_URL = "http://127.0.0.1:7860"
|
| 11 |
-
|
| 12 |
-
# LoRA mappings
|
| 13 |
-
animal_loras = [
|
| 14 |
-
("daniml_V2_alpaca", 0.4),
|
| 15 |
-
("daniml_V2_badger", 0.4),
|
| 16 |
-
("daniml_V2_fox", 0.4),
|
| 17 |
-
("daniml_V2_monkey", 0.4),
|
| 18 |
-
("daniml_V2_pig", 0.4),
|
| 19 |
-
("daniml_V2_rat", 0.4),
|
| 20 |
-
]
|
| 21 |
-
|
| 22 |
-
style_loras = [
|
| 23 |
-
("daniml_V2_cryptonerdV2", 0.6),
|
| 24 |
-
("daniml_V2_gangsterV2", 0.6),
|
| 25 |
-
("daniml_V2_katana", 0.6),
|
| 26 |
-
("daniml_V2_samurai", 0.6),
|
| 27 |
-
("daniml_V2_wizard", 0.6),
|
| 28 |
-
]
|
| 29 |
-
|
| 30 |
-
background_lora = ("daniml_background", 0.2)
|
| 31 |
-
|
| 32 |
-
prompt_buckets = [
|
| 33 |
-
"alley, cracked pavement, graffiti wall, neon kanji signs",
|
| 34 |
-
"rooftop, vents, loose wires, neon graffiti, skyline haze",
|
| 35 |
-
"tunnel, cracked tiles, green neon lighting, graffiti everywhere",
|
| 36 |
-
"alley wall, layered street art, magenta neon glow, wet ground",
|
| 37 |
-
"rooftop, rusted pipes, green haze, cracked concrete",
|
| 38 |
-
"alley, vending machine glow, crumbling walls, neon posters",
|
| 39 |
-
"tunnel, graffiti tunnel, magenta and green lighting, steam rising",
|
| 40 |
-
"side street, cracked cement, glowing kanji signs, mist and trash",
|
| 41 |
-
"alley, graffiti wall both sides, purple lighting, puddles",
|
| 42 |
-
"alley, trash-filled floor, glowing drain cover, misty neon signs",
|
| 43 |
-
"Tokyo alley, glowing pink signage, broken pavement, foggy atmosphere",
|
| 44 |
-
"narrow street with kanji billboards, cracked concrete, trash piles, cyan glow",
|
| 45 |
-
"backstreet tunnel, neon reflections on wet tiles, graffiti panels",
|
| 46 |
-
"rooftop walkway with tagged walls, dim green neon, rusted ducts",
|
| 47 |
-
"urban stairwell, crumbling cement, layered graffiti, purple lighting",
|
| 48 |
-
"service alley, flickering green lights, cracked asphalt, torn posters",
|
| 49 |
-
"subway entrance, steam vents, magenta overhead light, stained tiles",
|
| 50 |
-
"industrial rooftop, loose cables, glowing vents, Tokyo tower in distance",
|
| 51 |
-
"graffiti-covered passageway, deep haze, scattered debris, violet lighting",
|
| 52 |
-
"graffiti tunnel, puddles reflecting red and teal signage, cracked floor"
|
| 53 |
-
]
|
| 54 |
-
|
| 55 |
-
async def gen(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
| 56 |
-
try:
|
| 57 |
-
# Random selections
|
| 58 |
-
background_prompt = random.choice(prompt_buckets)
|
| 59 |
-
animal_lora, animal_weight = random.choice(animal_loras)
|
| 60 |
-
use_style = random.random() < 0.5
|
| 61 |
-
style_lora, style_weight = random.choice(style_loras) if use_style else (None, 0.0)
|
| 62 |
-
|
| 63 |
-
# Compose full LoRA string
|
| 64 |
-
lora_string = f"<lora:{background_lora[0]}:{background_lora[1]}> <lora:{animal_lora}:{animal_weight}>"
|
| 65 |
-
if use_style:
|
| 66 |
-
lora_string += f" <lora:{style_lora}:{style_weight}>"
|
| 67 |
-
|
| 68 |
-
# Extract animal name
|
| 69 |
-
animal_name = animal_lora.replace("daniml_V2_", "")
|
| 70 |
-
|
| 71 |
-
# Prompt setup
|
| 72 |
-
print("🧠 Final prompt:", full_prompt)
|
| 73 |
-
full_prompt = f"{lora_string} cyberpunk anthropomorphic {animal_name}, {background_prompt}, gritty neon lighting"
|
| 74 |
-
payload = {
|
| 75 |
-
"prompt": full_prompt,
|
| 76 |
-
"steps": 30,
|
| 77 |
-
"width": 768,
|
| 78 |
-
"height": 768,
|
| 79 |
-
}
|
| 80 |
-
|
| 81 |
-
res = requests.post(f"{A1111_URL}/sdapi/v1/txt2img", json=payload)
|
| 82 |
-
res.raise_for_status()
|
| 83 |
-
images = res.json()["images"]
|
| 84 |
-
if not images:
|
| 85 |
-
await update.message.reply_text("Generation failed. No image returned.")
|
| 86 |
-
return
|
| 87 |
-
|
| 88 |
-
# Decode and send first image
|
| 89 |
-
img_data = base64.b64decode(images[0])
|
| 90 |
-
with open("output.png", "wb") as f:
|
| 91 |
-
f.write(img_data)
|
| 92 |
-
await update.message.reply_photo(photo=open("output.png", "rb"))
|
| 93 |
-
|
| 94 |
-
except Exception as e:
|
| 95 |
-
await update.message.reply_text(f"Error: {e}")
|
| 96 |
-
|
| 97 |
-
app = ApplicationBuilder().token(BOT_TOKEN).build()
|
| 98 |
-
app.add_handler(CommandHandler("gen", gen))
|
| 99 |
-
|
| 100 |
-
print("Bot is running...")
|
| 101 |
-
app.run_polling()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|