egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

help news

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
pilouuu
Halfop


Joined: 26 Dec 2005
Posts: 82

PostPosted: Mon Mar 20, 2006 5:45 pm    Post subject: help news Reply with quote

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
View user's profile Send private message
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Mon Mar 20, 2006 10:48 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
pilouuu
Halfop


Joined: 26 Dec 2005
Posts: 82

PostPosted: Tue Mar 21, 2006 9:00 am    Post subject: ... Reply with quote

forum for help? or redirection? ...

thx
Back to top
View user's profile Send private message
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Tue Mar 21, 2006 9:10 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
pilouuu
Halfop


Joined: 26 Dec 2005
Posts: 82

PostPosted: Tue Mar 21, 2006 11:34 am    Post subject: Reply with quote

it good Smile thx u for infos et redirection Smile
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Tue Mar 21, 2006 1:14 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber