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 

change mrc to tcl (please help)

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
ORATEGOD
Voice


Joined: 08 Jun 2020
Posts: 32

PostPosted: Mon Dec 28, 2020 10:45 pm    Post subject: change mrc to tcl (please help) Reply with quote

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


Code:

; ---------------------------------------------
; 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.
Back to top
View user's profile Send private message AIM Address
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Tue Dec 29, 2020 6:31 am    Post subject: Reply with quote

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:
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
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1175

PostPosted: Tue Dec 29, 2020 9:55 am    Post subject: Reply with quote

Some good references to bookmark and use, when learning :


http://suninet.the-demon.de/

https://docs.eggheads.org/mainDocs/tcl-commands.html

http://www.tcl.tk/man/tcl8.6/TclCmd/contents.htm
_________________
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
Back to top
View user's profile Send private message
ORATEGOD
Voice


Joined: 08 Jun 2020
Posts: 32

PostPosted: Tue Dec 29, 2020 11:35 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message AIM Address
ORATEGOD
Voice


Joined: 08 Jun 2020
Posts: 32

PostPosted: Tue Dec 29, 2020 11:36 am    Post subject: Reply with quote

Cheers... Thanks for those references ... I'll study them.
Back to top
View user's profile Send private message AIM Address
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Wed Dec 30, 2020 5:30 am    Post subject: Reply with quote

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:
puts $fi "[join [lrange $args 1 end]] $now"


@line 26, bad opening of the file:
Code:
set fo [open $::packlist "r"]


If you used party-line and console mode +d, you'll get the error.
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
ORATEGOD
Voice


Joined: 08 Jun 2020
Posts: 32

PostPosted: Wed Dec 30, 2020 11:49 pm    Post subject: Reply with quote

I work with these lines...

Code:
# ==============================================================================================================================================================================
# 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:
;# ----------[ 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
    }
  }
}
Back to top
View user's profile Send private message AIM Address
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Thu Dec 31, 2020 6:31 am    Post subject: Reply with quote

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

Code:
;# ----------[ 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:
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]]"
}

_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
ORATEGOD
Voice


Joined: 08 Jun 2020
Posts: 32

PostPosted: Sun Jan 03, 2021 4:24 pm    Post subject: Reply with quote

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

Code:
;# ----------[ 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:
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:
scon -a if ($network == NETWORK.IRC) msg #Chan01 !add packs $3
How can it be corrected?
Back to top
View user's profile Send private message AIM Address
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Sun Jan 03, 2021 6:59 pm    Post subject: Reply with quote

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:
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]]"
}

_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
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 -> Script Requests 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