1. Hey Guest, are you looking for a place to host your IRC related project? Then check out the Resource Manager on IRCForums! Click the resources tab above this notice!
  2. Hello Guest, are you new to IRCForums? Why not introduce yourself in the introduction forum!
  3. We have updated the layout of our forums. Please see this thread for more information.

[TCL] Play a file to a channel at a given time

Discussion in 'Script Gallery (Depreciated)' started by Nascimento, May 4, 2012.

  1. Offline

    Nascimento Sports Chat

    Member Since:
    Dec 20, 2011
    Message Count:
    305
    Likes Received:
    53
    Trophy Points:
    86
    Thanks to caesar from www.egghelp.org.

    [09:53:42] <@Nascimento> !play 09:54 preview.txt #moderators
    [09:53:43] <@Favela> I will play preview.txt to #moderators at 09:54
    [09:54:01] * Favela sets mode: +m
    [09:54:03] <@Favela> Zklw
    [09:54:05] <@Favela> is
    [09:54:07] <@Favela> fat
    [09:54:09] <@Favela> lol @ zklw
    [09:54:11] <@Favela> monitors 24/7
    [09:54:13] <@Favela> lame
    [09:54:15] * Favela sets mode: -m

    Code (text):
    namespace eval cronPlay {
      set play(info) ""
      bind pub * !play [namespace current]::create
     
      proc create {nick uhost hand chan text} {
        variable play
        if {[scan $text {%[^:]:%s%s%s} hour minute file channel] != 4} {
          puthelp "NOTICE $nick :Usage: !play <hour:minute> <file> <#channel>"
          return
        }
        if {![regexp {^[0-9]+$} $hour] || ![regexp {^[0-9]+$} $minute]} {
          puthelp "NOTICE $nick :Error, the hour or minute aren't valid."
          return
        }
        if {![file exists $file]} {
          puthelp "NOTICE $nick :Error, $file file doesn't exist."
          return
        }
        if {![validchan $channel]} {
          puthelp "NOTICE $nick :Error, $channel channel is not valid."
          return
        }
        set play(info) "$file $channel"
        bind cron - "$minute $hour * * *" [namespace current]::play
        puthelp "PRIVMSG $chan :I will play $file to $channel at $hour:$minute"
      }
     
      proc play {minute hour day month weekday} {
        variable play
        if {[catch {unbind cron - "$minute $hour * * *" [namespace current]::play} err]} {
          putlog "Error in cronPlay: $err"
        }
        if {[scan $play(info) {%s%s} file channel] != 2} return
        if {![file exists $file]} return
        set fo [open $file]
        set lines [split [read -nonewline $fo] \n]
        close $fo
        if {![llength $lines]} return
        if {[botisop $channel]} {
          puthelp "MODE $channel +m"
          foreach line $lines {
            puthelp "PRIVMSG $channel :$line"
          }
          puthelp "MODE $channel -m"
        }
      }
    }
     
    putlog "cronPlay.tcl loaded.."
  2. Offline

    Trixar_za GigIRC

    Member Since:
    Dec 18, 2011
    Message Count:
    1,295
    Likes Received:
    182
    Trophy Points:
    178
    ... that's exactly what my python script does...
  3. Offline

    Nascimento Sports Chat

    Member Since:
    Dec 20, 2011
    Message Count:
    305
    Likes Received:
    53
    Trophy Points:
    86
    Yeah, but had to load a bot just for that function since all the bots I`m using are eggdrops
  4. Offline

    dancer69 Newbie

    Member Since:
    Aug 7, 2012
    Message Count:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Hello, somehow i got an error with this after i'm executing this command:

    Tcl error [::cronPlay::create]: bad type, should be one of: act, away, bcst, bot, chat, chjn, chof, chon, chpt, ctcp, ctcr, dcc, disc, evnt, fil, filt, flud, join, kick, link, load, lost, mode, msg, msgm, need, nick, nkch, notc, note, part, pub, pubm, raw, rcvd, rejn, sent, sign, splt, time, topc, tout, unld, wall

    Need help please

    Thank You

Share This Page