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.

change mrc to tcl (please help)

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
O
ORATEGOD
Voice
Posts: 39
Joined: Mon Jun 08, 2020 5:50 pm

change mrc to tcl (please help)

Post by ORATEGOD »

I already appreciate the help for this * .mrc (change it to * .tcl)

Code: Select all

; ---------------------------------------------
; AGREGA NUEVOS PACKS A UN TXT (lastpacks.txt).
; ADD NEW PACKS TO A TXT (lastpacks.txt).
; ---------------------------------------------

on *:TEXT:!add packs*:#Channel1:{
  if ($nick isop $chan) {
    if (!$3) { .notice $nick 04[02 LastBot 04][02 syntax error04:02 !add packs 04(02Release Title04) 04] | halt }
    while ($lines(lastpacks.txt) >= 50) { write -dl1 lastpacks.txt }
    write lastpacks.txt $3- 12(02 $+ $date $+ 12) 
    msg #Channel1 04[02 Latest Packs Added04:02 $3- 04(02 $+ $date $+ 04) 04]
  }
}


; ------------------------------------------------
; MUESTRA LOS ULTIMOS 50 PACKS SUBIDOS A LOS BOTS.
; SHOW THE LAST 50 PACKS UPLOADED TO THE BOTS.
; Triggers: !last - !latest - !l
; ------------------------------------------------

on *:TEXT:!last:#Channel2:{
  var %i 50
  var %c 1
  .notice $nick 04[02 LastBot 04][02 Latest Releases04. 04]
  while (%i > 0) {
    .notice $nick 04[02 Release $chr(35) $+ %c $+ 04:02 $gettok($read(lastpacks.txt,%i),1,32) 04][02 Added04:02 $gettok($read(lastpacks.txt,%i),2-,32) $+ 04. 04]
    dec %i
    inc %c
  }
}
}
}


Note ... this mrc I could test it and it works in a good way ... it is only for moderators (@) of a channel.
User avatar
CrazyCat
Revered One
Posts: 1217
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

You can probably begin to learn tcl, especially when you have basics mrc remotes.

on *:TEXT is a bind pub (or pubm if text begins with *)

Code: Select all

set packlist "lastpacks.txt"
set maxentry 50
set packchan "#channel1"
set modchan "#channel2"

bind pub - !add newpack
proc newpack {nick uhost handle chan text} {
   if {![string match -nocase $::packchan $chan]} { return }
   set args [split $text]
   if {![string match -nocase "packs" [lindex $args 0]]} { return }
   if {[llength $args]<2} {
     putserv "NOTICE $nick :Syntax error: !add packs \00302release title\003"
      return
   }
   set now [strftime "%d/%m/%Y (%Hh%M)"]
   set fi [open $::packlist "a"]
   puts $fi "[join [lrange $args 1 end] $now"
   close $fi
}

bind pub - !last lastpack
bind pub - !lastest lastpack
bind pub - !l lastpack
proc lastpack {nick uhost handle chan text} {
   if {![string match -nocase $::modchan $chan]} { return }
   set fo [open $::packlist "w"]
   set packs [lrange [split [read -nonewline $fo] "\n"] end-50 end]
   close $fo
   foreach pack $packs {
      putserv "PRIVMSG $nick :$pack"
   }
}
Not tested, but may work
w
willyw
Revered One
Posts: 1196
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
O
ORATEGOD
Voice
Posts: 39
Joined: Mon Jun 08, 2020 5:50 pm

Post by ORATEGOD »

Greetings ... It does not add the lines to txt, and it does not show the results of the triggers.

NOTE: Thanks for the help you always give me in the forums.


[11:28] <~ORATEGOD> !add packs Six.Days.ebooks.pdf
[11:28] <~ORATEGOD> !l
[11:29] <~ORATEGOD> !last
[11:29] <~ORATEGOD> !lastest
O
ORATEGOD
Voice
Posts: 39
Joined: Mon Jun 08, 2020 5:50 pm

Post by ORATEGOD »

Cheers... Thanks for those references ... I'll study them.
User avatar
CrazyCat
Revered One
Posts: 1217
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

ORATEGOD wrote:Greetings ... It does not add the lines to txt, and it does not show the results of the triggers.

NOTE: Thanks for the help you always give me in the forums.


[11:28] <~ORATEGOD> !add packs Six.Days.ebooks.pdf
[11:28] <~ORATEGOD> !l
[11:29] <~ORATEGOD> !last
[11:29] <~ORATEGOD> !lastest
Did you well set packchan and modchan ?
And I made 2 small errors:
@line 17, a ] is missing:

Code: Select all

puts $fi "[join [lrange $args 1 end]] $now"
@line 26, bad opening of the file:

Code: Select all

set fo [open $::packlist "r"]
If you used party-line and console mode +d, you'll get the error.
O
ORATEGOD
Voice
Posts: 39
Joined: Mon Jun 08, 2020 5:50 pm

Post by ORATEGOD »

I work with these lines...

Code: Select all

# ==============================================================================================================================================================================
# Add !latest
 
set packlist "lastpacks.db"
set maxentry 50
# Donde se anuncian los packs
set packchan "#Chan01"
# Donde se muestra los 50 últimos packs
set modchan "#Chan02"
 
bind pub - !add newpack
proc newpack {nick uhost handle chan text} {
   if {![string match -nocase $::packchan $chan]} { return }
   set args [split $text]
   if {![string match -nocase "packs" [lindex $args 0]]} { return }
   if {[llength $args]<2} {
     putserv "NOTICE $nick :Syntax error: !add packs \00302release title\003"
      return
   }
   set now [strftime "%d/%m/%Y (%Hh%M)"]
   set fi [open $::packlist "a"]
   puts $fi "[join [lrange $args 1 end] $now]"
   close $fi
}

bind pub - !latest lastpack
bind pub - !l lastpack
proc lastpack {nick uhost handle chan text} {
   if {![string match -nocase $::modchan $chan]} { return }
   set fo [open $::packlist "r"]
   set packs [lrange [split [read -nonewline $fo] "\n"] end-50 end]
   close $fo
   putserv "NOTICE $nick : "
   putserv "NOTICE $nick :\00309,01 ========================================\[ !Latest - 50 Packs \]======================================== \003"
   foreach pack $packs {
      putserv "NOTICE $nick :\00309,01 $pack \003"
   }
   putserv "NOTICE $nick :\00309,01 ======================================================================================================= \003"
   putserv "NOTICE $nick :  "
}

I complement it with this *.mrc // which I don't know how to write in TCL

Code: Select all

;# ----------[ AutoAddLatest ]----------
on *:TEXT:*:#Chan01:{
  tokenize 32 $strip($1-)
  if ( [LWT]- isin $nick || [TF]- isin $nick || ORATEGOD isin $nick ) {
    if ( $1 == New && Release isin $2 ) {
      scon -a if ($network == NETWORK.IRC) msg #Chan01 !add packs $3
    }
  }
}
User avatar
CrazyCat
Revered One
Posts: 1217
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

ORATEGOD wrote:I complement it with this *.mrc // which I don't know how to write in TCL

Code: Select all

;# ----------[ AutoAddLatest ]----------
on *:TEXT:*:#Chan01:{
  tokenize 32 $strip($1-)
  if ( [LWT]- isin $nick || [TF]- isin $nick || ORATEGOD isin $nick ) {
    if ( $1 == New && Release isin $2 ) {
      scon -a if ($network == NETWORK.IRC) msg #Chan01 !add packs $3
    }
  }
}
This part of script will simply convert a line beginning by "New Release" on #chan01 on network.irc to a "!add packs" on #chan01, if user is [LWT], [TF] or ORATEGOD.
So it could be a short procedure:

Code: Select all

set autonick {\[LWT\] \[TF\] ORATEGOD}
bind pub - "new" addauto
proc addauto {nick uhost handle chan text} {
  if {![string match -nocase $::packchan $chan]} { return }
  set args [split $text]
  if {![string match -nocase "release" [lindex $args 0]]} { return }
  if {[lsearch -nocase $::autonick $nick]==-1} { return }
  newpack $nick $uhost $handle $chan "newpack [join [lrange $args 1 end]]"
}
O
ORATEGOD
Voice
Posts: 39
Joined: Mon Jun 08, 2020 5:50 pm

Post by ORATEGOD »

CrazyCat wrote:
ORATEGOD wrote:I complement it with this *.mrc // which I don't know how to write in TCL

Code: Select all

;# ----------[ AutoAddLatest ]----------
on *:TEXT:*:#Chan01:{
  tokenize 32 $strip($1-)
  if ( [LWT]- isin $nick || [TF]- isin $nick || ORATEGOD isin $nick ) {
    if ( $1 == New && Release isin $2 ) {
      scon -a if ($network == NETWORK.IRC) msg #Chan01 !add packs $3
    }
  }
}
This part of script will simply convert a line beginning by "New Release" on #chan01 on network.irc to a "!add packs" on #chan01, if user is [LWT], [TF] or ORATEGOD.
So it could be a short procedure:

Code: Select all

set autonick {\[LWT\] \[TF\] ORATEGOD}
bind pub - "new" addauto
proc addauto {nick uhost handle chan text} {
  if {![string match -nocase $::packchan $chan]} { return }
  set args [split $text]
  if {![string match -nocase "release" [lindex $args 0]]} { return }
  if {[lsearch -nocase $::autonick $nick]==-1} { return }
  newpack $nick $uhost $handle $chan "newpack [join [lrange $args 1 end]]"
}
HAPPY YEAR FRIENDS !!


nowhere in that code it does "!add packs thepackname"
!add packs

Code: Select all

scon -a if ($network == NETWORK.IRC) msg #Chan01 !add packs $3
How can it be corrected?
User avatar
CrazyCat
Revered One
Posts: 1217
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Ok, so I explain: the piece of code I add must be added to the previous code.
And as eggdrop is mono-server, it's useless to verify on which server it is connected.

So, here is the full code (based on mine):

Code: Select all

set packlist "lastpacks.txt"
set maxentry 50
set packchan "#channel1"
set modchan "#channel2"
set autonick {\[LWT\] \[TF\] ORATEGOD} 

# triggers "!add packs" command
bind pub - !add newpack
proc newpack {nick uhost handle chan text} {
   if {![string match -nocase $::packchan $chan]} { return }
   set args [split $text]
   if {![string match -nocase "packs" [lindex $args 0]]} { return }
   if {[llength $args]<2} {
     putserv "NOTICE $nick :Syntax error: !add packs \00302release title\003"
      return
   }
   set now [strftime "%d/%m/%Y (%Hh%M)"]
   set fi [open $::packlist "a"]
   puts $fi "[join [lrange $args 1 end]] $now"
   close $fi
}

# triggers "!last", "!latest" and "!l" commands
bind pub - !last lastpack
bind pub - !lastest lastpack
bind pub - !l lastpack
proc lastpack {nick uhost handle chan text} {
   if {![string match -nocase $::modchan $chan]} { return }
   set fo [open $::packlist "r"]
   set packs [lrange [split [read -nonewline $fo] "\n"] end-50 end]
   close $fo
   foreach pack $packs {
      putserv "PRIVMSG $nick :$pack"
   }
}

# triggers when someone in $autonick list
# type "new release ....."
bind pub - "new" addauto
proc addauto {nick uhost handle chan text} {
  if {![string match -nocase $::packchan $chan]} { return }
  set args [split $text]
  if {![string match -nocase "release" [lindex $args 0]]} { return }
  if {[lsearch -nocase $::autonick $nick]==-1} { return }
  newpack $nick $uhost $handle $chan "newpack [join [lrange $args 1 end]]"
}
Post Reply