how can control on that readfile code ?

Решение вопросов при работе с TCL скриптами.

Модератор: Модераторы

how can control on that readfile code ?

Сообщение heartbroken » 21 апр 2012 23:57

hi
i've seen a script that read and post messages line by line into a .txt file with timer on chan. or into nick's PM with !read nick|chan command..

i saw that someone asks help for this script on freenode : #eggdrop channel.and i'd try that on my bot.but this script has a problem ...it wont stop when it starts..so need to add a bind !stop & !stop nick|chan commands for this code.

i tried to make somethings like that on code but everytime i got error messages and wont stop posting...this is usefull code for me but it has bad problem for usage on channel or for nick..so i need yours advices and help for to fix this issue…

thanks.
У вас нет необходимых прав для просмотра вложений в этом сообщении.
Life iS Just a dReaM oN tHE wAy to DeaTh
Аватара пользователя
heartbroken
 
Сообщения: 18
Зарегистрирован: 07 апр 2012 09:25
Благодарил (а): 9 раз.
Поблагодарили: 0 раз.

Re: how can control on that readfile code ?

Сообщение tvrsh » 22 апр 2012 08:56

Try this, Ive add stopwow flag. If channel get +stopwow it stops reading. Command !wow remove that flag and command !stopwow enable it.
TCL: [ Скачать ] [ Скрыть ]
#############################################################
##                                                         ##
##           Words of Wisdom v2.01 TCL (WoW)               ##
##   Display funny nonsense to your irc friends/channel    ##
##                  by Phil (Admin)                        ##
##              Penthux.net - June 2005                    ##
##                                                         ##
## This script is not meant to do anything except make you ##
## smile. The text file can contain any plain text,        ##
## whether it be jokes, channel adverts or whatever. When  ##
## adding your own content just make sure you put each     ##
## item on a seperate line in the text file. There is no   ##
## limit to how large or small the text file must be.      ##
##                                                         ##
## Usage:                                                  ##
## [channel commands]                                      ##
## !wow               = displays a WoW line to channel     ##
## !wow [nick|chan]   = displays WoW line to nick or chan  ##
##                                                         ##
## ** NB - only ops, halfops and voices in the named       ##
## #channel can use the !wow [nick|chan] command which can ##
## be sent to any nickname or channel on the network which ##
## allows external messages. All other users get the WoW   ##
## line back in their own query window. Change the code if ##
## you like as this setup primarily stops lamer flooding   ##
## to nicks/chans.                                         ##
##                                                         ##
## Installation:                                           ##
## 1. Set the irc #channel to display the WoW lines        ##
## automatically and the timer intervals between output.   ##
## Edit your eggdrop filename.conf and add this line to    ##
## the end of the file:                                    ##
##                                                         ##
## source scripts/wow.tcl                                  ##
##                                                         ##
## 2. Copy the edited filename.conf file to your eggdrop   ##
## dir and copy both the wow.tcl & wow.txt files to the    ##
## SCRIPTS directory. Now reboot/restart your eggdrop bot. ##
##                                                         ##
## Please keep this header intact if you distribute or     ##
## modify this CGI script.               admin@penthux.net ##
#############################################################

## set the channel to display automatic WoW lines, include the '#' prefix
set wowchan "#channel"

## set the timer interval (in minutes) between WoW lines
set wowtime "30"

### From this line we will begin to post to chan.
set wownr 0

### Flag to stop reading
setudef flag stopwow

#######################################################
### don't change anything below if u don't know TCL ###
#######################################################

if { [info exists wowtime] } { timer $wowtime "timer:wow" }

set wowtxt "scripts/wow.txt"
set wowver "v2.01"

bind pub - !wow disp:wow

proc disp:wow {nick host handle chan text} {
  global wowchan wowtxt wownr

  ### We unset stopread flag.
  catch {channel set $wowchan -stopwow}

  if { [isop $nick $wowchan] || [ishalfop $nick $wowchan] || [isvoice $nick $wowchan] } {  
    if { [lindex $text 0] != "" } {
        set wowto [lindex $text 0]
    } else {
        set wowto $wowchan
    }
      set wowfile [open $wowtxt r]
      set wowread [split [read $wowfile] \n]
      close $wowfile

      ### We check if stopread flag exists.
      if {![channel get $wowchan stopwow]} {
          putserv "PRIVMSG $wowto :[lindex $wowread $wownr] "
          set wownr [expr $wownr + 1]
      }
  } else {
      set wowfile [open $wowtxt r]
      set wowread [split [read $wowfile] \n]
      close $wowfile

      ### We check if stopread flag exists.
      if {![channel get $wowchan stopwow]} {
          putserv "PRIVMSG $nick :[lindex $wowread $wownr] "
          set wownr [expr $wownr + 1]
      }
  }
}

### This proc enable stopread flag on channel.
bind pub - !stopwow stopwow
proc stopwow {nick host handle chan text} {
    global wowchan wowtxt wownr
    if { [isop $nick $wowchan] || [ishalfop $nick $wowchan] || [isvoice $nick $wowchan] } {  
        catch {channel set $wowchan +stopwow}
    }
    putserv "PRIVMSG $chan :Reading from $wowtxt to $wowchan stopped."
}

proc timer:wow {} {
  global botnick wowchan wowtime wowtxt wownr
  ### We check if stopread flag exists.
  if { [onchan $botnick $wowchan] && ![channel get $wowchan stopwow] } {
    set wowfile [open $wowtxt r]
    set wowread [split [read $wowfile] \n]
    close $wowfile
    putserv "PRIVMSG $wowchan :[lindex $wowread $wownr] "
    set wownr [expr $wownr + 1]
    timer $wowtime "timer:wow"
  }
}

putlog "Words of Wisdom $wowver TCL (timer: $wowtime mins) - Loaded! "

#
#
Have fun.
-
Получить помощь можно на каналах #egghelp в сети IrcNet.ru и #eggdrop в сети RusNet(Ключ канала eggdrop).
Перед созданием новой темы внимательно читайте Правила оформления топиков.
Аватара пользователя
tvrsh
 
Сообщения: 1230
Зарегистрирован: 19 авг 2008 16:55
Откуда: Russian Federation, Podolsk
Благодарил (а): 6 раз.
Поблагодарили: 130 раз.
Версия бота: Eggdrop 1.6.20+suzi

Re: how can control on that readfile code ?

Сообщение heartbroken » 22 апр 2012 15:41

yes.. now this working like a charm:) awesome work thank you so much tvrsh :)
Life iS Just a dReaM oN tHE wAy to DeaTh
Аватара пользователя
heartbroken
 
Сообщения: 18
Зарегистрирован: 07 апр 2012 09:25
Благодарил (а): 9 раз.
Поблагодарили: 0 раз.


Вернуться в TCL скрипты

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 8

cron