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.

[Solved]Need Help with dccsimul

Help for those learning Tcl or writing their own scripts.
Post Reply
Z
Zohaib
Voice
Posts: 22
Joined: Wed May 18, 2011 3:30 am

[Solved]Need Help with dccsimul

Post by Zohaib »

Hello Everyone,
I am trying to make public commands for changing settings for Allprotection without DCC chat As now a days most of the time I dont have access to my Laptop and cannot use DCC chat directly from phone.
here are few things i have tried but they didnt work.

I was Using this Code to Enable Disable Scripts using Public Command
for example !enable/disable gseen youtube and other scripts

Code: Select all

proc dcc_enable {nick uhost hand chan text} {
	set chan1 [lindex $text 0]
	set cmdschar [lindex $text 1]
	channel set $chan1 +$cmdschar
	puthelp "privmsg $chan : Enabled $cmdschar on Channel $chan1 ."  
}
so i tried editing it for All Protection stuff

Code: Select all

proc dcc_chanset {nick uhost hand chan text} {
	set chan1 [lindex $text 0]
	set cmdschar [lrange [split $text] 1 end]]
	channel set $chan1 $cmdschar
	puthelp "Notice $nick : Channel $chan1 Settings Changed to $cmdschar"  
}
But i m getting this error
Tcl error [dcc_chanset]: illegal channel option: ap:reset"
so instead using
channel set $chan1 $cmdschar
I changed it to

Code: Select all

proc dcc_chanset {host idx text} {
	set chan1 [lindex $text 0]
	set cmdschar [lrange $text 1 end]
	dccsimul $idx ".chanset $chan1 $cmdschar"
	puthelp "privmsg $chan : Channel $chan1 Settings Changed to $cmdschar"  
}
but i am getting this error
Tcl error [dcc_chanset]: wrong # args: should be "dcc_chanset host idx text"
Can anyone guide me how I achieve my goal here

P.S i m noob in scripting.

Thanks in Advance
Last edited by Zohaib on Sun May 10, 2020 11:39 am, edited 1 time in total.
<Zohaib>
Z
Zohaib
Voice
Posts: 22
Joined: Wed May 18, 2011 3:30 am

Post by Zohaib »

any body?
<Zohaib>
User avatar
CrazyCat
Revered One
Posts: 1306
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

the ap:reset is not a known value, so it's normal you got an error. (.chaninfo #yourchan to list the available values).
Try your dcc_enable proc with a standard value, like seen or greet.

For your use of dccsimul, the error message seems clear:

Code: Select all

dccsimul $host $idx ".chanset $chan1 $cmdschar"
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Here's something i threw together really quick:

Code: Select all

namespace eval ChanSet {

	bind pub n|n .chanset [namespace current]::chanset
	
	proc chanset {nick uhost hand chan text} {
		if {[scan $text {%s%s} mode value] < 1} {
			puthelp "NOTICE $nick :Error, usage: $::lastbind +/-<channel mode> \[value\]"
			return
		}
		if {![string last - $mode]} {
			set what [string map {- ""} $mode]
		} else {
			set what [string map {+ ""} $mode]
		}
		if {[catch {channel get $chan $what} err]} {
			puthelp "NOTICE $nick :Error, \002$what\002 is an unkown channel setting."
			return
		}
		if {[info exists value]} {
			channel set $chan $mode $value
			puthelp "NOTICE $nick :Channel mode $what has been set to $value"
		} else {
			channel set $chan $mode
			puthelp "NOTICE $nick :Channel mode $what has been set to [expr {[string first + $mode] > -1 ? "enabled" : "disabled"}]."
		}
	}
}
Once the game is over, the king and the pawn go back in the same box.
Z
Zohaib
Voice
Posts: 22
Joined: Wed May 18, 2011 3:30 am

Post by Zohaib »

Thanks a lot guys. I m going to give it a go. I really appreciate you guys your help means a lot to us. Thanks once again
<Zohaib>
Z
Zohaib
Voice
Posts: 22
Joined: Wed May 18, 2011 3:30 am

Post by Zohaib »

caesar wrote:snip
thanks for your help.
there was a small problem for me as it was working for mode value of 2 digits only
<@Zohaib> .set #me ap:limit +3
-XmIRC- Channel mode for #me ap:limit has been set to +3
But when i tried it for a bigger value command i.e
<@Zohaib> .set #me ap:cjoin 3:2 120 kb 2
-XmIRC- Channel mode for #me ap:cjoin has been set to 3:2
it was not reading and setting the whole value for it so i modified it a bit

Code: Select all

namespace eval ChanSet {

   bind pub n|n .set [namespace current]::chanset
   
   proc chanset {nick uhost hand chan text} {
	set chan [lindex $text 0]
	set mode [lindex $text 1]
	set value [lrange [split $text] 2 end]
      if {![string last - $mode]} {
         set what [string map {- ""} $mode]
      } else {
         set what [string map {+ ""} $mode]
      }
      if {[catch {channel get $chan $what} err]} {
         puthelp "NOTICE $nick :Error, \002$what\002 is an unkown channel setting."
         return
      }
      if {[info exists value ]} {
         channel set $chan $mode $value
         puthelp "NOTICE $nick :Channel mode for $chan $what has been set to $value"
      } else {
         channel set $chan $mode
         puthelp "NOTICE $nick :Channel mode for $chan $what has been set to [expr {[string first + $mode] > -1 ? "enabled" : "disabled"}]."
      }
   }
}
And now it is working like a Charm

thanks a lot for your help. Now problem is with the enable disable option and i m trying to fix it. i will post the next update as i fix it thanks once again
<Zohaib>
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Here's a quick fix for the previous code to work with 'ap:cjoin 3:2 120 kb 2' or whatever you want to throw at it:

Code: Select all

namespace eval ChanSet {

	bind pub n|n .set [namespace current]::chanset
	
	proc chanset {nick uhost hand chan text} {

		set pos [string first # $text]
		if {!$pos} {
			scan $text {%s%s} chan mode
		} else {
			scan $text {%s} mode
		}
		
		if {![info exists mode]} {
			puthelp "NOTICE $nick :Error, usage: $::lastbind \[channel\] <channel mode> \[value\]. For example $::lastbind #foo +enforcebans, $::lastbind $chan blah 1 2 3, $::lastbind foo 2:5" 
			return
		}

		if {![string last - $mode]} {
			set what [string map {- ""} $mode]
		} else {
			set what [string map {+ ""} $mode]
		}
		
		if {![validchan $chan]} {
			puthelp "NOTICE $nick :Error, I'm not on $chan channel."
			return
		}
		
		if {[string equal $mode $what]} {
			set value [lrange $text [expr $pos +2] end]
		}		

		if {[catch {set now [channel get $chan $what]} err]} {
			puthelp "NOTICE $nick :Error, \002$what\002 is an unkown channel setting."
			return
		}

		if {[info exists value]} {
			if {[string equal -nocase $now $value]} {
				puthelp "NOTICE $nick :Channel mode $what is already set to $now."
				return
			}
			channel set $chan $mode $value
			puthelp "NOTICE $nick :Channel mode $what has been set to $value for $chan cahnnel."
		} else {
			scan [string map {+ 1 - 0} $mode] {%d} change
			if {[string equal $now $change]} {
				puthelp "NOTICE $nick :Error, channel mode $what is already [expr {$now ? "enabled" : "disabled"}] for $chan channel"
				return
			}
			channel set $chan $mode
			puthelp "NOTICE $nick :Channel mode $what has been [expr {[string first + $mode] > -1 ? "enabled" : "disabled"}] for $chan channel."
		}
	}
}
Edit: Added some extra stuff. ;)
Once the game is over, the king and the pawn go back in the same box.
Z
Zohaib
Voice
Posts: 22
Joined: Wed May 18, 2011 3:30 am

Post by Zohaib »

Now this looks yummy 😋 😋
<Zohaib>
Post Reply