Send your Telegram bot a description and it draws that picture and sends it back to the same chat.
Uses
ImgBB
OpenAI
Stability AI
Telegram
Message a description, get a picture back in Telegram
incomingMessage.When a new message is received. Save it as incomingMessage.pictureStyle to blank.Set pictureStyle to blank.pictureShape to 1:1.Set pictureShape to 1:1.pictureStyle lowercase and save it as styleChoice.Make pictureStyle lowercase and save it as styleChoice.knownStyles to:Set knownStyles to:3d-model
analog-film
anime
cinematic
comic-book
digital-art
enhance
fantasy-art
isometric
line-art
low-poly
modeling-compound
neon-punk
origami
photographic
pixel-art
...knownStyles doesn't contain styleChoiceIf knownStyles doesn't contain styleChoiceYes
No
No steps
pictureShape and save it as shapeChoice.Trim pictureShape and save it as shapeChoice.knownShapes to:Set knownShapes to:1:1
16:9
9:16
3:2
2:3
5:4
4:5
21:9
9:21knownShapes doesn't contain shapeChoiceIf knownShapes doesn't contain shapeChoiceYes
No
No steps
chatId to incomingMessage.chat_id.Set chatId to incomingMessage.chat_id.chatId is emptyIf chatId is emptyYes
No
No steps
requestText to blank.Set requestText to blank.messageErrorIf a step below fails, save the error as messageErrorTry
incomingMessage.text and save it as requestText.Trim incomingMessage.text and save it as requestText.On error
isOwnReply to requestText starts with Here is your picture or requestText starts with I could not draw that or requestText starts with Tell me what to draw.Set isOwnReply to requestText starts with Here is your picture or requestText starts with I could not draw that or requestText starts with Tell me what to draw.isOwnReply is yesIf isOwnReply is yesYes
No
No steps
requestText is less than 3If the length of requestText is less than 3Yes
chatId.Send a message to chat chatId.Tell me what to draw - a red bicycle leaning on a wall at sunset, a fox reading a map, anything you can describe.No
No steps
requestText to 400 characters (keeping words whole) and save it as cappedRequest.Shorten requestText to 400 characters (keeping words whole) and save it as cappedRequest.screenRules to You are the safety check for a picture bot. Someone has sent a description and a picture will be drawn from it. Decide whether it should be drawn.Set screenRules to You are the safety check for a picture bot. Someone has sent a description and a picture will be drawn from it. Decide whether it should be drawn.
Refuse if the description asks for:
- any real, named or otherwise identifiable person, living or dead, including public figures, politicians, celebrities, and anyone the sender says they know
- sexual or suggestive content of anyone, or any depiction of a child that is not ordinary and fully clothed
- violence, gore, injury, self-harm, or a weapon being used on someone
- hateful, demeaning or harassing content about a person or a group
- anything meant to pass as real: an identity document, currency, an official paper, a signature, or the logo or packaging of a real company or product
- a diagram or instructions for making a weapon, an explosive or a drug
Anything else is fine, including invented characters, animals, places, food, objects, patterns, abstract art and fictional scenes.screenPrompt to screenRulesAnswer on one line. Either the single word ALLOW, or REFUSE: followed by one short sentence, beginning with a capital letter, that a person can read and that says what the problem was without repeating the request.Set screenPrompt to screenRulesAnswer on one line. Either the single word ALLOW, or REFUSE: followed by one short sentence, beginning with a capital letter, that a person can read and that says what the problem was without repeating the request.
The description:
cappedRequest
.screenResult to nothing.Set screenResult to nothing.screenCallErrorIf a step below fails, save the error as screenCallErrorTry
screenPrompt. Save it as screenResult.Ask OpenAI: screenPrompt. Save it as screenResult.On error
screenResult to nothing.Change screenResult to nothing.verdict to blank.Set verdict to blank.verdictErrorIf a step below fails, save the error as verdictErrorTry
screenResult.response_text and save it as verdict.Trim screenResult.response_text and save it as verdict.On error
verdict to blank.Change verdict to blank.verdict doesn't start with ALLOWIf verdict doesn't start with ALLOWYes
refusalText to I could not draw that. The safety check did not come back, so nothing was drawn. Send the description again in a moment..Set refusalText to I could not draw that. The safety check did not come back, so nothing was drawn. Send the description again in a moment..verdict starts with REFUSEIf verdict starts with REFUSEYes
verdict with REFUSE: replaced by with REFUSE replaced by and save it as refusalReason.Trim verdict with REFUSE: replaced by with REFUSE replaced by and save it as refusalReason.refusalText to I could not draw that. It is outside what this bot will draw..Change refusalText to I could not draw that. It is outside what this bot will draw..refusalReason isn't emptyIf refusalReason isn't emptyYes
refusalText to I could not draw that. refusalReason truncated to 300 characters using ... as the ellipsis (keeping words whole).Change refusalText to I could not draw that. refusalReason truncated to 300 characters using ... as the ellipsis (keeping words whole).No
No steps
No
No steps
chatId.Send a message to chat chatId.refusalTextNo
No steps
pictureRef to blank.Set pictureRef to blank.drawingErrorIf a step below fails, save the error as drawingErrorTry
cappedRequest. Save it as generated.Generate an image of cappedRequest. Save it as generated.text, letters, words, watermark, signature, logo, brand mark, real person, celebrity, nudity, goregenerated.document_ref and save it as pictureRef.Trim generated.document_ref and save it as pictureRef.On error
pictureRef to blank.Change pictureRef to blank.pictureUrl to blank.Set pictureUrl to blank.pictureRef isn't emptyIf pictureRef isn't emptyYes
hostingErrorIf a step below fails, save the error as hostingErrorTry
hosted.Upload an image. Save it as hosted.hosted.url and save it as pictureUrl.Trim hosted.url and save it as pictureUrl.On error
pictureUrl to blank.Change pictureUrl to blank.No
No steps
pictureUrl doesn't start with https://If pictureUrl doesn't start with https://Yes
pictureUrl to blank.Change pictureUrl to blank.No
No steps
pictureUrl isn't emptyIf pictureUrl isn't emptyYes
chatId.Send a photo to chat chatId.
Photo URL: pictureUrlHere is your picture: cappedRequest truncated to 900 characters using "..." as the ellipsis (keeping words whole)No
No steps
chatId.Send a message to chat chatId.I could not draw that right now - the picture could not be made. Send the description again in a moment.