This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | |
}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id": "modr-XXXXX", | |
"model": "text-moderation-005", | |
"results": [ | |
{ | |
"flagged": true, | |
"categories": { | |
"sexual": false, | |
"hate": false, | |
"harassment": false, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"created": 1679081581, | |
"data": [ | |
{ | |
"url": "URL_DA_IMAGEM_GERADA" | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | |
}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define('DEFAULT_BLACKLIST', array("cachorro", "gato", "coelho", "galinha", "tigre", "onça", "rato")); | |
<? |
NewerOlder