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.

OP Event doubt

Help for those learning Tcl or writing their own scripts.
Post Reply
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

OP Event doubt

Post by juanamores »

I want to control the OP events, when someone comes up with @ to a my channel ($canal_radio).

If the nick you get @ it is the DJ ($dj) that emits or has flags are +o +a +t or +n not do anything.

If the nick you get @ it is NOT the DJ ($dj) that emits or flags are NOT +o +a +t or +n the bot must remove the @ (DEOP or -o).

To be honest I do not know the on OP event.

I tried this but it did not work :

Code: Select all

bind mode - "% +o" check:op 
proc check:op {nick host hand chan mode target} {
 global canal_radio
 if {[file exist dj]} {
	set temp [open "dj" r]
    set dj1 [gets $temp]
	set dj [lindex $dj1 0]
    close $temp
   } 
   if {([info exist dj]) && ([matchattr $nick -o]) && ([matchattr $nick -a]) && ([matchattr $nick -n]) && ([matchattr $nick -t]) && ($nick != $::botnick)} {
	foreach users [chanlist $canal_radio] {
		if {[isop $users $canal_radio]} {
			if {($users eq $::botnick) || ($users eq $dj) || ([matchattr $users o]) || ([matchattr $users a]) || ([matchattr $users n]) || ([matchattr $users t]) } {continue}
				if {$users != $dj} { 
	putserv "mode $canal_radio +v $dj"
	putserv "mode $canal_radio -o $dj"
	putserv "PRIVMSG chan :DEOP $canal_radio $dj" 
	putquick "PRIVMSG $canal_radio :\002$dj\002 to be @ with you must be emitting." 
				}
		} 
	}	
	} else { return }
}
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks :)
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

You lost me at second line. If the DJ gives @ to someone then the bot shouldn't remove the @ from them?

Or the bot shouldn't remove the @ if the person who just got it or already had the @ is either the current DJ or has one of the flags you mentioned?
Once the game is over, the king and the pawn go back in the same box.
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Post by juanamores »

caesar wrote:You lost me at second line. If the DJ gives @ to someone then the bot shouldn't remove the @ from them?
Yes, the bot only gives @ (OP) to the DJ that is going to broadcast (current DJ).
When the DJ completes its broadcast, the robot removes the @ (DEOP).
If somebody gives @ to one DJ who is not brodcasting, then I want the bot removes this @ inmediately.
caesar wrote:Or the bot shouldn't remove the @ if the person who just got it or already had the @ is either the current DJ or has one of the flags you mentioned?
If the person who gets the @ is the current DJ or has one of the flags mentioned above, then the bot does NOT has to take it off.
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks :)
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Give this a try:

Code: Select all

bind mode - "% +o" dj:check:op

proc dj:check:op {nick host hand chan mode vict} {
	global canal_radio
	if {![string match -nocase $chan $canal_radio]} return
	if {![botisop $chan]} return
	if {[file exist "dj"]} {
		set fo [open "dj" r]
		set data [read -nonewline $fo]
		set dj [lindex $data 0]
		close $fo
	}
	if {[info exists dj]} {
		foreach user [chanlist $chan] {
			if {[isbotnick $nick]} continue
			if {![isop $user $chan]} continue
			if {[string equal -nocase $user $dj]} continue
			set hand [nick2hand $user $chan]
			if {[dj:check:flags $chan $hand]} continue
			lappend uList $user
		}
		if {[info exists uList]} {
			set max 6		
			set len [llength $uList]
			while {$len > 0} {
				if {$len > $max} {
					set m1 [string repeat "o" $max]
					set m2 [string repeat "v" $max]
					set users [join [lrange $uList 0 [expr {$max - 1}]]]
					set uList [lrange $uList $max end]
					incr len -$max
				} else {
					set m1 [string repeat "o" $len]
					set m2 [string repeat "v" $len]
					set users [join $uList]
					set len 0
				}
				pushmode $chan -$m1 $users
				pushmode $chan +$m2 $users
				puthelp "PRIVMSG $chan :$users to be @ with you must be emitting."
			}
		}
	}
}

proc dj:check:flags {chan hand {flags "oatn"}} {
	set match 0
	if {[validuser $hand]} {
		foreach flag [split $flags] {
			if {[matchattr $hand $flag $chan]} {
				set match 1
				break
			}
		}
	}
	return "$match"
}
When there's a +o the bot will check the entire list of @ members to see if a member has one of the flags or is DJ, if not will remove @ and give voice (+) instead. Haven't tested this so load it on a test bot. :)

Edit: Fixed typo.
Last edited by caesar on Fri Sep 23, 2016 9:56 am, edited 1 time in total.
Once the game is over, the king and the pawn go back in the same box.
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Post by juanamores »

It does not work

If I try to give me @ through boT CHaN (Official Network Bot, i.e ChanServ)

Code: Select all

/msg CHaN OP #mychannel juanam
10:47 ?                         => ¦ CHaN puts mode [+o juanam ]
10:47                @My-BoT ¦ CHaN CHaN CHaN CHaN to be @ with you must be emitting.
My BoT mentions 4 times Bot CHaN, when he should do it once to my nick, and then NOT remove @, but anyway it should NOT be because I have all the flags.

If I give @ Maria (NOT the current DJ)

Code: Select all

/mode #mychannel +o Maria
10:47 ?                         => ¦ juanam puts mode [+o Maria ]
10:47                @My-BoT ¦ juanam juanam juanam juanam juanam to be @ with you must be emitting.
My BoT mentions 5 times my nick instead of Maria and then NOT remove @.
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks :)
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Ah i noticed a typo. Replace:

Code: Select all

lappend uList $nick 
with

Code: Select all

lappend uList $user
I'll test right now to see what else isn't working.

Edit: I did some limited testing in tclsh and seems to be working as intended. Make the change and let me know if still doesn't and will test on a bot.
Once the game is over, the king and the pawn go back in the same box.
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Post by juanamores »

Now, work perfectly. Thank you caesar. :D
I had to change this:

Code: Select all

pushmode $chan -$m1 $users
pushmode $chan +$m2 $users 
for this:

Code: Select all

putserv "mode $canal_radio +v $users"
putserv "mode $canal_radio -o $users"
This may be because the commands are different in my Network.
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks :)
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

My guess it has to do with having just a single mode change if it applies to multiple victims. To test this out from your irc client do:

Code: Select all

/mode #channel +v member_1 member_2 member_3 member_4 member_5 member_6
and if you voice all 6 members in one line then replace your putserv lines with:

Code: Select all

pushmode $chan -o $users
pushmode $chan +v $users
Once the game is over, the king and the pawn go back in the same box.
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Post by juanamores »

Ok, I'll try, but it works perfect.
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks :)
Post Reply