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.

kick/ban on invite

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
s
simo
Revered One
Posts: 1107
Joined: Sun Mar 22, 2015 2:41 pm

kick/ban on invite

Post by simo »

hi,

I was looking around for an anti invite tcl it seems there arent any around.

Basicly it needs to set ban (if eggdrop is gettin invites for other channels) on all channels the bot is opped and also check if the inviter is on channel and kick if so

Thnx.
User avatar
Get_A_Fix
Master
Posts: 206
Joined: Sat May 07, 2005 6:11 pm
Location: New Zealand

Post by Get_A_Fix »

You could play around with something like this and make it do what you need. The fundamentals are there.
We explore.. and you call us criminals. We seek after knowledge.. and you call us criminals. We exist without skin color, without nationality, without religious bias.. and you call us criminals.
s
simo
Revered One
Posts: 1107
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

thx for the swift reply

i was looking at the tcl i wonder what bmotion is

Code: Select all

# March 5, 2012
# http://forum.egghelp.org/viewtopic.php?t=18870


# Be sure that bmotion is loaded before this script.
# This script attempts to set user defined flag +bmotion.  If bmotion does not exist first, it is a Bad Thing.


bind raw - invite the341

set oldinvitetime [expr [unixtime] - 60]
set oldchan ""


proc the341 {from key text} {
global botnick oldinvitetime oldchan

   set chan [string trimleft [lindex [split $text] 1] :]
   set nick [lindex [split $from !] 0]


   set invitetime [unixtime]
   set diff [expr $invitetime - $oldinvitetime]
   

     if {$diff < 60} {
      putserv "privmsg $nick :I was just invited to $oldchan. Please wait [expr 60 - $diff] seconds before inviting me again."
         return 0
         }
     
      set oldinvitetime $invitetime
      set oldchan $chan

   channel add $chan
        utimer 3 [list do_check $nick $chan]
}



proc do_check {nick chan} {
global botnick

   if {[isop $nick $chan] } {
      putserv "privmsg $chan :Hi there I'm $botnick. I was invited by $nick. Try +commands for a list of my commands and +opcom for the list of commands who only can be used by an Op."
      channel set $chan +bmotion      
          } else {
      putserv "privmsg $chan :I was invited by a non-op. Please try again with an opped Nick."
      channel remove $chan     
     }

}

User avatar
Get_A_Fix
Master
Posts: 206
Joined: Sat May 07, 2005 6:11 pm
Location: New Zealand

Post by Get_A_Fix »

lol, bMotion is an AI script, much like egg-fu or a lower-end alice instance. The script gives you the raw, it shows how to set the nickname using $from and channel from $text - you only really need the341 proc.

You should be able to make it work, but if not, someone may post a full snippet for you.
We explore.. and you call us criminals. We seek after knowledge.. and you call us criminals. We exist without skin color, without nationality, without religious bias.. and you call us criminals.
w
willyw
Revered One
Posts: 1205
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

Get_A_Fix wrote:You could play around with something like this and make it do what you need. The fundamentals are there.
Wow... I don't even remember doing that.
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
User avatar
Get_A_Fix
Master
Posts: 206
Joined: Sat May 07, 2005 6:11 pm
Location: New Zealand

Post by Get_A_Fix »

willyw wrote:Wow... I don't even remember doing that.
lol :)

I always check search, to make sure it hasn't already been covered before giving any info. I found that, thought it was best to post it than make something. Saves on time and doubling up code.
We explore.. and you call us criminals. We seek after knowledge.. and you call us criminals. We exist without skin color, without nationality, without religious bias.. and you call us criminals.
s
simo
Revered One
Posts: 1107
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

im not sure how to edit it to do what i want it to do
User avatar
Get_A_Fix
Master
Posts: 206
Joined: Sat May 07, 2005 6:11 pm
Location: New Zealand

Post by Get_A_Fix »

Try this (untested)

Code: Select all

# noinvite.tcl,v1.0
## SYNTAX: !noinvite on|off

# Set global trigger
set noInvTrig "!"

# Set the time duration (in minutes) for ban here (if 0 is set, this would be permanent)
set timetoban "5"

# Set flags that can enable/disable this procedure (default: globalop|chanmaster)
set noInvFlags o|m

# Set the reasons for no invitations ban
set noInvReason "This channel does not allow invites to bot or public"

# BAN Types are given below;
# 1 - *!*@some.domain.com 
# 2 - *!*@*.domain.com
# 3 - *!*ident@some.domain.com
# 4 - *!*ident@*.domain.com
# 5 - *!*ident*@some.domain.com
# 6 - *nick*!*@*.domain.com
# 7 - *nick*!*@some.domain.com
# 8 - nick!ident@some.domain.com
# 9 - nick!ident@*.host.com
set bantype 1

## ----- Lets get coding! -----
setudef flag noinvite

proc makeInvTrig {} {
  global noInvTrig
  return $noInvTrig
}

bind raw - invite check:invite
proc check:invite {from key text} {
  global botnick noInvReason timetoban
  set nick [lindex [split $from !] 0]
  if {[string match "*#*" $text]} { 
    set chan [lindex [split $text] 1]
    set uhost [getchanhost $nick $chan]
    if {[validuser [nick2hand $nick]] || [isop $nick $chan]} {return}
    set mask [make:banmask $uhost $nick]
    newban $mask $botnick $noInvReason $timetoban
  }
}

bind pub - ${noInvTrig}noinvite noInv:pub
proc noInv:pub {nick uhost hand chan arg} {
  global noInvFlags
  if {[matchattr [nick2hand $nick] $noInvFlags $chan]} {
    if {[lindex [split $arg] 0] == ""} {putquick "PRIVMSG $chan :ERROR: Incorrect Parameters. SYNTAX: [makeInvTrig]noinvite on|off"; return}

    if {[lindex [split $arg] 0] == "on"} {
      if {[channel get $chan noinvite]} {putquick "PRIVMSG $chan :ERROR: This setting is already enabled."; return}
      channel set $chan +noinvite
      puthelp "PRIVMSG $chan :Enabled No Invitations for $chan"
      return
    }

    if {[lindex [split $arg] 0] == "off"} {
      if {![channel get $chan noinvite]} {putquick "PRIVMSG $chan :ERROR: This setting is already disabled."; return}
      channel set $chan -noinvite
      puthelp "PRIVMSG $chan :Disabled No Invitations for $chan"
      return
    }
  }
}

proc make:banmask {uhost nick} {
 global bantype
  switch -- $bantype {
   1 { set banmask "*!*@[lindex [split $uhost @] 1]" }
   2 { set banmask "*!*@[lindex [split [maskhost $uhost] "@"] 1]" }
   3 { set banmask "*!*$uhost" }
   4 { set banmask "*!*[lindex [split [maskhost $uhost] "!"] 1]" }
   5 { set banmask "*!*[lindex [split $uhost "@"] 0]*@[lindex [split $uhost "@"] 1]" }
   6 { set banmask "*$nick*!*@[lindex [split [maskhost $uhost] "@"] 1]" }
   7 { set banmask "*$nick*!*@[lindex [split $uhost "@"] 1]" }
   8 { set banmask "$nick![lindex [split $uhost "@"] 0]@[lindex [split $uhost @] 1]" }
   9 { set banmask "$nick![lindex [split $uhost "@"] 0]@[lindex [split [maskhost $uhost] "@"] 1]" }
   default { set banmask "*!*@[lindex [split $uhost @] 1]" }
   return $banmask
  }
}

putlog ".:Loaded:. noinvite.tcl,v1.0 for simo @ egghelp.forums"
Last edited by Get_A_Fix on Tue Mar 14, 2017 12:15 pm, edited 2 times in total.
We explore.. and you call us criminals. We seek after knowledge.. and you call us criminals. We exist without skin color, without nationality, without religious bias.. and you call us criminals.
s
simo
Revered One
Posts: 1107
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

i get this error :

( it seems to get the channel where its invited to
while it needs to set ban on every channel where bot is opped
and check if the one who sent the invite is in any of those channels and get kicked as well as the ban )
Tcl error [check:invite]: illegal channel: #jkjs
User avatar
Get_A_Fix
Master
Posts: 206
Joined: Sat May 07, 2005 6:11 pm
Location: New Zealand

Post by Get_A_Fix »

simo wrote:i get this error :

Code: Select all

Tcl error [check:invite]: illegal channel: #jkjs
hmm, strange, I haven't been able to test it but I was going from willyw's script. It, from past experience, should have worked fine.
I edited the code above, try recopying, rehash and trigger the event again.
simo wrote: ( it seems to get the channel where its invited to
while it needs to set ban on every channel where bot is opped
and check if the one who sent the invite is in any of those channels and get kicked as well as the ban )
Well, I was going to use a foreach and check every channel, but I just used a newban call instead. This does the same thing, as long as the bot is @'d. It adds the ban to the internal banlist, so it'll add the ban on any active channel the user joins or is on, until removed.
We explore.. and you call us criminals. We seek after knowledge.. and you call us criminals. We exist without skin color, without nationality, without religious bias.. and you call us criminals.
w
willyw
Revered One
Posts: 1205
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

simo wrote:i get this error :

( it seems to get the channel where its invited to
while it needs to set ban on every channel where bot is opped
and check if the one who sent the invite is in any of those channels and get kicked as well as the ban )
Tcl error [check:invite]: illegal channel: #jkjs
This line:

Code: Select all

set chan [string trimleft [lindex [split $text] 1] :] 
does get the channel name that bot was invited to join.
Since bot isn't in it... thus, the error appears later in the script.
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
w
willyw
Revered One
Posts: 1205
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

Get_A_Fix wrote: ...
Well, I was going to use a foreach and check every channel, but I just used a newban call instead. This does the same thing, as long as the bot is @'d. It adds the ban to the internal banlist, so it'll add the ban on any active channel the user joins or is on, until removed.
Yes.

It seems to me that invites are not channel dependent at all. An invite can come in from a nick that is not in a channel with you.

And unless I misunderstand what the original poster here is asking for, I came up with this:

Code: Select all


# March 14, 2017
# http://forum.egghelp.org/viewtopic.php?p=105901#105901


## Basicly it needs to set ban (if eggdrop is gettin invites for other channels) on all channels the bot is opped and
## also check if the inviter is on channel and kick if so


# Do:  .chaninfo #channel
# See:  enforcebans
# Experiment with it. Probably needs to be +enforcebans

#####################################
#####################################


bind raw - invite invite_banner

proc invite_banner {from key text} {
global botnick

        set nick [lindex [split $from !] 0]
        set uhost [lindex [split $from !] 1]
        set invited_to_chan [string trimleft [lindex [split $text] 1] :]

putquick "privmsg #helpbottest : "
putquick "privmsg #helpbottest :from is: $from "
putquick "privmsg #helpbottest :nick is: $nick "
putquick "privmsg #helpbottest :uhost is: $uhost "
putquick "privmsg #helpbottest :masked host is: [maskhost $nick!$uhost 2] "

        newban [maskhost $nick!$uhost 2] $botnick "global banned for inviting $botnick to $invited_to_chan" 60


}

It is super simplified.
BUT !
I have encountered an interesting problem.

Get-A-Fix (or anyone else too) :
This script only gets the real hostmask on every other invite .
See the putquick lines. Can you load this thing and set them to some test channel of your own?

Then send an invite to some other channel.
Watch what is said by the bot in your test chan.
Do the same invite again.
It doesn't get the hostmask on the first try, but it does on the second.
And this pattern repeats.

What do you make of it?
Have I overlooked something super silly?

Thanks.
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
s
simo
Revered One
Posts: 1107
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

tested it willyw and

and indeed as u prev said
in the outputs it sometimes outputs host sometimes its empty

would it possible to not use internal banlist with newban cause we want to be able to remove bans at all times and not have bot add bans back again after chanOP removes we rather use channel bans to keep the freedom to remove bans at anytime
w
willyw
Revered One
Posts: 1205
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

simo wrote: ...
would it possible to not use internal banlist...
If we can get the hostmask of the inviter every time, then : Yes.

But until then, we are stuck.
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
s
simo
Revered One
Posts: 1107
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

ok
Post Reply