Skip to content

Commit

Permalink
Ottavifier
Browse files Browse the repository at this point in the history
  • Loading branch information
andreskrey committed Nov 1, 2016
1 parent f0e0a77 commit fa77a21
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
2 changes: 1 addition & 1 deletion config/config.heroku.php
Expand Up @@ -15,7 +15,7 @@ class Config

static $REDIS_URL = null;

static $SIGNATURE = '<div id="firma"><hr><p><em><strong>empleadoEstatalBot</strong>, el bot que opina que esto con los milicos no pasaba.</em></p><p><a href="/u/subtepass">Autor</a>
static $SIGNATURE = '<div id="firma"><hr><p><em>Argentina: fulbo, pete, Maradona y <strong>empleadoEstatalBot</strong>.</em></p><p><a href="/u/subtepass">Autor</a>
| <a href="https://github.com/andreskrey/empleadoEstatalBot">Código fuente</a> | <a href="https://github.com/andreskrey/empleadoEstatalBot#que-diarios-soporta">Lista de diarios</a></p></div>';

public function __construct()
Expand Down
Expand Up @@ -56,22 +56,35 @@ public function parse($text)

public function checkForKicilove($text)
{
if (stripos($text, 'kicillof') !== false) {
$this->dom = new DOMDocument('1.0', 'utf-8');
$this->dom->loadHTML('<?xml encoding="utf-8"?>' . $text);
$this->dom->encoding = 'utf-8';

$frag = $this->dom->createDocumentFragment();
$frag->appendXML('<p>- - - - - -</p>');
$frag->appendXML('<p>En esta nota se menciona a Kicillof y por reglas de /r/argentina es obligatorio recordar este video: <b><a href="https://www.youtube.com/watch?v=htCUanVT4Dg">Prat-Gay humilló a Axel Kicillof</a></b>.</p>');

$firma = $this->dom->getElementById('firma');
$firma->appendChild($frag);

return str_replace('<?xml encoding="utf-8"?>', '', $this->dom->saveHTML());
} else {
return $text;
$politicos = [
'kicillof' => [
'<p>- - - - - -</p>',
'<p>En esta nota se menciona a Kicillof y por reglas de /r/argentina es obligatorio recordar este video: <b><a href="https://www.youtube.com/watch?v=htCUanVT4Dg">Prat-Gay humilló a Axel Kicillof</a></b>.</p>'
],
'ottavis' => [
'<p>- - - - - -</p>',
'<p>Ottavis, <a href="https://i.redd.it/y1y0s803tuux.jpg">orgullo nacional</a>.</p>'
]
];
foreach ($politicos as $politico => $addon) {
if (stripos($text, $politico) !== false) {
$this->dom = new DOMDocument('1.0', 'utf-8');
$this->dom->loadHTML('<?xml encoding="utf-8"?>' . $text);
$this->dom->encoding = 'utf-8';

$frag = $this->dom->createDocumentFragment();
foreach ($addon as $line) {
$frag->appendXML($line);
}

$firma = $this->dom->getElementById('firma');
$firma->appendChild($frag);

return str_replace('<?xml encoding="utf-8"?>', '', $this->dom->saveHTML());
}
}

return $text;
}

public function getNewspaperText($url)
Expand Down

0 comments on commit fa77a21

Please sign in to comment.