| View previous topic :: View next topic |
| Author |
Message |
pilouuu Halfop
Joined: 26 Dec 2005 Posts: 82
|
Posted: Mon Mar 20, 2006 5:45 pm Post subject: help news |
|
|
Hi
My code
| Code: |
bind pub - .news do_news
bind pub m|m .setnews do_makenews
proc do_news {nick userhost handle channel args} {
set newsfile [open "news" r]
set news [gets $newsfile]
putserv "privmsg $channel :News: $news"
putlog "(**Command: news by '$nick' on '$channel'**)"
}
proc do_makenews {nick userhost handle channel test} {
set newsfile [open "news" w]
puts $newsfile $test
putserv "NOTICE $channel :Done.: $test"
close $newsfile
putlog "(**Command: setnews by '$nick' on '$channel'**)"
} |
types: .setnews bla bla
<nick>.news
<bot> News: bla bla
code it good for 1 chan. Possible to add multi-chan? ( all chan bot is oN )
expl:
#chan1
.setnews bla bla
<nick chan1>.news
<bot> News: bla bla
#chan2
.setnews iop iop
<nick chan2>.news
<bot> News: iop iop
Thx for all help |
|
| Back to top |
|
 |
Alchera Revered One

Joined: 11 Aug 2003 Posts: 3344 Location: Ballarat Victoria, Australia
|
Posted: Mon Mar 20, 2006 10:48 pm Post subject: |
|
|
For use in more than one channel use the following (from tcl-commands.doc):
| Code: | setudef <flag/int/str> <name>
Description: initializes a user defined channel flag, string or integer
setting. You can use it like any other flag/setting. IMPORTANT: Don't
forget to reinitialize your flags/settings after a restart, or it'll be
lost.
Returns: nothing
Module: channels |
_________________ Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM |
|
| Back to top |
|
 |
pilouuu Halfop
Joined: 26 Dec 2005 Posts: 82
|
Posted: Tue Mar 21, 2006 9:00 am Post subject: ... |
|
|
forum for help? or redirection? ...
thx |
|
| Back to top |
|
 |
Alchera Revered One

Joined: 11 Aug 2003 Posts: 3344 Location: Ballarat Victoria, Australia
|
Posted: Tue Mar 21, 2006 9:10 am Post subject: |
|
|
This is the Scripting Help forum; you have been helped. You have implied you wrote that Tcl code; that being the case then you should understand my post and code accordingly. _________________ Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM |
|
| Back to top |
|
 |
pilouuu Halfop
Joined: 26 Dec 2005 Posts: 82
|
Posted: Tue Mar 21, 2006 11:34 am Post subject: |
|
|
it good thx u for infos et redirection  |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Tue Mar 21, 2006 1:14 pm Post subject: |
|
|
Alchera I think he means he wants to add different news for each channel not let the script work on all channels (as I see in the code, it already does).
pilouuu you can do something like this:
| Code: | set mynews [split [read [set newsf [open news]]][close $newf] \n][unset newsf]
bind pub - .news do_news
bind pub m|m .setnews do_makenews
proc do_news {nick userhost handle channel args} {
set gotnews 0
foreach news $::mynews {
if {[string equal -nocase $channel [lindex [split $news] 0]]} {
putserv "privmsg $channel :News: [join [lrange [split $news] 1 end]]"
putlog "(**Command: news by '$nick' on '$channel'**)"
set gotnews 1 ; break
}
}
if {!$gotnews} {
putserv "privmsg $channel :No news for this channel."
}
}
proc do_makenews {nick userhost handle channel test} {
global mynews
set test [string tolower $test]
set chan [string tolower $channel]
if {[set ci [lsearch -glob $mynews "$channel *"]] != -1} {
set mynews [lreplace $mynews $ci $ci]
}
lappend mynews "$chan $test"
set newsf [open news w]
foreach news $mynews {
if {$news != ""} {
puts $newsf $news
}
}
close $newsf
putserv "NOTICE $channel :Done.: $test"
putlog "(**Command: setnews by '$nick' on '$channel'**)"
} |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
|