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 

kick/ban on invite
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
simo
Master


Joined: 22 Mar 2015
Posts: 204

PostPosted: Mon Mar 13, 2017 1:06 am    Post subject: kick/ban on invite Reply with quote

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.
Back to top
View user's profile Send private message
Get_A_Fix
Master


Joined: 07 May 2005
Posts: 206
Location: New Zealand

PostPosted: Mon Mar 13, 2017 2:56 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
simo
Master


Joined: 22 Mar 2015
Posts: 204

PostPosted: Mon Mar 13, 2017 9:00 am    Post subject: Reply with quote

thx for the swift reply

i was looking at the tcl i wonder what bmotion is

Code:
# 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     
     }

}

Back to top
View user's profile Send private message
Get_A_Fix
Master


Joined: 07 May 2005
Posts: 206
Location: New Zealand

PostPosted: Mon Mar 13, 2017 10:14 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
willyw
Owner


Joined: 15 Jan 2009
Posts: 921

PostPosted: Mon Mar 13, 2017 11:16 am    Post subject: Reply with quote

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 !
Back to top
View user's profile Send private message
Get_A_Fix
Master


Joined: 07 May 2005
Posts: 206
Location: New Zealand

PostPosted: Mon Mar 13, 2017 3:16 pm    Post subject: Reply with quote

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


lol Smile

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.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
simo
Master


Joined: 22 Mar 2015
Posts: 204

PostPosted: Mon Mar 13, 2017 6:54 pm    Post subject: Reply with quote

im not sure how to edit it to do what i want it to do
Back to top
View user's profile Send private message
Get_A_Fix
Master


Joined: 07 May 2005
Posts: 206
Location: New Zealand

PostPosted: Mon Mar 13, 2017 7:29 pm    Post subject: Reply with quote

Try this (untested)

Code:

# 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"

_________________
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.


Last edited by Get_A_Fix on Tue Mar 14, 2017 12:15 pm; edited 2 times in total
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
simo
Master


Joined: 22 Mar 2015
Posts: 204

PostPosted: Tue Mar 14, 2017 4:59 am    Post subject: Reply with quote

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 )

Quote:
Tcl error [check:invite]: illegal channel: #jkjs
Back to top
View user's profile Send private message
Get_A_Fix
Master


Joined: 07 May 2005
Posts: 206
Location: New Zealand

PostPosted: Tue Mar 14, 2017 7:10 am    Post subject: Reply with quote

simo wrote:
i get this error :
Code:
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.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
willyw
Owner


Joined: 15 Jan 2009
Posts: 921

PostPosted: Tue Mar 14, 2017 1:05 pm    Post subject: Reply with quote

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 )

Quote:
Tcl error [check:invite]: illegal channel: #jkjs


This line:
Code:

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 !
Back to top
View user's profile Send private message
willyw
Owner


Joined: 15 Jan 2009
Posts: 921

PostPosted: Tue Mar 14, 2017 1:14 pm    Post subject: Reply with quote

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:


# 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 !
Back to top
View user's profile Send private message
simo
Master


Joined: 22 Mar 2015
Posts: 204

PostPosted: Tue Mar 14, 2017 9:04 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
willyw
Owner


Joined: 15 Jan 2009
Posts: 921

PostPosted: Tue Mar 14, 2017 9:43 pm    Post subject: Reply with quote

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 !
Back to top
View user's profile Send private message
simo
Master


Joined: 22 Mar 2015
Posts: 204

PostPosted: Fri Mar 17, 2017 1:41 am    Post subject: Reply with quote

ok
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Goto page 1, 2, 3  Next
Page 1 of 3

 
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