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.

ChanServ Akick

Help for those learning Tcl or writing their own scripts.
Post Reply
i
illusionist
Voice
Posts: 25
Joined: Mon Mar 09, 2020 11:22 am

ChanServ Akick

Post by illusionist »

Hello Everyone This is a small ChanServ TCL and it is working very well. It does not have a check system to show the error message that Nick is already added in akick list of channel or nick is not found in akick list of channel when adding or removing akick.

If aome one can add a check system .. really appreciated
Thanks in advance

Code: Select all

set chanserv "chanserv@services.dal.net"

setudef flag chanserv


###Chanserv Add Akick
proc accessakick {nick host handle channel testes} {
    global nxg chanserv
if {[channel get $channel chanserv]} { 
    set who [lindex $testes 0]
    set reason [lrange $testes 1 end]
    if {$reason == ""} {set reason "\0032In \00312compliance \0032with the aDministration of \00312$channel\017 \002\037\0037(\017\00312\u00bb\0031\002j\002a\0034\002D\002u\0031\u00ae\00312\u00ab\0037\002\037)\017"
    }
	putserv "PRIVMSG $chanserv :akick $channel add $who $reason"
	putserv "NOTICE $nick :$who added to $channel Akick list."
    putlog "$nick added $who to the Akick list in $channel"
 }
}
###End Of Chanserv Add Akick

###Chanserv Remove Akick
proc accessremoveakick {nick host handle channel testes} {
    global nxg chanserv
if {[channel get $channel chanserv]} { 
	set who [lindex $testes 0]
	putserv "PRIVMSG $chanserv :akick $channel del $who"
	putserv "NOTICE $nick :$who deleted from $channel Akick list."
    putlog "$nick removed $who from the Akick list in $channel"
 }
}
###End Of Chanserv Remove Akick
User avatar
CrazyCat
Revered One
Posts: 1305
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Quite hard to do: services use msg or notice (depend on your choice and the default choice of admin) and can use the language you want.
So you'll have to bind pubs and notices, and have the correct sentences interesting you.

Simpliest to do a /msg chanserv akick...
s
simo
Revered One
Posts: 1107
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

u could try this:

Code: Select all

bind pub -!- .akick pub-add-akick

proc pub-add-akick {nick host hand chan text} {
       if {![matchattr [nick2hand $nick] o|o $chan] && ![isop $nick $chan] && ![ishalfop $nick $chan]} { return 0  }
   global anick
    set anick $nick
  set who [lindex [split $text] 0]
  set reason [join [lrange [split $text] 1 end]] 
  if {$reason == ""} {set reason "\0032In \00312compliance \0032with the aDministration of \00312$chan\017 \002\037\0037(\017\00312\u00bb\0031\002j\002a\0034\002D\002u\0031\u00ae\00312\u00ab\0037\002\037)\017" 
  set items [split $text]
  if {[llength $items] < 1} {
    putserv "NOTICE $nick :Syntax\: .akick \[mask\] \[reason\]"
    return
  } 
   putserv "chanserv akick $chan add $who $reason"
   putserv "NOTICE $nick :$who added to $chan Akick list."
 }
}


bind notc - "*already exists on the AKICK list of*" duplicate-akick

proc duplicate-akick {nick uhost hand text dest} {
global anick
if {[string match -nocase $nick chanserv]} { putserv "notice $anick :\002$text\002"}
 }


User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

I saw this in another topic and wanted to ask you about it in there but forgot. Anyway, why do you use nick2hand if you already have the handle (the name of the user's account on the bot) set in hand variable when the pub-add-akick process is triggered?

Right now that first if line will 'return 0' if the user isn't local "operator" or global "operator" AND isn't channel operator (having a @, not necessarily access on the bot) AND isn't a halfop. You sure this is the wanted behavior?

Anyway, I don't see the point of the matchattr part entirely when you can just change at the flags on the bind directly, I mean changing from:

Code: Select all

bind pub -!- .akick pub-add-akick 
to:

Code: Select all

bind pub o|o .akick pub-add-akick 
that will basically have the same effect.

I'll show you a nifty trick with lassign, turning this:

Code: Select all

  set who [lindex [split $text] 0]
  set reason [join [lrange [split $text] 1 end]] 
into this:

Code: Select all

set reason [lassign $text who]
results:

Code: Select all

% set text "user some long reason in here"
% set reason [lassign $text who]
some long reason in here
% puts $who
user
% puts $reason
some long reason in here
It would be a good idea if you would move the:

Code: Select all

if {[llength $items] < 1} {
higher, preferable after the 1st line and make it into:

Code: Select all

if {![llength $text]} {
that translates if the text variable content's length is 0 (or empty) then do whatever you want.
Once the game is over, the king and the pawn go back in the same box.
s
simo
Revered One
Posts: 1107
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

nice tnx caesar
Post Reply