This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

help news

Help for those learning Tcl or writing their own scripts.
Post Reply
p
pilouuu
Halfop
Posts: 82
Joined: Mon Dec 26, 2005 8:03 pm

help news

Post by pilouuu »

Hi

My code

Code: Select all

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
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

For use in more than one channel use the following (from tcl-commands.doc):

Code: Select all

  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
p
pilouuu
Halfop
Posts: 82
Joined: Mon Dec 26, 2005 8:03 pm

...

Post by pilouuu »

forum for help? or redirection? ...

thx
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

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
p
pilouuu
Halfop
Posts: 82
Joined: Mon Dec 26, 2005 8:03 pm

Post by pilouuu »

it good :) thx u for infos et redirection :)
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

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: Select all

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'**)"
}
Post Reply