Тема: YourICQ BOT
Показать сообщение отдельно

  #189  
Старый 19.08.2008, 18:21
Byrger
Постоянный
Регистрация: 07.03.2008
Сообщений: 479
С нами: 9567480

Репутация: 61
По умолчанию

помогите переписать под этот YourICQ бота

PHP код:
<?php


class bashorg {
    
    static 
$regexp '~<div class="q">[\s|\S]*?<\/div>\s{0,}<div>([\s|\S]*?)<\/div>~',
           
$buffer = array();

    static function 
SendQuote() {
        
$quote array_pop(self::$buffer);
        
SteelBot::Msg($quote);
        if ( 
count(self::$buffer) < ) {
            
self::RefreshDB();
        }
    }

    static function 
RefreshDB() {
        
$result '';
        if (
$sock fsockopen("bash.org.ru"80) ) {        
            
$d fputs ($sock"GET http://bash.org.ru/random HTTP/1.0\n");

            
fputs ($sock"Connection: Keep-Alive\n".
                          
"User-Agent: SteelBot/1.0 (http://steelbot.net)\n".
                          
"Host: bash.org.ru\n".
                          
"Pragma: no-cache\n".
                          
"Cache-Control: no-cache\n".
                          
"Connection: close\n\n" );

            while ( !
feof($sock) ) {
                
$result .= fgets($sock1024);
            }
            
preg_match_all(self::$regexp$result$matches);
                
            foreach(
$matches[1] as $quot) {
                
$quot html_entity_decode($quot);
                
$quotstr_replace( array("<br>""<br />"), "\n"$quot);
                
self::$buffer [] = iconv('WINDOWS-1251''UTF-8'$quot);;
            }
            
fclose($sock);
            echo 
"[bashorg] quotes buffer has been refreshed (".count(self::$buffer)." quotes added).\n";
        } else {
            echo 
"[bashorg] ERROR: can't establish connection to bash.org.ru\n";
        }
    }




SteelBot::RegisterCmd('bash', array('bashorg''SendQuote'), 1'bash - чтение цитат с bash.org.ru');
bashorg::RefreshDB();
 
Ответить с цитированием