Ignore:
Timestamp:
Jul 31, 2008, 4:13:02 PM (16 years ago)
Author:
george
Message:
  • Přidáno: Podpora pro IRC chat. IRC bot pro sledování historie a ukládání zpráv do databáze.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/www/chat/irc_bot.php

    r94 r98  
    11<?php
    22
    3 // PHP IRC bot
    4 // Based on HARVESTER IRC BOT by Harvie
     3include('../global.php');
    54
    65class IRCBot
     
    109  var $Port = 6667;
    1110  var $Channel = "#zdechov";
    12   var $Nick = "BigBrother";
     11  var $Nick = "History";
    1312  var $JokeFileName = "jokes.txt";
    1413  var $File;
     
    4241  function Run()
    4342  {
     43    global $Database;
     44
    4445    while(!fwrite($this->File, ''))
    4546    {
     
    7071      }
    7172
     73      // Log messages to database
     74      if(strpos($Line, 'PRIVMSG') !== false)
     75      {
     76        $LineParts = explode(':', $Line);
     77        $Text = $LineParts[2];
     78        $LineParts2 = explode(' ', $LineParts[1]);
     79        $LineParts3 = explode('@', $LineParts2[0]);
     80        $Host = $LineParts3[1];
     81        $LineParts4 = explode('!', $LineParts3[0]);
     82        $Nick = $LineParts4[0];
     83        $Database->insert('ChatHistory', array('Nick' => $Nick, 'Text' => $Text, 'Host' => $Host, 'Time' => 'NOW()', 'RoomName' => 'Všichni'));
     84      }
     85
    7286      $Commands = explode(':', $Line);
    7387      foreach($Commands as $Index => $Item)
     
    90104          $this->Say('Ja jsem Harvester.');
    91105          /*
    92           irc_say( $sfp, "Harvester - Posle vizitku", $nick, $channel );
     106          irc_say( $sfp, "Bot - Posle vizitku", $nick, $channel );
    93107          irc_say( $sfp, "hhelp - vypise tuto napovedu", $nick, $channel );
    94108          irc_say( $sfp, "hsay:Message - Posle zpravu", $nick, $channel );
Note: See TracChangeset for help on using the changeset viewer.