This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Load perl scripts to eggdrop

General support and discussion of Eggdrop bots.
Post Reply
h
honken
Voice
Posts: 2
Joined: Sun May 29, 2005 9:06 am
Location: Sweden
Contact:

Load perl scripts to eggdrop

Post by honken »

Hi there.

Been trying now to find out if it's posible to load a perl script to eggdrop.
But when i try to rehash the bot it just died.
With error:
[19:22] Writing user file...
[19:22] Writing channel file...
[19:22] Rehashing ...
[19:22] Listening at telnet port 3434 (bots).
[19:22] Listening at telnet port 4343 (users).
[19:22] Userinfo TCL v1.07 loaded (URL BF GF IRL EMAIL DOB PHONE ICQ).
[19:22] use '.help userinfo' for commands.
[19:22] Tcl error in file 'eggdrop.conf':
[19:22] invalid command name "use"
[19:31] while executing
[19:31] "use threads"
[19:31] (file "/home/bot/mother_mod.pl" line 5)
[19:31] invoked from within
[19:31] "source /home/bot/mother_mod.pl"
[19:31] (file "eggdrop.conf" line 1346)
[19:22] * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR)
After this i was like "aww need perl modules" and did this in my terminal as root.
perl -MCPAN -e "install Bundle::CPAN";
And after this i was sure it would work but you know what? id didn't.
So now im after some help to see if i can get this to work.


First part in the mother_mod.pl script that ends it all.

#!/usr/bin/perl -w

#use strict;
use threads;
use Thread::Queue;
use HTML::TableExtract;
use lib qw( ..);
use LWP::UserAgent;
use HTTP::Cookies;
use Net::Telnet;
Anyone with any good ideas?
Configure a new world. Since the default one sucks.
User avatar
KrzychuG
Master
Posts: 306
Joined: Sat Aug 16, 2003 2:51 pm
Location: Torun, Poland
Contact:

Post by KrzychuG »

Loading a PERL scripts is not possible with Eggdrop 1.6.x. Proper module to support that scripting language exists in 1.9 version.
Que?
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

I wonder if it's of any use... did you test it? I know you're perl guy
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

there is only 1 way I would advise someone to use perl scripts in eggdrop:
make a TCL script, open a pipe to perl and just read the output and throw it in some vars, in a channel or simply eval it if the script returns TCL script.

This may look like something like that then:

Code: Select all

proc getrostatus:t {min h d m y} {
	set sock [open {|perl euro.pl} r]
	fileevent $sock readable [list getrostatus:cb $sock]
	return 0
}

proc getrostatus:cb {sock} {
	global euro
	set status [read $sock]
	if {[catch {close $sock} err]} {
		putlog $err
	} else {
		array set euro $status
	}
	return 0
}
Well, you still need to know some TCL, but you are nolonger bound to restrictions that might apply to TCL. But note that fileevent triggers only about twice a second, so you usually wont get the callback triggered within less than 500ms.
For exeption handling I believe you need to catch the close statement like mentioned above.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

using scripts written in languages other than Tcl (shell, Perl, whatever) by simply piping input/output seems kind of pointless to me (unless you need to do exactly that, i.e. you want to use already made script which is not related to eggdrop, and you are interested in input/only only, not in control)
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
Post Reply