View previous topic :: View next topic |
Author |
Message |
slennox Owner

Joined: 22 Sep 2001 Posts: 593
|
Posted: Tue May 03, 2005 12:46 pm Post subject: "Tip of the day" |
|
|
This topic is for the posting of scripting tips, i.e. short pieces of advice rather than major concepts. It was requested by NoZparker who would like to pass on things he comes across while learning Tcl, but anyone can share their tips here. |
|
Back to top |
|
 |
^DooM^ Owner

Joined: 26 Aug 2003 Posts: 772 Location: IronForge
|
Posted: Tue May 03, 2005 6:11 pm Post subject: split |
|
|
When using always make sure you use split to properly deal with your list. Code: | [lindex [split $arg] 0] |
_________________ The lifecycle of a noob is complex. Fledgling noobs gestate inside biometric pods. Once a budding noob has matured thru gestation they climb out of their pod, sit down at a PC, ask a bunch of questions that are clearly in the FAQ, The Noob is born |
|
Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Tue May 03, 2005 7:07 pm Post subject: |
|
|
Same goes with Code: | [lrange $arg 0 end] |
use this instead
Code: | [join [lrange [split $arg] 0 end]] |
Split is used to turn the string $arg into a list since lrange is applied to lists, and join converts it back to a string. (check out http://www.peterre.info/characters.html)
Edit: Updated URL to the new one. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts
Last edited by Sir_Fz on Fri Jan 05, 2007 7:50 pm; edited 1 time in total |
|
Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Thu May 05, 2005 7:00 pm Post subject: |
|
|
To get the host from $uhost (ident@host) you can use the following:
Code: | set host [lindex [split $uhost @] 1] |
Now you can use *!*@$host as a banmask.
Or you can use:
Code: | scan $uhost %*\[^@\]@%s host |
Which will also assign the host to $host.
To get both ident and host, you can use:
Code: | scan ident@host %\[^@\]@%s ident host |
Now you have the ident in $ident and the host in $host. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
Back to top |
|
 |
NoZparker Voice
Joined: 16 Feb 2004 Posts: 34
|
Posted: Fri May 06, 2005 11:31 am Post subject: naming eggdrop.conf |
|
|
Whilst saving an eggdrop.conf use all lower case. This will not effect the nickname of the bot but does save time looking in the dir to remember how you have saved the conf when it's crashed, and you have to restart. |
|
Back to top |
|
 |
NoZparker Voice
Joined: 16 Feb 2004 Posts: 34
|
Posted: Fri May 06, 2005 11:33 am Post subject: looking for bugs |
|
|
When you are looking for a bug in your new tcl that you are writing and is not necessarily an error use.... Putlog "got this far" .....in the tcl. and then move it so you can see what is happening. |
|
Back to top |
|
 |
NoZparker Voice
Joined: 16 Feb 2004 Posts: 34
|
Posted: Fri May 06, 2005 11:34 am Post subject: looking for server replies |
|
|
If you need to see the result of perhaps a server notice or what the bot sees in channel while you are writing your tcl then set ... .console [channel] +r. ....but don't forget to turn it off. |
|
Back to top |
|
 |
NoZparker Voice
Joined: 16 Feb 2004 Posts: 34
|
Posted: Fri May 06, 2005 11:37 am Post subject: What on earth is this variable |
|
|
Whilst writing a tcl use long discription variables. That makes it easier to follow. Then when you are finished replace with shortened variables. (keep it small) |
|
Back to top |
|
 |
NoZparker Voice
Joined: 16 Feb 2004 Posts: 34
|
Posted: Fri May 06, 2005 11:38 am Post subject: now how can i shorten this tcl |
|
|
when you have finished writing a tcl, or think you have finished. look for if's inside of if's. eg
if {1st set of rules} {
if {2nd set of rules} {
do your stuff
}
}
can be written
if {(1st set of rules) && (2nd set of rules)} {
do your stuff
}
--------------- save space |
|
Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Fri May 06, 2005 11:43 am Post subject: |
|
|
Use proper formatting while writing a code so you won't get lost in it.
for example:
Code: | if {[botisop $chan]} {
if {$nick == "bla"} {
pushmode $chan +v $nick
}
} |
is more clear and easier to follow than:
Code: | if {[botisop $chan]} {
if {$nick == "bla"} {
pushmode $chan +v $nick
}
} |
This way you'll find it easier to trace the open and closed braces. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
Back to top |
|
 |
greenbear Owner
Joined: 24 Sep 2001 Posts: 733 Location: Norway
|
Posted: Fri May 06, 2005 7:09 pm Post subject: |
|
|
get rid of the redundant braces, and it'll be even easier to read
Code: | if [botisop $chan] {
if {$nick == "bla"} {
pushmode $chan +v $nick
}
} |
|
|
Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Fri May 06, 2005 7:57 pm Post subject: |
|
|
Or even better you can combine those 2 if statements in one:
Code: | if {[botisop $chan] && $nick == "bla"} {
pushmode $chan +v $nick
} |
or as gb may prefer:
Code: | if [botisop $chan]&&[string equal "bla" $nick] {
pushmode $chan +v $nick
} |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sun May 08, 2005 8:32 pm Post subject: |
|
|
If you want to join a list with a special character, like for example "nick1 nick2 nick3 nick4" to "nick1,nick2,nick3,nick4" you can use this:
Code: | set mylist [list nick1 nick2 nick3 nick4]
set mylist [join $mylist ,]
# Now, $mylist will return: nick1,nick3,nick3,nick4. |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sat May 14, 2005 7:16 pm Post subject: |
|
|
You can use different commands to send data into server.
The fastest way is by using:
Code: | putdccraw 0 [string length "YOUR DATA\n"] "YOUR DATA\n"
# for example:
# putdccraw 0 [string length "MODE $chan +b $ban\n"] "MODE $chan +b $ban\n" |
But be carefull using this since it might flood out your bot.
Then we have eggdrop's queues (fastest to slowest order)
Quote: | putquick <text> [options]
Description: sends text to the server, like 'putserv', but it uses a
different (and faster) queue.
Options:
-next: push messages to the front of the queue
-normal: no effect
Returns: nothing
Module: server |
Quote: | putserv <text> [options]
Description: sends text to the server, like '.dump' (intended for direct
server commands); output is queued so that the bot won't flood itself
off the server.
Options:
-next: push messages to the front of the queue
-normal: no effect
Returns: nothing
Module: server |
Quote: | puthelp <text> [options]
Description: sends text to the server, like 'putserv', but it uses a
different queue intended for sending messages to channels or people.
Options:
-next: push messages to the front of the queue
-normal: no effect
Returns: nothing
Module: server |
I figured alot don't take a look at Tcl-commands.doc, so reading the quotes might be better for them
PS: RTFM (^DooM^'s popular acronym ) _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
Back to top |
|
 |
NoZparker Voice
Joined: 16 Feb 2004 Posts: 34
|
Posted: Sun May 15, 2005 9:48 am Post subject: reading help files |
|
|
when you looking for answers sometimes it is worth looking in the help file in your mirc script (looking for correct syntax maybe) as well as in the tcl-commands.doc (found in the eggdrop\doc folder
Oh and don't forget to do a search here in the forum _________________ It's times like this I wished I had listened to What my dad used to say. Can't say what it was I never listened. |
|
Back to top |
|
 |
|