• Inloggen
  • Registreer
  • Zoeken
Dit topic
  • Overal
  • Dit topic
  • Dit forum
  • Artikelen
  • Pagina's
  • Forum
  • Downloads
  • Meer opties

ICTscripters

Dé plek voor IT

Dé plek voor IT

Aanmelden

Geavanceerde opties
  1. Home
  2. Forum
    1. Alle berichten
    2. Recente activiteiten
    3. Onopgeloste topics
  3. ICT Nieuws
  4. Blog
  5. Marktplaats
    1. Werk
    2. Advertenties
    3. Domeinnamen
    4. Websites
    5. Design & lay-outs
    6. Scripts
    7. Overige
  6. Design
  7. Leden
    1. Actieve bezoekers
    2. Team
    3. Leden zoeken
  8. Downloads
  1. Home
  2. Forum
    1. Alle berichten
    2. Recente activiteiten
    3. Onopgeloste topics
  3. ICT Nieuws
  4. Blog
  5. Marktplaats
    1. Werk
    2. Advertenties
    3. Domeinnamen
    4. Websites
    5. Design & lay-outs
    6. Scripts
    7. Overige
  6. Design
  7. Leden
    1. Actieve bezoekers
    2. Team
    3. Leden zoeken
  8. Downloads
  1. Home
  2. Forum
    1. Alle berichten
    2. Recente activiteiten
    3. Onopgeloste topics
  3. ICT Nieuws
  4. Blog
  5. Marktplaats
    1. Werk
    2. Advertenties
    3. Domeinnamen
    4. Websites
    5. Design & lay-outs
    6. Scripts
    7. Overige
  6. Design
  7. Leden
    1. Actieve bezoekers
    2. Team
    3. Leden zoeken
  8. Downloads
  1. Dé plek voor IT - ICTscripters
  2. Forum
  3. Scripting & programmeren
  4. Advanced Programming

Forum

  • nieuwe game

    frio 1 november 2026 om 14:08
  • Criminolz

    qevanto 31 oktober 2026 om 20:52
  • [Beta] Ottomaan: gratis browserspel met een echte, levende stad. Feedback gezocht!

    frio 27 oktober 2026 om 12:22
  • Port Father: beta van een browsergame in Antwerpen 1931, feedback welkom

    Jeroen.G 26 oktober 2026 om 10:33
  • Maffia Hotel: een browsergame waarin je van lobbygast naar spil van het hotel groeit

    eeyk 22 oktober 2026 om 18:43
  • Crime Club volledig herschreven vanaf nul

    frio 19 oktober 2026 om 23:57
  • Malavita (nieuwe maffia game, van 0)

    jos 19 oktober 2026 om 23:18
  • Herkent deze Notion-structuurscan echte problemen?

    Jeroen.G 19 oktober 2026 om 15:09

Marktplaats

  • [Aanbod] Stadskaart voor je browsergame: van menu naar klikbare stad, vanaf €200

    frio 29 oktober 2026 om 18:17
  • [Verkoop] G4G (Gangsters 4 Gangsters): volledige broncode, nieuw gebouwd in PHP 8.3 | € 30 per domein

    frio 27 oktober 2026 om 18:54
  • [TE KOOP] Malavita.be [Maffiaspel, gebaseerd op omicidio.nl, unieke code]

    Dpm_x 26 oktober 2026 om 00:22

IRC bot class

  • Patrick
  • 11 november 2010 om 15:10
  • Patrick
    Back in the game
    Berichten
    1.417
    • 11 november 2010 om 15:10
    • #1
    PHP
    Class ViiIrcBot {
        
        protected $BotSocket;
        protected $BotConfig;
        protected $BotData;
        
        public function __construct () {
            
            
            $this->BotConfig = array(
            
                /**
                 * Bot configuration for information
                 */
                 
                'nickname' => 'ViiBot2',
                'realname' => 'Vii personal bot',
                'ident'    => 'ViiBot',
                
                /**
                 * Bot server configration
                 */
                 
                'hostname' => 0,
                'server'   => 'ogn1.ogamenet.net',
                'port'    => 6667,
                
                /**
                 * Bot channel configration
                 */
                 
                'channel'  => array('#Vii')
            );
             
             
             /**
              * Prepare for bot connection
              */
              
              if(!$this->ConnectViiBot()) {
                    die('Connection failed.');
              }
              else {
                
                    $this->ConnectToIrc();
                    $this->BotMainLoop();
              }
        }
        
        protected function ConnectViiBot() {
            
            /**
             * Create a socket for bot connection
             */
             
            $this->BotSocket = socket_create(AF_INET,SOCK_STREAM,SOL_TCP);
            if (!$this->BotSocket) {
                return false;
            }
            
            /**
             * Bind the socket to make it irc'able 
             */
             
            if(!socket_bind($this->BotSocket, $this->BotConfig['hostname'])) { 
                return false;
            } 
            if(!socket_connect($this->BotSocket, $this->BotConfig['server'], $this->BotConfig['port'])) { 
                return false;
            } 
            
            /**
             * Return positive result
             */
            return $this->BotSocket;
        }
        
        protected function ConnectToIrc () {
            
            /**
             * Utilize connection
             */
            
            $this->RawWrite('USER ' . $this->BotConfig['ident']. ' ' . $this->BotConfig['hostname'] . ' ' . $this->BotConfig['server'] . ' :'. $this->BotConfig['realname']); 
                            
            /**
             * Define bot nickname to use
             * on the server
             */
                            
            $this->RawWrite('NICK ' . $this->BotConfig['nickname']);
            return true; 
        }
        
        protected function RawWrite ($Parameter) {
            
            /**
             * Write raw data to server
             */
            
            echo $Parameter;
            if(!socket_write($this->BotSocket, $Parameter . '\r\n')){
                die('error!');
            }
        }
        
        protected function BotMainLoop () {
            $inKanaal = false; 
            while($data = socket_read($this->BotSocket,65000,PHP_NORMAL_READ)) { 
                if($data == "\n") continue; 
                
                if ($data = 'NOTICE AUTH :*** No ident response') {
                    $this->RawWrite('USER ' . $this->BotConfig['ident']. ' ' . $this->BotConfig['hostname'] . ' ' . $this->BotConfig['server'] . ' :'. $this->BotConfig['realname']); 
                }
                
                $write = fopen('log.txt', 'w');
                $writenow = fwrite($write, $data);
            }
        }
    }
    
    
    $ViiBot = new ViiIrcBot();
    ?>
    Meer tonen


    probleem is dat hij blijft haken op dat hij geen ident, toe krijgt gestuurd daar in tegen doe ik wel sturen met de "nick" en "user" writing...

    op 1 of andere manier pakt hij die niet >_>

    en btw let niet op de loop :P

  • Gast, wil je besparen op je domeinnamen? (ad)
  • Patrick
    Back in the game
    Berichten
    1.417
    • 11 november 2010 om 17:33
    • #2

    voor de gene die het willen weten wat de fout was:

    in de raw_write functie:

    PHP
    if(!socket_write($this->BotSocket, $Parameter . "rm"

    moet met dubbele quote tekens enkele doet hij het niet ^^

    Nieuwe reactie samengevoegd met originele reactie op 12.11.10 00:53:10:
    en voor de mensen die een opstart willen hebben voor een irc bot:

    PHP
    <?php
    
    
    /**
     * @filesource bot.php
     * @version 0.1-alpha
     * @author Patrick Rennings
     * @copyright 2010
     * 
     * @usage Basic IRC Bot class
     */
    
    
    Class ViiIrcBot {
        
        protected $BotSocket;
        protected $BotConfig;
        protected $BotData;
        
        protected $Parameter;
        
        /**
         * @name    ViiIrcBot::__construct
         * @param   void
         * @return  void
         * 
         * @usage  Main part for creating the bot
         */
        
        public function __construct () {
            
            
            $this->BotConfig = array(
            
                /**
                 * Bot configuration for information
                 */
                 
                'nickname' => 'ViiBot4',
                'realname' => 'Vii personal bot',
                'ident'    => 'ViiBot',
                
                /**
                 * Bot server configration
                 */
                 
                'hostname' => 0,
                'server'   => 'ogn1.ogamenet.net',
                'port'    => 6667,
                
                /**
                 * Bot channel configration
                 */
                 
                'channel'  => array('#Vii')
            );
             
             
             /**
              * Prepare for bot connection
              */
              
              if(!$this->ConnectViiBot()) {
                    die('Connection failed.');
              }
              else {
                
                    $this->ConnectToIrc();
                    $this->BotMainLoop();
              }
        }
        
        /**
         * @name    ViiIrcBot::ConnectViiBot
         * @param   void
         * @return  boolean
         * 
         * @usage  login to the irc server
         */
        
        protected function ConnectViiBot() {
            
            /**
             * Create a socket for bot connection
             */
             
            $this->BotSocket = socket_create(AF_INET,SOCK_STREAM,SOL_TCP);
            if (!$this->BotSocket) {
                return false;
            }
            
            /**
             * Bind the socket to make it irc'able 
             */
             
            if(!socket_bind($this->BotSocket, $this->BotConfig['hostname'])) { 
                return false;
            } 
            if(!socket_connect($this->BotSocket, $this->BotConfig['server'], $this->BotConfig['port'])) { 
                return false;
            } 
            
            /**
             * Return positive result
             */
            return $this->BotSocket;
        }
        
        /**
         * @name    ViiIrcBot::ConnectToIrc
         * @param   void
         * @return  boolean
         * 
         * @usage  Connect to the irc server
         */
        
        protected function ConnectToIrc () {
            
            /**
             * Utilize connection
             */
            
            $this->RawWrite('USER ' . $this->BotConfig['ident']. ' ' . $this->BotConfig['hostname'] . ' ' . $this->BotConfig['server'] . ' :'. $this->BotConfig['realname']); 
                            
            /**
             * Define bot nickname to use
             * on the server
             */
                            
            $this->RawWrite('NICK ' . $this->BotConfig['nickname']);
            return true; 
        }
        
        /**
         * @name    ViiIrcBot::RawWrite
         * @param   $Parameter
         * @return  void
         * 
         * @usage   dump an raw line in to the server
         */  
        
        protected function RawWrite ($Parameter) {
            
            socket_write($this->BotSocket, $Parameter . "\r\n");
            
        }
    
    
        /**
         * @name    ViiIrcBot::DefineRawLine
         * @param   void
         * @return  Void
         * 
         * @usage   Defining usable parameters for commands
         */ 
        
        protected function DefineRawLine($RawLine) {
            $this->Parameter['hostmask'] = $RawLine[0];
            $this->Parameter['servercmd'] = $RawLine[1];
            $this->Parameter['location'] = $RawLine[2];
            $this->Parameter['command'] = trim(substr($RawLine[3], 1));
                    
            if (!empty($this->Parameter['command'])) {
                $ExplodingPar = explode($RawLine[3], $this->BotData);
                $this->Parameter['parameters'] = $ExplodingPar[1];
            }
            
            /**
             * Splitting hostmask for usable things
             * $this->Parameter['hostmask'] = Vii`[email protected]
             */
             
             if (preg_match('/^([^!@]+)!(?:[ni]=)?([^@]+)@([^ ]+)/', $this->Parameter['hostmask'])) {
                $TempStorage = preg_match('/^([^!@]+)!(?:[ni]=)?([^@]+)@([^ ]+)/', $this->Parameter['hostmask'], $HostArray);
                $this->Parameter['hostmask'] = array();
                
                $this->Parameter['hostmask']['hostmask'] = substr($HostArray[0], 1);
                $this->Parameter['hostmask']['nickname'] = substr($HostArray[1], 1);
                $this->Parameter['hostmask']['ident'] = $HostArray[2];
                $this->Parameter['hostmask']['banmask'] = '*!*@' . $HostArray[3];
             }
             
        }
        
        /**
         * @name    ViiIrcBot::BotMainLoop
         * @param   void
         * @return  boolean
         * 
         * @usage   Main loop of usage of the bot
         */ 
        
        protected function BotMainLoop () {
            while($this->BotData = socket_read($this->BotSocket,65000,PHP_NORMAL_READ)) { 
                
                /**
                 * Even when the line is empty, just continue
                 */
                 
                if($this->BotData == "\n") { continue; } 
                
                /**
                 * Get usable data from the raw output line of irc
                 */
                
                $ConfiguratingData = explode(' ', $this->BotData);
                $this->DefineRawLine($ConfiguratingData);
                
                /**
                 * Go play ping pong with the server
                 */
                 
                if($this->Parameter['hostmask'] == 'PING') { 
                    $this->RawWrite('PONG '. $this->Parameter['servercmd']);  
                } 
                
                
                /**
                 * Other commands
                 */
                
                if ($this->Parameter['command'] == '!raw') {
                    $this->RawWrite($this->Parameter['parameters']);
                }
                
                if ($this->Parameter['command'] == '!hostmask') {
                    $this->RawWrite('PRIVMSG ' . $this->Parameter['location'] . ' :Hostmask:' . $this->Parameter['hostmask']['hostmask']);
                    $this->RawWrite('PRIVMSG ' . $this->Parameter['location'] . ' :Nickname: ' . $this->Parameter['hostmask']['nickname']);
                    $this->RawWrite('PRIVMSG ' . $this->Parameter['location'] . ' :Banmask: ' . $this->Parameter['hostmask']['banmask']);
                    $this->RawWrite('PRIVMSG ' . $this->Parameter['location'] . ' :Identity: ' . $this->Parameter['hostmask']['ident']);
                }
                            
                if ($this->Parameter['command'] == '!parameter') {
                    $this->RawWrite('PRIVMSG ' . $this->Parameter['location'] . ' :Server command: ' . $this->Parameter['servercmd']);
                    $this->RawWrite('PRIVMSG ' . $this->Parameter['location'] . ' :Localation:' . $this->Parameter['location']);
                    $this->RawWrite('PRIVMSG ' . $this->Parameter['location'] . ' :Command: ' . $this->Parameter['command']);
                    $this->RawWrite('PRIVMSG ' . $this->Parameter['location'] . ' :Parameters: ' . $this->Parameter['parameters']);
                }
                                                                
            }
        }
    }
    
    
    $ViiBot = new ViiIrcBot();
    ?>
    Meer tonen

    en ja dit is omdat ik niks te doen heb :P

Registratie

Nog geen account? Registreer je nu en word deel van onze community!

Nu registreren Aanmelden

ICT Nieuws

  • PHP waarschuwt voor twee ernstige bugs die makkelijk uit te buiten lijken

    Aaron 22 oktober 2026 om 22:19

Blogs

  • Functioneel ontwerp

    Dees 28 december 2014 om 12:38
  • Access Control List implementatie in PHP/MySQL - deel 1/2

    FangorN 28 december 2018 om 12:35
  • Access Control List implementatie in PHP/MySQL - deel 2/2

    FangorN 29 december 2018 om 12:37

Gebruikers die dit topic bekijken

  • 2 Gasten
  1. Marktplaats
  2. Design
  3. Voorwaarden
  4. Ons team
  5. Leden
  6. Geschiedenis
  7. Regels
  8. Links
  9. Privacyverklaring
  10. Contact
ICTscripters ©2005 - 2026 , goedkope hosting door DiMoWeb.com, BE0558.915.582
Sponsors: Beste kattenhotel provincie Antwerpen
Style: Nexus by cls-design
Stylename
Nexus
Manufacturer
cls-design
Licence
Commercial styles
Help
Supportforum
Visit cls-design