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.

Trigger Script on e-Mail arrival

Old posts that have not been replied to for several years.
Locked
D
Dark-Sider
Voice
Posts: 2
Joined: Tue Feb 08, 2005 2:56 pm

Trigger Script on e-Mail arrival

Post by Dark-Sider »

Hi,

I have an Eggdrop-Bot up and running. Now I want to script a script which is triggered by an event on the server. Like an e-Mail arrives, the mailer pipes the content of the mail to the bot and the bot parses the mail and displays its content in the chan.

Till now I have not a single clue how an external event can trigger an eggdrop script - is there any chance to do this?

bye
Darky
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

i dont exactly know how email filenames are aranged, but using the tcl command file exists or mtime there should be possibilites to check the email dir on a time bind.
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...
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

probably you would wana use imapd or pop3d, but if you wana use the mail file then file exists won't do you no good if you know that mail is stored in one file and every mail that is read has Status: RO or something like it..

mail is ceperated by mailheader (From: .. ) so if a new mail is arraived just open your mail file /var/mail probably and look for mail with no Status: RO in the header
XplaiN but think of me as stupid
D
Dark-Sider
Voice
Posts: 2
Joined: Tue Feb 08, 2005 2:56 pm

Post by Dark-Sider »

Hi,

to stress it out: I don't want a timed event (because it would be too easy ;-).

My current approch looks like: e-Mail received by qmail. prcomail triggers a sighup to eggdrop which starts the mail script everytye sighup is received (bind evnt). The script looks in the maildir, parses all new mail an deletes every parsed mail. So I don't have to deal with the mbox stuff.

The best soloution would be in my opinion if the eggdrop opens an unix socket where i can "pipe" in the mail and a tcl script processes the data received on that socket - is this possible?

bye
Darky
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

you know what also could be done ?


if you just wana know if an email arives yes or no
then do this

Code: Select all

set file /path/to/mail/file
if {[info exists filesize]} {
  if {[file size $file] != $filesize]} {
     puts "You've got mail."
     set filesize [file size $file]
  }
} else {
  set filesize [file size $file]
}
XplaiN but think of me as stupid
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

Dark-Sider wrote:Hi,

to stress it out: I don't want a timed event (because it would be too easy ;-).

My current approch looks like: e-Mail received by qmail. prcomail triggers a sighup to eggdrop which starts the mail script everytye sighup is received (bind evnt). The script looks in the maildir, parses all new mail an deletes every parsed mail. So I don't have to deal with the mbox stuff.

The best soloution would be in my opinion if the eggdrop opens an unix socket where i can "pipe" in the mail and a tcl script processes the data received on that socket - is this possible?

bye
Darky
yeah i gues so but i don't see the use .. if you bind to every minute then it can be done like 1000000000 times more easy why do it the hard way? hell and a socket can kill the bot if you don't be carefull, well i wouldn't like .. to use a socket in this way
XplaiN but think of me as stupid
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Dark-Sider,

I don't think tcl has commands to deal with unix sockets, just tcp. You could load an extension (I'm sure there are some), or write a module instead. Also there's almost no difference between a tcp socket and a unix socket so you could just use that. The easiest thing would be to use a named pipe instead of a socket and use regular file commands.
Locked