User:Jack3

From EggWiki
Jump to navigation Jump to search

← Super simple, first time ever, script

August 30, 2022
A very simple script.  This is good for a 'first script'.  Keep it simple - easier to get the hang of installing and using scripts. 

However, this script isn't a do-nothing script!   :)     It is actually useful.    I install it on every bot I create, first thing.
This script creates a partyline command :    .date 
It simply returns the current date and time, same as if you executed the      date      command on the linux command line in a shell.

Usage:
On the partyline, simply type:         .date
Bot will return the date and time.
I find it very handy at times, when working in the partyline.    Especially when editing/debugging a script that 
contains    bind cron    .   I'll want to know when to expect it to trigger, and can quickly get that info.   

Feel free to install and use this script.    If you do, I suggest you install it as-is, first.  No edits.   
Reason:  Get it installed and working correctly, first.   THEN you can hack it up and do what you want with it.   :)   
Suggestion:  Add to it.  Make yet another command, so that it responds to a public command in a channel,  and/or to a /msg to the bot.
It's good practice!   :)


References:

https://docs.eggheads.org/using/tcl-commands.html

    text search tcl-commands.doc and find: 
            bind dcc
            putdcc
            ctime
            unixtime

Other helpful info:

   http://suninet.the-demon.de/
   http://suninet.the-demon.de/041.htm
   http://suninet.the-demon.de/042.htm
   http://suninet.the-demon.de/043.htm
   http://suninet.the-demon.de/044.htm
   https://wiki.eggheads.org/index.php/Loading_Tcl_Scripts


Start small - like this.  :)   Add to it.  That's a great way to learn!    But mostly - Have fun !     :)
I hope this helps.



Script starts here


bind dcc - "date" partyline_date_time

###
proc partyline_date_time {handle idx text} {

        putdcc $idx "[ctime [unixtime] ]"

 }
###

End script