Add error message in add_message function + NSFW error message for 9gag
This commit is contained in:
@@ -432,9 +432,7 @@ class Databap extends PhpObject
|
||||
'errors'=>array('disconnected'=>self::DISCONNECTED,
|
||||
'not_authorized'=>self::NOT_AUTH,
|
||||
'not_found'=>self::NOT_FOUND,
|
||||
'insert'=>self::FAIL_INSERT,
|
||||
'update'=>self::FAIL_UPDATE,
|
||||
'delete'=>self::FAIL_DELETE),
|
||||
'system'=>array(self::FAIL_INSERT, self::FAIL_UPDATE, self::FAIL_DELETE)),
|
||||
'success'=>self::SUCCESS,
|
||||
'error'=>self::ERROR,
|
||||
'keep_alive'=>self::KEEP_ALIVE,
|
||||
@@ -735,15 +733,18 @@ class Databap extends PhpObject
|
||||
break;
|
||||
}
|
||||
}
|
||||
$asResult = $this->downloadToTmp($o9gagImage->getAttribute('src'));
|
||||
|
||||
$asResult = array();
|
||||
if(isset($o9gagImage)) $asResult = $this->downloadToTmp($o9gagImage->getAttribute('src'));
|
||||
else $asResult['error'] = 'Not safe for work';
|
||||
|
||||
if($asResult['error']=='')
|
||||
{
|
||||
$asPost['url_img'] = $asResult['out'];
|
||||
$asPost['width'] = $asResult['width'];
|
||||
$asPost['height'] = $asResult['height'];
|
||||
}
|
||||
else $asPost['error'] = $asResult['error'];
|
||||
$asPost['error'] = $asResult['error'];
|
||||
|
||||
return $asPost;
|
||||
}
|
||||
@@ -1793,6 +1794,8 @@ class Databap extends PhpObject
|
||||
{
|
||||
$sMessage = htmlspecialchars($sMessage);
|
||||
$sType = self::MESSAGE_USER;
|
||||
$bSuccess = true;
|
||||
$sDesc = '';
|
||||
if(mb_substr($sMessage, 0, 1) == '/')
|
||||
{
|
||||
if(mb_substr($sMessage, 0, 4) == '/me ')
|
||||
@@ -1906,17 +1909,25 @@ class Databap extends PhpObject
|
||||
elseif((mb_substr($sMessage, 0, 5) == '/img ' || mb_substr($sMessage, 0, 5) == '/pic ') && mb_strlen($sMessage)>5)
|
||||
{
|
||||
$sUrl = trim(mb_substr($sMessage, 4));
|
||||
$asResult = $this->downloadToTmp($sUrl);
|
||||
if($asResult['error']=='')
|
||||
$asImage = $this->downloadToTmp($sUrl);
|
||||
$bSuccess = ($asImage['error']=='');
|
||||
if($bSuccess)
|
||||
{
|
||||
$sMessage = $this->getJsonMessage(array($asResult['out'], $asResult['width'], $asResult['height'], $sUrl));
|
||||
$sMessage = $this->getJsonMessage(array($asImage['out'], $asImage['width'], $asImage['height'], $sUrl));
|
||||
$sType = self::MESSAGE_IMG;
|
||||
}
|
||||
else $sDesc = $asImage['error'];
|
||||
}
|
||||
elseif(mb_substr($sMessage, 0, 6) == '/9gag ' && mb_strlen($sMessage)>6)
|
||||
{
|
||||
$sMessage = $this->getJsonMessage($this->get9gagPost(trim(mb_substr($sMessage, 6))));
|
||||
$sType = self::MESSAGE_9GAG;
|
||||
$asImage = $this->get9gagPost(trim(mb_substr($sMessage, 6)));
|
||||
$bSuccess = ($asImage['error']=='');
|
||||
if($bSuccess)
|
||||
{
|
||||
$sMessage = $this->getJsonMessage($asImage);
|
||||
$sType = self::MESSAGE_9GAG;
|
||||
}
|
||||
else $sDesc = $asImage['error'];
|
||||
}
|
||||
elseif(mb_substr($sMessage, 0, 7) == '/reboot' && $this->checkUserClearance(self::CLEARANCE_ADMIN))
|
||||
{
|
||||
@@ -1934,8 +1945,16 @@ class Databap extends PhpObject
|
||||
{
|
||||
$sType = self::MESSAGE_PRIVATE;
|
||||
}
|
||||
$sChanId = $this->getChanId($sChanName);
|
||||
return $this->addMessage($sMessage, $sType, $sChanId);
|
||||
|
||||
//Storing message
|
||||
if($bSuccess)
|
||||
{
|
||||
$sChanId = $this->getChanId($sChanName);
|
||||
$bSuccess = $this->addMessage($sMessage, $sType, $sChanId);
|
||||
if(!$bSuccess) $sDesc = self::FAIL_INSERT;
|
||||
}
|
||||
|
||||
return $this->getJsonPostResult($bSuccess, $sDesc);
|
||||
}
|
||||
|
||||
private function getJsonMessage($asData)
|
||||
|
||||
Reference in New Issue
Block a user