<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/20330" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2017-04-20T12:29:42-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/20330</id>

		<entry>
		<author><name><![CDATA[juanamores]]></name></author>
		<updated>2017-04-19T14:20:04-04:00</updated>

		<published>2017-04-19T14:20:04-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=106152#p106152</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=106152#p106152"/>
		<title type="html"><![CDATA[Greeting on join with countdown days]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=106152#p106152"><![CDATA[
Excellent solution and excellent explanation. <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_mrgreen.gif" width="15" height="15" alt=":mrgreen:" title="Mr. Green"> <br>You are a genious  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12499">juanamores</a> — Wed Apr 19, 2017 2:20 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2017-04-19T12:03:03-04:00</updated>

		<published>2017-04-19T12:03:03-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=106151#p106151</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=106151#p106151"/>
		<title type="html"><![CDATA[Greeting on join with countdown days]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=106151#p106151"><![CDATA[
Sure. If we put in the values for the variables inside<div class="codebox"><p>Code: </p><pre><code> clock scan "$month/1/$year + 1 month - 1 day"</code></pre></div>then the result will be:<div class="codebox"><p>Code: </p><pre><code>clock scan "04/1/2017 + 1 month - 1 day"</code></pre></div>I chose the <em class="text-italics">04/1/2017</em> format from the <a href="https://www.tcl.tk/man/tcl8.4/TclCmd/clock.htm#M45" class="postlink">acceptable formats</a> for clock scan to work that is in TCL version 8.4 upwards. Could have used <em class="text-italics">1 April 2017</em>, or just <em class="text-italics">1 April</em> without year and results would have been the same, but decided to stick with a standard accepted format so won't get in any problems.<br><br>Without the <em class="text-italics">+ 1 month - 1 day</em> part:<div class="codebox"><p>Code: </p><pre><code>clock scan "04/1/2017"</code></pre></div>basically we define the current day to be 1st April 2017 and the result will be 1490994000, meaning 1st April 2017 exactly as we wanted.<br><br>Now, in order to get the last day of current month we use the <em class="text-italics">+ 1 month - 1 day</em> part:<br>1) Add one month to 1st April 2017:<div class="codebox"><p>Code: </p><pre><code>%clock scan "04/1/2017 +1 month"1493586000</code></pre></div>meaning 1st May 2017<br>2) subtract one day from the above result<div class="codebox"><p>Code: </p><pre><code>% clock scan "04/1/2017 +1 month -1 day"1493499600</code></pre></div>meaning 30th April 2017.<br><br>Next with the help of the first command:<div class="codebox"><p>Code: </p><pre><code>clock format unixtime -format %d</code></pre></div>where unixtime now is 1493499600 meaning 30th April 2017, we get the day of the month from this unixtime time stamp, thus the result will be 30. <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Wed Apr 19, 2017 12:03 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[juanamores]]></name></author>
		<updated>2017-04-19T07:41:14-04:00</updated>

		<published>2017-04-19T07:41:14-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=106150#p106150</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=106150#p106150"/>
		<title type="html"><![CDATA[Greeting on join with countdown days]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=106150#p106150"><![CDATA[
Hi Caesar, I worked perfect your script from above. <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br>Could you explain to me, to learn, how does this line work?<div class="codebox"><p>Code: </p><pre><code># compute the number of days in the current monthset days [clock format [clock scan "$month/1/$year + 1 month - 1 day"] -format %d]</code></pre></div>Thank you very much! <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12499">juanamores</a> — Wed Apr 19, 2017 7:41 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2017-04-20T12:29:42-04:00</updated>

		<published>2017-04-19T01:43:30-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=106149#p106149</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=106149#p106149"/>
		<title type="html"><![CDATA[Greeting on join with countdown days]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=106149#p106149"><![CDATA[
You have way too many arguments for the join process, hence the error. Give this a try:<div class="codebox"><p>Code: </p><pre><code>set mychan "#chann1"bind join v|v * greet:awardsproc greet:awards {nick uhost hand chan} {global mychan# skip if it's bot that is joiningif {[isbotnick $nick]} return# skip if it's not the channel you defined aboveif {![string equal -nocase $chan $mychan]} return# set system timeset systemTime [clock seconds]# set current dayset today [clock format $systemTime -format %e]# set monthset month [clock format $systemTime -format %m]# set yearset year [clock format $systemTime -format "%Y"]# compute the number of days in the current monthset days [clock format [clock scan "$month/1/$year + 1 month - 1 day"] -format %d]# set the number of days remaining in the month starting with todayset rest [expr $days - $today]# output the resultputhelp "PRIVMSG $chan :$nick rest $rest days for de awards"}</code></pre></div>Since your system language is in Spanish and having the months names in English it would fail, so did a little workaround this and should work on all systems no matter the language it has set.<br><br>Edit: Here is a little tip. Instead of having:<div class="codebox"><p>Code: </p><pre><code>if {$month == "January"}  {set mo 31}if {$month == "February"} {set mo 29}if {$month == "March"} {set mo 31}if {$month == "April"} {set mo 30}if {$month == "May"} {set mo 31}if {$month == "June"} {set mo 30}if {$month == "July"} {set mo 31}if {$month == "August"} {set mo 31}if {$month == "September"} {set mo 30}if {$month == "October"} {set mo 31}if {$month == "November"} {set mo 30}if {$month == "December"} {set mo 31}</code></pre></div>that is a mistake because all if statements are checked you have 3 options:<br><br>Option #1 would be to use <strong class="text-strong">if ... elseif</strong><div class="codebox"><p>Code: </p><pre><code>if {$month == "January"} {set mo 31} elseif {$month == "February"} {set mo 29} elseif { ... }</code></pre></div>and so on. In this case the first if statement that is true will stop the remaining ones. Still not a very good choice because if $month is equal with December then it will still check all statements until reaches last.<br><br>Moving on to option #2: <strong class="text-strong">switch</strong><div class="codebox"><p>Code: </p><pre><code>switch -- $month {"January" {set mo 31}"February" {set mo 29}... and so on...default {set mo 0}}</code></pre></div>Switch is a better option than a bunch of <em class="text-italics">if</em> or <em class="text-italics">if ... elseif</em> since it will <em class="text-italics">jump</em> at the exactly <em class="text-italics">match</em>, or to default (if you added it) in case there's no match inside the switch.<br><br>But we can do better and here we got option #3 the <strong class="text-strong">string map</strong>.. the champion! <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><div class="codebox"><p>Code: </p><pre><code>set days [string map [list "January" 31 "February" 29 "March" 31 "April" 30 "May" 31 "June" 30 "July" 31 "August" 31 "September" 30 "October" 31 "November" 30 "December" 31] $month]</code></pre></div>and that's all in a single line. <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br>Depending on the $month name it will return the element behind it from the list. For example For "February" it will return 29, for "October" it will return 31 and so on.<br><br>Edit: Fixed typo.<br>Edit #2: There's no 'text' argument inside the bind join.. how did I miss that? <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_rolleyes.gif" width="15" height="15" alt=":roll:" title="Rolling Eyes"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Wed Apr 19, 2017 1:43 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[juanamores]]></name></author>
		<updated>2017-04-18T21:10:45-04:00</updated>

		<published>2017-04-18T21:10:45-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=106148#p106148</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=106148#p106148"/>
		<title type="html"><![CDATA[Greeting on join with countdown days]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=106148#p106148"><![CDATA[
I want to create a script that greets the nicks when join a channel and indicates how many days rest for the last day of the month.<br><br>The last day of the month will be known who was the winner.<br><br>I have problem with the variables nick and chan, since I can not put them in the process because it gives error.<br><div class="codebox"><p>Code: </p><pre><code>bind join v|v * greet:awardsset mychan "#chann1"proc greet:awards  {min hour day month weekday nick uhost hand chan text} {global chann1if {$chan == "$chann1"} {#set number of days of the monthif {$month == "January"}  {set mo 31} if {$month == "February"} {set mo 29} if {$month == "March"} {set mo 31} if {$month == "April"} {set mo 30} if {$month == "May"} {set mo 31} if {$month == "June"} {set mo 30} if {$month == "July"} {set mo 31} if {$month == "August"} {set mo 31} if {$month == "September"} {set mo 30} if {$month == "October"} {set mo 31} if {$month == "November"} {set mo 30} if {$month == "December"} {set mo 31} #rest the number of days of the month with todayset rest [expr $mo - $day]putquick "PRIVMSG $chan :$nick rest  $rest days for de awards"return } else { return }}  </code></pre></div>   <br><br>How can it be fixed?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12499">juanamores</a> — Tue Apr 18, 2017 9:10 pm</p><hr />
]]></content>
	</entry>
	</feed>
