Skip to content

Instantly share code, notes, and snippets.

View luizmarcus's full-sized avatar

Luiz Marcus luizmarcus

View GitHub Profile
<?php
define('BOT_TOKEN', 'TOKEN_DO_TELEGRAM');
define('API_URL', 'https://api.telegram.org/bot'.BOT_TOKEN.'/');
define('CHATGPT_API','https://api.openai.com/v1/audio/speech');
function processMessage($message) {
// processa a mensagem recebida
$message_id = $message['message_id'];
curl https://api.openai.com/v1/audio/speech \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "tts-1",
"input": "Esse é um teste de conversão de texto para voz",
"voice": "alloy"
}'
<?php
define('BOT_TOKEN', 'TELEGRAM_BOT_API_TOKEN');
define('API_URL', 'https://api.telegram.org/bot'.BOT_TOKEN.'/');
define('CHATGPT_API','https://api.openai.com/v1/moderations');
function processMessage($message) {
// processa a mensagem recebida
$message_id = $message['message_id'];
{
"id": "modr-XXXXX",
"model": "text-moderation-005",
"results": [
{
"flagged": true,
"categories": {
"sexual": false,
"hate": false,
"harassment": false,
curl https://api.openai.com/v1/moderations \
-X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{"input": "Sample text goes here"}'
<?php
define('BOT_TOKEN', 'TOKEN_TELEGRAM');
define('API_URL', 'https://api.telegram.org/bot'.BOT_TOKEN.'/');
define('DALLE_URL_API','https://api.openai.com/v1/images/generations');
define('TOTAL_IMGS', 1); //total de imagens a ser gerado
define('SIZE_IMGS', "1024x1024"); //tamanho das imagens a serem geradas
function processMessage($message) {
{
"created": 1679081581,
"data": [
{
"url": "URL_DA_IMAGEM_GERADA"
}
]
}
curl https://api.openai.com/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"prompt": "a white siamese cat",
"n": 1,
"size": "1024x1024"
}'
<?php
$message_id = $message['message_id'];
$chat_id = $message['chat']['id'];
$name = $message['from']['first_name'];
if (isset($message['text'])) {
$text = $message['text'];//texto recebido na mensagem
$result = checkBlackList($text);//checagem da pesença das palavras banidas no texto
<?php
define('DEFAULT_BLACKLIST', array("cachorro", "gato", "coelho", "galinha", "tigre", "onça", "rato"));
<?