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.

Quesation: Is it possible to do this with a TCL script?

Help for those learning Tcl or writing their own scripts.
Post Reply
l
l8night
Voice
Posts: 12
Joined: Mon Dec 17, 2007 8:43 pm

Quesation: Is it possible to do this with a TCL script?

Post by l8night »

Hi,

I'm new to tcl scripting and have an idea for a script, and I would just like to know if it is even possible before I attempt to write it.

Scenario:

I have a shell account that will get deleted if it is the oldest of 300 accounts. To check how old your account is you simply go to a certain IRC channel and type the command ' howold username ' and a bot will tell how many accounts are older than yours. I want to write a script for my eggdrop that will do this 'howold' command every so often, and when a certain number of accounts are older than mine, the bot will send an email to notify me to renew my shell account. The only part I'm really not sure about is if you can add mail server functionality to a script.

Any response or direction will be greatly appreciated.

Regards, Jeff
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

You will first have to find out how the age is determined. Simply going by uid may not work as some (if not most) shell providers configure their adduser scripts to reuse uids.

On most shells, using TCL exec command to run commandline mail is possible.
l
l8night
Voice
Posts: 12
Joined: Mon Dec 17, 2007 8:43 pm

Post by l8night »

The age of the account is determined like this----

There can only be 300 accounts total on the shell server.
You sign up for an account and there are 299 accounts older than yours. another person gets an account and now there's 298 accounts older than yours, when there are 0 accounts older than your account it's gets deleted.
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

l8night wrote:The age of the account is determined like this----

There can only be 300 accounts total on the shell server.
You sign up for an account and there are 299 accounts older than yours. another person gets an account and now there's 298 accounts older than yours, when there are 0 accounts older than your account it's gets deleted.
This does not tell anyone how the age is figured out, this only restates the scenario.
So, I'll ask again. How do users know how old their account is?
l
l8night
Voice
Posts: 12
Joined: Mon Dec 17, 2007 8:43 pm

Post by l8night »

ok ... I hope this makes since to you. I'm going to go and check the age of the account right now by going to this irc channel and typing in the command
howold myaccountname. This is the output that I got , At the moment there are 191 accounts older then "myaccount". That is how the age of my account is determined, by the number of accounts older than mine, or by the number of accounts newer than mine.
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

I suggest using a timer, or a time bind, to out put "howold account" to the channel.

You can use pubm bind to catch the reply based on "At the moment there are * accounts older then account", and suggest further creating a condition based on the uhost of the responding bot (to prevent some malicious user from simply creating a script that spits out "At the moment there are 1 accounts older then account" in reply to your bot's request).

Have the bot write the response it gets to a file, then use something like the following to send it:

Code: Select all

exec mail -s "Account age" my@email.com < filename
Since you asked this in the "Scripting Help" forum, and not the request forum, these are the best tips I can give for your script because you provided none of the code you are using.
l
l8night
Voice
Posts: 12
Joined: Mon Dec 17, 2007 8:43 pm

Post by l8night »

Thanks a lot!! I'll take your suggestions and attempt to write my self a script.

I'll let you know how things go. Thanks again

Jeff
l
l8night
Voice
Posts: 12
Joined: Mon Dec 17, 2007 8:43 pm

Post by l8night »

This is what I have so far:

Code: Select all






bind time - "05 05 * * *" proc:putquick

 proc proc:putquick {} { 

   putquick "howold l8night" 
}

bind pubm -  At the moment there are * accounts older then l8night proc:gettext

 proc proc:gettext {} {}


I want to put the value represented by the * in a variable, I was thinking first put the whole "At the moment there are * accounts older than l8night" in a list, I guess my question is how would I capture that text and put it into a list.

Any response will be greatly appreciated


Jeff
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

Code: Select all

proc proc:gettext { nick uhost handle channel text } {
  regexp {there are (.*?) accounts older} $text match others
}
This will set the variable $others with the number of people after you.

"putquick" is a command used to tell eggdrop how fast to send information to the server, you have to put in the command what to send t the server.

Code: Select all

putquick "PRIVMSG #channel :howold l8night"
Post Reply