<?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/14238" />

	<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>2007-11-19T00:37:32-04:00</updated>

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

		<entry>
		<author><name><![CDATA[Alchera]]></name></author>
		<updated>2007-11-19T00:37:32-04:00</updated>

		<published>2007-11-19T00:37:32-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=78533#p78533</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=78533#p78533"/>
		<title type="html"><![CDATA[Tcl News (rud-news.tcl)]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=78533#p78533"><![CDATA[
rud TCLs <a href="http://www.distorted.se/tcl/contact.php" class="postlink">contact</a><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3646">Alchera</a> — Mon Nov 19, 2007 12:37 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Robertus]]></name></author>
		<updated>2007-11-05T11:09:46-04:00</updated>

		<published>2007-11-05T11:09:46-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=77468#p77468</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=77468#p77468"/>
		<title type="html"><![CDATA[Tcl News (rud-news.tcl)]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=77468#p77468"><![CDATA[
Hi guys, i have a little problem with this .tcl<br>i want the header when i write !news, for example:<br><br>&lt;I&gt; !news<br>&lt;BOT&gt; MY NEWS<br>&lt;BOT&gt; News1<br>&lt;BOT&gt; News2<br>&lt;BOT&gt; News3<br>etc...<br><br>And when i edit some NOTICE to PRIVMSG $chan, don't work, for example i edit  putserv "NOTICE $nick : News Deleted!" in  putserv "PRIVMSG $chan : News Deleted!", and i have this error (in dcc chat): Tcl error [::bc::onEncryptedText]: can't read "chan": no such variable.<br>(I use the blowcrypt in my eggdrop)<br>I want that when i addnews o delnews or other notice in the code, the bot write this in channel with privmsg $chan, and not in notice.<br><br>When i write !news in #mychannel2, the bot write the news #mychannel1,but it don't the show news in other channel...<br><br>And the last problem is, that when i write !news and there aren't news, the bot don't write in the channel.<br>I want thaht write: No News At The Moment.<br><br>this is the code:<br><br>Thank u so much for the support<div class="codebox"><p>Code: </p><pre><code>###################  rud-news.tcl  ###############################  Info  ############# webpage: http://www.distorted.se/tcl/## !news script for displaying news in your irc channel(s), !addnews for easy adding# security for adding either by host or by channel, and by user flags in the bind also# the delay for displaying the news is configureable, and most output is configureable# enjoy###############  Licence  ################ Feel free to do whatever with this script as long as I'm credited as original author#################  Changelog  ################## 2006-12-03 - 1.2#  Added !delnews triggers, takes an integer for argument, 1 deleted the newest news, 2 the second newest, 3 the one after that and so on#  Made some code changes to reuse some code, better for future updates :)## 2006-11-30 - 1.1a#   Added text to show if nothing is found while searching (threw an error in 1.1)#   Added support for turning off the timed news announce## 2006-11-28 - 1.1#   Added search function, ie. !news affils , to get all news with "affils" in the somewhere#   Added help text on !news help## 2006-11-07 - 1.0.1#   Added !addnews as a msg command## 2006-11-06 - 1.0#   Initial release, security settings not throughtly tested.#######################  Config Settings  ######################## file to store the news in ?set news(file) "data.news"## space seperated list of channels to announce news inset news(channels) "#mychannel1"## set number of news to show when triggered by timer (consider anti-flood protection)set news(showtimer) 10## max number of news to show when triggered by !news (consider anti-flood protection)set news(shownotice) 10## how many news do we display by default in reply to !newsset news(noticedefault) 10## how many news to show if the user is searching for something (usually just a few matches needed)set news(searchdefault) 10## from what channel are news allowed to be added and deleted (!addnews, !delnews)set news(addchan) "#mychannel1"## from what hosts are news allowed to be added ande deleted no matter channelset news(addhosts) "*@*"## what delay between the news in minutes (I like to have this at something odd so it moves every day), 0 disables timed announceset news(timer) 0## what delay in minutes from loading this script till it prints the news first time, 0 disables timed announceset news(firstrun) 0## headerstyleset news(header) "MY NEWS"## dateformat (default is: 06 Nov 03:20) http://www.tcl.tk/man/tcl8.4/TclCmd/clock.htm#M6 for helpset news(dateformat) "%d·%b·%y - %H:%M:%S"## linestyle, %time %user and %news are valid cookiesset news(line) "14(%time14): %news » 14(4%user14)"## add news style, %user and %news are valid cookiesset news(addstyle) "News added by %user!"## text to display if nothing is found while searching, %search for the search stringset news(nothingfound) "Nothing was found when searching for %search"## help textset news(help) {!news usage:!news [number] [search]!news  - get a list of latest news!news &lt;number&gt;  - get a list of &lt;number&gt; latest news!news &lt;search&gt;  - get a list of latest news matching &lt;search&gt;, wildcards * and ?!news &lt;number&gt; &lt;search&gt;  - get a list of &lt;number&gt; latest news matching &lt;search&gt;, wildcards * and ?}###############  Bindings  ################ the o means that only users the bot recognize as op will be allowed to use the command# set this to - to allow all users no matter the status in the bot to run the commandbind pub - !news rud:pub:newsbind pub o !addnews rud:pub:addnewsbind msg o !addnews rud:msg:addnewsbind pub o !delnews rud:pub:delnewsbind msg o !delnews rud:msg:delnews################################  No edit below here needed  ################################set news(version) 1.2proc rud:pub:news { nick uhost handle chan arg } {        global news        set fp [open $news(file) r]        set data [split [read $fp] "\n"]        close $fp  if { $arg eq "help" } {        foreach line [split $news(help) \n] {                        if { [string trim $line] != "" } {                      putserv "NOTICE $nick :$line"                        }        }        return  }        if { [string trim $arg] == "" } {                 set numreplies $news(noticedefault)  } elseif { [string is integer [set numreplies [lindex [split $arg] 0]]] } {        if { $numreplies &gt; $news(shownotice) } {                 set numreplies $news(shownotice)         }                if { $numreplies &gt; [llength $data] } {                         set numreplies [llength $data]                 }                 if { [llength [split $arg]] &gt; 1 } {                         set searchstring [lrange [split $arg] 1 end]                }        } elseif { [string is integer [set numreplies [lindex [split $arg] end]]] } {        if { $numreplies &gt; $news(shownotice) } {                 set numreplies $news(shownotice)         }                if { $numreplies &gt; [llength $data] } {                         set numreplies [llength $data]                 }                 if { [llength [split $arg]] &gt; 1 } {                         set searchstring [lrange [split $arg] 0 end-1]                }        } else {                set numreplies $news(searchdefault)                set searchstring $arg        }  if { [info exists searchstring] } {        foreach line $data {                if { [string match -nocase "*$searchstring*" [lrange [split $line] 2 end]] } {                        lappend newdata $line                }        }                if { ![info exists newdata] } { putserv "PRIVMSG $chan :[string map [list "%search" $searchstring] $news(nothingfound)]" ; return }                if { $numreplies &gt; [llength $newdata] } { set numreplies [llength $newdata] }                for { set i [expr [llength $newdata] -1] } { $i &gt;= [expr [llength $newdata] - $numreplies] } { incr i -1 } {                        set line [lindex $newdata $i]                        if { $line != "" } { putserv "PRIVMSG $chan :[string map [list "%time" [clock format [lindex $line 0] -format $news(dateformat)] "%user" [lindex $line 1] "%news" [join [lrange $line 2 end]]] $news(line)]" }        }          } else {                for { set i [expr [llength $data] - 2] } { $i &gt;= [expr [llength $data] - $numreplies - 1] } { incr i -1 } {                        set line [lindex $data $i]                        if { $line != "" } { putserv "PRIVMSG $chan :[string map [list "%time" [clock format [lindex $line 0] -format $news(dateformat)] "%user" [lindex $line 1] "%news" [join [lrange $line 2 end]]] $news(line)]" }                }        } }proc rud:msg:addnews { nick uhost handle arg } {        global news        foreach addhost [split $news(addhosts)] {                if { [string match -nocase $addhost $uhost] } {                        set adder 1;                }        }        if { ![catch {onchan $nick $news(addchan)}] } {                if { [onchan $nick $news(addchan)] } {                        set adder 1;                }        }        if { [llength $arg] == 0 } {                putserv "NOTICE $nick :Usage: !addnews &lt;news&gt;"                return 0        }        if { [info exists adder] } {                set fp [open $news(file) a]                puts $fp "[clock seconds] $nick $arg"                close $fp                   foreach newschan [split $news(channels)] {                        putserv "NOTICE $nick :[string map [list "%user" $nick "%news" $arg] $news(addstyle)]"                }        }}proc rud:pub:addnews { nick uhost handle chan arg } {        rud:msg:addnews $nick $uhost $handle $arg}proc rud:msg:delnews { nick uhost handle arg  } {        global news        foreach addhost [split $news(addhosts)] {                if { [string match -nocase $addhost $uhost] } {                        set adder 1;                }        }        if { ![catch { onchan $nick $news(addchan) }] } {                if { [onchan $nick $news(addchan)] } {                        set adder 1;                }        }        if { [llength $arg] != 1 || ![string is integer $arg] } {                putserv "NOTICE $nick : Usage: !delnews &lt;number&gt;, 1 is the lastest news added, 2 seconds latest etc."                return 0        }        if { [info exists adder] } {                set fp [open $news(file) r]                set data [split [read $fp] \n]                close $fp                                set fp [open $news(file).new w]                set line [expr [llength $data] - $arg - 1]                for { set i 0 } { $i &lt; [expr [llength $data]-1] } { incr i } {                        if { $i == $line } {                                set line [lrange [lindex $data $i] 2 end]                        } else {                                puts $fp [lindex $data $i]                        }                }                close $fp                                file rename -force $news(file).new $news(file)             putserv "NOTICE $nick : News Deleted!"        }}proc rud:pub:delnews { nick uhost handle chan arg } {        rud:msg:delnews $nick $uhost $handle $arg}proc rud:timer:news { arg } {        global news                 set fp [open $news(file) r]        set data [split [read $fp] "\n"]        close $fp        foreach chan [split $news(channels)] {                putserv "PRIVMSG $chan :$news(header)"        }        for { set i [expr [llength $data] - 2] } { $i &gt;= [expr [llength $data] - $arg - 1] } { incr i -1 } {                if { [lindex $data $i] != "" } {                        set line [lindex $data $i]                        set output [string map [list "%time" [clock format [lindex $line 0] -format $news(dateformat)] "%user" [lindex $line 1] "%news" [lrange $line 2 end]] $news(line)]                        foreach chan [split $news(channels)] {                                 putserv "PRIVMSG $chan :$output"                         }                }        }        timer $news(timer) { rud:timer:news $news(showtimer) }}if { ![string match *rud:timer:news* [utimers]] &amp;&amp; ![string match *rud:timer:news* [timers]] &amp;&amp; $news(firstrun) &gt; 0 &amp;&amp; $news(timer) &gt; 0 } {        timer $news(firstrun) { rud:timer:news $news(showtimer) }}if { ![file isfile $news(file)] } {        set fp [open $news(file) w]        close $fp}putlog "rud-news.tcl $news(version) by rudenstam loaded..."</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9250">Robertus</a> — Mon Nov 05, 2007 11:09 am</p><hr />
]]></content>
	</entry>
	</feed>
