sf-active to irc

first, sorry for my english!

What the fuck is sfa2irc ?

sfa2irc is a script which allows you to enable or disable a realtime newsposter for incomming articles and comments to your sf-active cms. The script needs a running Sf-Active page (written for Version 0.9.4), 2 new mysql tables and an eggdrop irc bot.

Give me an example! Now

Okay, if you've installed to your sf-active system and got a running eggdrop, then you can add different channels to the sfa2irc script. You can select if the eggdrop have to post only new articles, or also comments. You can also select in which lanuage the bot have to post the news to the channel.

if you wanna see a already running sfa2irc, you can take a look to http://sfa.hmpf.info, join the channel #de-tech and #ircd on the irc.indymedia.org network and poste a new article or comment to the website. the bot will say something like this:

The lang for #ircd is english, so the bot say:
<@HmpF> New Article with the title "Test" was posted by Tammo-Tester. URL: http://sfa.hmpf.info/news/2005/01/43.php

The lang for #de-tech is german, so the bot say:
<@HmpF> Ein Artikel mit dem Thema "Test" wurde von Tammo-Tester eingetragen. URL: http://sfa.hmpf.info/news/2005/01/43.php

Yeah, man! cool stuff... and how i can install it to my sfa ?

k, you have to add some things to already existing files on the server, add a new file into a ne dir and you've to create 2 new MySQL-Tables

lets begin: go to the directory "/sf-active/sitename/website/admin/" and make a new folder called "sfa2irc", go into it and upload the index.php from the index_php.zip file. open the file and go to line 50 and edit the serverdatas.

k, now open the file /sf-active/sitename/local/include/admin-header.inc go to the line 105 and add the following line there:
<tr><td bgcolor="#e0e0e0"><a class="nav" href="/admin/sfa2irc/">sfa2irc</a></td></tr>
save and close it.

now we've to add the tables to the MySQL database. Connect to the DB, select the database and run the following command:

CREATE TABLE `sfa2irc` (
  `id` int(1) NOT NULL default '1',
  `enable` char(1) NOT NULL default '0',
  `egghost` varchar(255) NOT NULL default 'hmpf.info',
  `eggport` varchar(255) NOT NULL default '3333',
  `eggname` varchar(10) NOT NULL default 'hmpf',
  `egguser` varchar(255) NOT NULL default 'sf-active',
  `eggpassword` varchar(255) NOT NULL default 'blubb',
  `eggchannel` varchar(255) NOT NULL default '#hmpf',
  `egglang` varchar(255) NOT NULL default 'en_EN',
  PRIMARY KEY  (`id`)
INSERT INTO `sfa2irc` (`id`, `enable`, `egghost`, `eggport`, `eggname`, `egguser`, `eggpassword`, `eggchannel`, `egglang`) VALUES (1, '1', 'hmpf.info', '3333', 'hmpf', 'sf-active', 'blubb', '#hmpf', 'en_EN');

CREATE TABLE `sfa2irc_chan` (
  `id` int(10) NOT NULL auto_increment,
  `eggchannel` varchar(255) NOT NULL default '',
  `eggchanlang` varchar(255) NOT NULL default '',
  `postarticle` varchar(255) NOT NULL default '0',
  `postcomment` varchar(255) NOT NULL default '0',
  PRIMARY KEY  (`id`)

if the tables are created disconnect from the MySQL Server.

now open the file "/sf-active/shared/classes/article_class.inc", near of the line 900 you can find the following code:
        $this->article["id"] = $db_obj->execute_statement_return_autokey($query);

Replace it with the following code:

        $this->article["id"] = $db_obj->execute_statement_return_autokey($query);
// beginning of sfa2irc by tammo

$tammodate = date("Y");
$tammodate .= "/";
$tammodate .= date("m");
$sfa2irc_chantable = "sfa2irc_chan";
$eggquit = ".quit";
        $sfa2ircCheck=mysql_query("SELECT * FROM sfa2irc");
        if ($this->article['arttype'] == "news-response") {
          $ParentID = $this->article["parent_id"];
        $sfa2ircCommentCheck=mysql_query("SELECT * FROM webcast WHERE id = '$ParentID'");
        $ParentDate2 = preg_split('//',$ParentDate1, -1, PREG_SPLIT_NO_EMPTY);
        $ParentTempURL = $ParentDate2[0];
        $ParentTempURL .= $ParentDate2[1];
        $ParentTempURL .= $ParentDate2[2];
        $ParentTempURL .= $ParentDate2[3];
        $ParentTempURL .= "/";
        $ParentTempURL .= $ParentDate2[4];
        $ParentTempURL .= $ParentDate2[5];
        $articleURL =    SF_NEWS_URL . "/" . $tammodate . "/" . $this->article["id"] . ".php";
        $commentURL =    SF_NEWS_URL . "/" . $ParentTempURL . "/" . $this->article["parent_id"] . ".php";

if ($eggenable == "1") {
 $fp = fsockopen ($egghost, $eggport, &$errno, &$errstr, 180);
 sleep ( 2 );
   if (!$fp) {
     echo "$errstr ($errno)<br />\r\n";
  } else {
 fputs ($fp, $egguser ."\r\n");
  fputs ($fp, $eggpass ."\r\n");
      $AbfragE = "SELECT id,eggchannel,eggchanlang,postarticle,postcomment from $sfa2irc_chantable ORDER BY 'id' ASC";
      $ergEdit = mysql_db_query(DB_DATABASE,$AbfragE);

while (list($chanid,$eggchannel,$eggchanlang,$postarticle,$postcomment) = mysql_fetch_row($ergEdit)) {
 if ($eggchanlang == "de_DE") {
 $teXT12 = "Ein Artikel mit dem Thema \"" . $this->article["heading"] . " \" wurde von  " . $this->article["author"] . " eingetragen. URL: " . $articleURL . "";
 $teXT1 = "Ein Kommentar von " . $this->article["author"] . " wurde zum folgendem Artikel hinzugef\xFCgt: " . $commentURL . "";

elseif ($eggchanlang == "en_EN") {
 $teXT12 = "New Article with the title \"" . $this->article["heading"] . "\" was posted by " . $this->article["author"] . ". URL: " . $articleURL . "";
 $teXT1 = "A new comment was added by " . $this->article["author"] . " in the article: " . $commentURL . "";

      if (($this->article["arttype"] == "webcast") && ($postarticle == "1")) {
$eggcommand1 = ".say $eggchannel $teXT12";
  fputs ($fp, $eggcommand1 ."\r\n");
} elseif (($this->article["arttype"] == "news-response") && ($postcomment == "1")) {
$eggcommand2 = ".say $eggchannel $teXT1";
  fputs ($fp, $eggcommand2 ."\r\n");
  sleep ( 1 );
  fputs ($fp, $eggquit ."\r\n");

// end of sfa2irc by tammo
Save and exit the file.

boah!! now we're ready to logon to the administration center of your sf-active and edit the sfa2irc configs.

k, installed and where i can get the eggdrop now ?

You can download it from ftp://ftp.eggheads.org/pub/eggdrop/source/1.6/eggdrop1.6.17.tar.gz you can use the same eggdrop and the same eggdrop-login for different sf-actives

-- TammO - 23 Jan 2005
Topic revision: r6 - 23 Nov 2005, PaulWise
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback