- Timestamp:
- 01/24/12 21:16:27 (4 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ImmediateNotifyPlugin/lib/Foswiki/Plugins/ImmediateNotifyPlugin/IRC.pm
r13777 r13817 1 # Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/ 2 # 3 # Copyright (C) 2005 TWiki Contributors. All Rights Reserved. 4 # TWiki Contributors are listed in the AUTHORS file in the root 5 # of this distribution. 6 # NOTE: Please extend that file, not this notice. 7 # 8 # Additional copyrights apply to some or all of the code in this 9 # file as follows: 10 # Copyright (C) 2000-2003 Andrea Sterbini, a.sterbini@flashnet.it 11 # Copyright (C) 2001-2004 Peter Thoeny, peter@thoeny.com 12 # 13 # This program is free software; you can redistribute it and/or 14 # modify it under the terms of the GNU General Public License 15 # as published by the Free Software Foundation; either version 2 16 # of the License, or (at your option) any later version. For 17 # more details read LICENSE in the root of this distribution. 18 # 19 # This program is distributed in the hope that it will be useful, 20 # but WITHOUT ANY WARRANTY; without even the implied warranty of 21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1 # See bottom of file for default license and copyright information 22 2 23 = pod3 =begin TML 24 4 25 ---+ package IrcPlugin5 ---+ package Foswiki::Plugins::ImmediateNotifyPlugin::IRC 26 6 7 This plugin module supports immediate notification of topic saves using the IRC (Jabber) protocol. 8 . 27 9 =cut 28 10 29 package TWiki::Plugins::IrcPlugin; 11 package Foswiki::Plugins::ImmediateNotifyPlugin::IRC; 12 30 13 use strict; 14 use warnings; 31 15 32 use Net::IRC; 16 #use Net::IRC; DEPRECATED 17 18 use Bot::BasicBot; 33 19 use Data::Dumper; 34 20 35 use vars qw( $VERSION $RELEASE $debug $pluginName ); 36 $VERSION = '$Rev$'; 37 $RELEASE = 'Dakar'; 21 my $debug; 22 my $warning; 38 23 39 # Name of this Plugin, only used in this module 40 $pluginName = 'IrcPlugin';24 sub new { 25 my ($class) = @_; 41 26 42 ################################################################################ 27 my $this = bless( {}, $class ); 43 28 44 sub initPlugin { 45 my( $topic, $web, $user, $installWeb ) = @_; 29 $this->{ircUser} = 30 $Foswiki::cfg{Plugins}{ImmediateNotifyPlugin}{IRC}{Username}; 31 $this->{ircPass} = 32 $Foswiki::cfg{Plugins}{ImmediateNotifyPlugin}{IRC}{Password}; 33 $this->{ircServer} = 34 $Foswiki::cfg{Plugins}{ImmediateNotifyPlugin}{IRC}{Server}; 46 35 47 # check for Plugins.pm versions 48 if( $TWiki::Plugins::VERSION < 1.026 ) { 49 TWiki::Func::writeWarning( "Version mismatch between $pluginName and Plugins.pm" ); 50 return 0; 51 } 36 # SMELL: Resource allows multiple concurrent logins - consider including 37 # the pid or some other identifier so multiple fastcgi handlers could 38 # maintain concurrent connections. 39 $this->{ircResource} = 40 'Foswiki'; #Foswiki::Func::getPreferencesValue( 'WIKITOOLNAME' ); 41 $this->{con} = ''; 52 42 53 # Plugin correctly initialized 54 return 1; 43 $debug = \&Foswiki::Plugins::ImmediateNotifyPlugin::debug; 44 $warning = \&Foswiki::Plugins::ImmediateNotifyPlugin::warning; 45 46 &$debug( 47 "- IRC init with $this->{ircUser}, $this->{ircPass}, $this->{ircServer}" 48 ); 49 50 return $this; 55 51 } 52 53 56 54 57 55 sub afterSaveHandler { … … 59 57 my ( $topic, $web, $error, $meta ) = @_[1..4]; 60 58 61 TWiki::Func::writeDebug( "- ${pluginName}::afterSaveHandler( ${web}.${topic} )" ) if $debug;59 Foswiki::Func::writeDebug( "- ${pluginName}::afterSaveHandler( ${web}.${topic} )" ) if $debug; 62 60 63 61 my $topicInfo = $meta->get( 'TOPICINFO' ); … … 66 64 67 65 _writeIrc({ newconn => { 68 Server => TWiki::Func::getPluginPreferencesValue( 'SERVER' ) || 'localhost',69 Port => TWiki::Func::getPluginPreferencesValue( 'PORT' ) || '6667',70 Nick => ' TWikiIrcPlugin' || TWiki::Func::getPluginPreferencesValue( 'NICK' ) || 'TWikiIrcPlugin',66 Server => Foswiki::Func::getPluginPreferencesValue( 'SERVER' ) || 'localhost', 67 Port => Foswiki::Func::getPluginPreferencesValue( 'PORT' ) || '6667', 68 Nick => 'FoswikiIrcPlugin' || Foswiki::Func::getPluginPreferencesValue( 'NICK' ) || 'FoswikiIrcPlugin', 71 69 # Ircname => 'This bot brought to you by Net::IRC.', 72 # Username => ' TWikiIrcPlugin',70 # Username => 'FoswikiIrcPlugin', 73 71 }, 74 msg => TWiki::Func::getScriptUrl( $web, $topic, 'view' ) . ' '72 msg => Foswiki::Func::getScriptUrl( $web, $topic, 'view' ) . ' ' 75 73 . ( $version == 1 ? 'created' : "updated to r$version" ) 76 74 . " by $topicInfo->{author}", … … 115 113 my $self = shift; 116 114 117 my $CHANNEL = TWiki::Func::getPluginPreferencesValue( 'CHANNEL' ) || 'test';115 my $CHANNEL = Foswiki::Func::getPluginPreferencesValue( 'CHANNEL' ) || 'test'; 118 116 $self->join( $CHANNEL ); 119 117 # print STDERR "nick=[" . $self->nick . "]\n"; … … 153 151 154 152 1; 153 154 __END__ 155 Foswiki - The Free and Open Source Wiki, http://foswiki.org/ 156 157 Copyright (C) 2012 Foswiki Contributors. Foswiki Contributors 158 are listed in the AUTHORS file in the root of this distribution. 159 160 Additional copyrights apply to some or all of the code in this 161 file as follows: 162 Copyright (C) 2005 TWiki Contributors. All Rights Reserved. 163 TWiki Contributors are listed in the AUTHORS file in the root 164 of the TWiki distribution. 165 Copyright (C) 2000-2003 Andrea Sterbini, a.sterbini@flashnet.it 166 Copyright (C) 2001-2004 Peter Thoeny, peter@thoeny.com 167 168 This program is free software; you can redistribute it and/or 169 modify it under the terms of the GNU General Public License 170 as published by the Free Software Foundation; either version 2 171 of the License, or (at your option) any later version. For 172 more details read LICENSE in the root of this distribution. 173 174 This program is distributed in the hope that it will be useful, 175 but WITHOUT ANY WARRANTY; without even the implied warranty of 176 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 177 178 As per the GPL, removal of this notice is prohibited. 179
Note: See TracChangeset
for help on using the changeset viewer.
