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 

Auto Voice System
Goto page Previous  1, 2
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
mvp1
Voice


Joined: 27 Jan 2022
Posts: 22

PostPosted: Tue Feb 01, 2022 8:20 am    Post subject: Reply with quote

HI @Caesar /all, I am trying to test a similar av system and thank you very much for your code mate. I am using below code successfully and its working fine for voice g flag users and then devoicing every user after set time. I tried the exeptions code you mentioned but it didn't work properly. Appreciate if you can write me a exception code which I can add to this, where it does not devoice the exception users? I want to add exception users manually by for example giving them another flag or something? so the code can check if the user have exception flag, then not devoice it.

Code:





namespace eval idleDevoice {

   # Default idle time in minutes
   set idleTime 2

   setudef flag idleDevoice     
   
   bind cron - {* * * * *} [namespace current]::idle:cron
   bind pubm g|g * [namespace current]::idle:voice
   
   proc idle:cron {min hour day month weekday} {
      variable idleTime
      set now [clock seconds]
      foreach channel [channels] {
         if {![channel get $channel idleDevoice]} continue
         if {![botisop $channel]} continue
         foreach member [chanlist $channel] {
            if {[isbotnick $member]} continue
         
            if {[isop $member $channel] || ![isvoice $member $channel]} continue
          #  set handle [nick2hand $member $channel]
          #  if {[matchattr $handle e]} return
            set chanidle [getchanidle $member $channel]
            if {$chanidle >= $idleTime} {
               lappend userList $member
            }
         }
         
        if {[info exists userList]} {
          idle:push $channel $userList
}
      }
   }

   proc idle:voice {nick uhost hand chan text} {
      if {![botisop $chan]} return
      if {[isvoice $nick $chan]} return
      pushmode $chan +v $nick
   }
   
   proc idle:push {channel userList} {
      if {![botisop $channel]} return
      set max 6
        set len [llength $userList]
        while {$len > 0} {
         if {$len > $max} {
            set mode [string repeat "v" $max]
            set users [join [lrange $userList 0 [expr {$max - 1}]]]
            set userList [lrange $userList $max end]
            incr len -$max
         } else {
            set mode [string repeat "v" $len]
            set users [join $userList]
            set len 0
         }
            pushmode $channel -$mode $users
      }
   }
}

[/code]
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1058
Location: France

PostPosted: Tue Feb 01, 2022 8:43 am    Post subject: Reply with quote

If your users are in bot's userlist, add them the +V flag (global or per channel)

Then, find the following line:
Code:
if {[isop $member $channel] || ![isvoice $member $channel]} continue


Replace it with:
Code:
if {[isop $member $channel] || ![isvoice $member $channel] || [matchattr [nick2handle $member] +V|+V $channel]} continue

_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
mvp1
Voice


Joined: 27 Jan 2022
Posts: 22

PostPosted: Wed Feb 02, 2022 6:24 am    Post subject: Reply with quote

Hi CrazyCat, thanks mate. I've testing it now and getting below error;

[05:23:00] Tcl error [::idleDevoice::idle:cron]: invalid command name "nick2handle"
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1058
Location: France

PostPosted: Wed Feb 02, 2022 6:50 am    Post subject: Reply with quote

My bad... nick2hand
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
mvp1
Voice


Joined: 27 Jan 2022
Posts: 22

PostPosted: Wed Feb 02, 2022 7:00 am    Post subject: Reply with quote

Cheers CrazyCat, the +V flag exception works now. Legend mate.
However, I just picked up another issue. The eggdrop seems to be enforcing the voice on +g flag users? I'm not too sure if there's something we could do with this code, or with my .chaninfo settings for the channel?

Below is example,
(after it voices a +g user when users speak, if any other OP devoices it manually, it voices it back) (Also when a +g user is currently devoice, and if any other user devoice it again, the bot puts it back on voice, until the devoice timer 2 mins, when bot devoices it itself)

[23:49] <User1> hi
[23:49] * Bot sets mode: +v User1
[23:49] * AnotherOP sets mode: -v User1
[23:49] * Bot sets mode: +v User1
[23:52] * Bot sets mode: -v User1
[00:11] * AnotherOp sets mode: -v User1
[00:11] * Bot sets mode: +v User1


Below is my .chaninfo output;


[23:50] <AnotherOP> .chaninfo #channel123
[23:50] <Bot> Settings for dynamic channel #channel123:
[23:50] <Bot> Protect modes (chanmode): +tn
[23:50] <Bot> Idle Kick after (idle-kick): DON'T!
[23:50] <Bot> stopnethack: DON'T!
[23:50] <Bot> aop-delay: 5:30
[23:50] <Bot> revenge-mode: 0
[23:50] <Bot> ban-type: 3
[23:50] <Bot> ban-time: 120
[23:50] <Bot> exempt-time: 60
[23:50] <Bot> invite-time: 60
[23:50] <Bot> Other modes:
[23:50] <Bot> -inactive -statuslog -secret +shared
[23:50] <Bot> +greet -seen +cycle +dontkickops
[23:50] <Bot> +protectops -protectfriends -revenge -revengebot
[23:50] <Bot> -bitch -autoop -autovoice -nodesynch
[23:50] <Bot> -enforcebans -dynamicbans -userbans -autohalfop
[23:50] <Bot> -protecthalfops -static
[23:50] <Bot> +dynamicexempts +userexempts +dynamicinvites +userinvites
[23:50] <Bot> User defined channel flags:
[23:50] <Bot> +idleDevoice -nopubstats -quietstats -nostats
[23:50] <Bot> -noseendata -quietseens -quietaiseens -nopubseens
[23:50] <Bot> flood settings: chan ctcp join kick deop nick
[23:50] <Bot> number: 15 3 5 3 3 5
[23:50] <Bot> time : 60 60 60 10 10 60
[23:50] <Bot> [05:50:01] #AnotherOp# chaninfo #channel123
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1058
Location: France

PostPosted: Wed Feb 02, 2022 7:16 am    Post subject: Reply with quote

+g is auto-voice flag (https://docs.eggheads.org/mainDocs/users.html), so it's normal the voice is enforced.

Change the bind to v|v and give your users the +v flag rather than the +g.

I did advoice script a long time before, I'll work on it to make it suit your need.

Actually, it voices any user joining or speaking (unless the user is op/halfop) and devoice idle users after a delay (global or per channel).
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
mvp1
Voice


Joined: 27 Jan 2022
Posts: 22

PostPosted: Mon Aug 01, 2022 8:59 am    Post subject: Reply with quote

Hi CrazyCat, Ceasar,

I'm using below code, it is working but it does not seem to devoice all the nicks which are sitting on voice more than idle time? When the channel is 150+ count and voiced users are 10-15, many voiced users stay voiced and do not get devoiced. Below is complete code I am using.
Voicing +V and Exception +G are working fine. But devoicing seems to have a problem or lag when there are 10-15 users sitting on voice.

Any thoughts what is going wrong? Or if something can be changed with the code?

Many thanks

Code:

namespace eval idleDevoice {

## Default idle time in minutes
   set idleTime 28
   setudef flag idleDevoice     

### Bind Cron every 5 mins ###
   
   bind cron - {*/5 * * * *} [namespace current]::idle:cron

### Bind on pub msg from V flag users

   bind pubm V|V * [namespace current]::idle:voice

### MAIN PROC ###   

   proc idle:cron {min hour day month weekday} {
      variable idleTime
      set now [clock seconds]
      foreach channel [channels] {
         if {![channel get $channel idleDevoice]} continue
         if {![botisop $channel]} continue
         foreach member [chanlist $channel] {
            if {[isbotnick $member]} continue
         
            if {[isop $member $channel] || ![isvoice $member $channel] || [matchattr [nick2hand $member] +G|+G $channel]} continue
          #  set handle [nick2hand $member $channel]
          #  if {[matchattr $handle e]} return
            set chanidle [getchanidle $member $channel]
            if {$chanidle >= $idleTime} {
               lappend userList $member
            }
         }
         
        if {[info exists userList]} {
          idle:push $channel $userList
}
      }
   }

   proc idle:voice {nick uhost hand chan text} {
      if {![botisop $chan]} return
      if {[isvoice $nick $chan]} return
      pushmode $chan +v $nick
   }
   
   proc idle:push {channel userList} {
      if {![botisop $channel]} return
      set max 3
        set len [llength $userList]
        while {$len > 0} {
         if {$len > $max} {
            set mode [string repeat "v" $max]
            set users [join [lrange $userList 0 [expr {$max - 1}]]]
            set userList [lrange $userList $max end]
            incr len -$max
         } else {
            set mode [string repeat "v" $len]
            set users [join $userList]
            set len 0
         }
            pushmode $channel -$mode $users
      }
   }
}

Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 969

PostPosted: Mon Aug 01, 2022 2:08 pm    Post subject: Reply with quote

i tested this and it seems to work for me :

Code:


namespace eval idleDevoice {

## Default idle time in minutes
   set idleTime 28
   setudef flag idleDevoice     

### Bind Cron every 5 mins ###
   
   bind cron - {*/5 * * * *} [namespace current]::idle:cron

### Bind on pub msg from V flag users

   bind pubm V|V * [namespace current]::idle:voice

### MAIN PROC ###   

   proc idle:cron {min hour day month weekday} {
      variable idleTime
      set now [clock seconds]
      foreach channel [channels] {
         if {![channel get $channel idleDevoice]} continue
         if {![botisop $channel]} continue
         foreach member [chanlist $channel] {
            if {[isbotnick $member]} continue
         
            if {[isop $member $channel] || ![isvoice $member $channel] || [matchattr [nick2hand $member] +G|+G $channel]} continue
          #  set handle [nick2hand $member $channel]
          #  if {[matchattr $handle e]} return
            set chanidle [getchanidle $member $channel]
            if {$chanidle >= $idleTime} {
               lappend userList $member
            }
         }
         
        if {[info exists userList]} {
          idle:push $channel $userList
}
      }
   }

   proc idle:voice {nick uhost hand chan text} {
      if {![botisop $chan]} return
      if {[isvoice $nick $chan]} return
      pushmode2 $chan +v $nick
   }
   
   proc idle:push {channel userList} {
      if {![botisop $channel]} return
      set max 3
        set len [llength $userList]
        while {$len > 0} {
         if {$len > $max} {
            set mode [string repeat "v" $max]
            set users [join [lrange $userList 0 [expr {$max - 1}]]]
            set userList [lrange $userList $max end]
            incr len -$max
         } else {
            set mode [string repeat "v" $len]
            set users [join $userList]
            set len 0
         }
            puthelp "mode $channel -$mode $users"
      }
   }
}






i changed the :

Quote:
pushmode $channel -$mode $users


into :

Quote:
puthelp "mode $channel -$mode $users"
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1058
Location: France

PostPosted: Tue Aug 02, 2022 3:17 am    Post subject: Reply with quote

adding a flushmode right after the pushmode is more the way it may work.
It actually works with puthelp because your eggdrop isn't too much loaded and haven't to send lot of msg, but using a message queue to send modes is not the solution.
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 969

PostPosted: Wed Aug 03, 2022 12:21 am    Post subject: Reply with quote

Hm ok CrazyCat
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 969

PostPosted: Wed Aug 03, 2022 3:36 am    Post subject: Reply with quote

this seems to work for me :

Code:


namespace eval idleDevoice {

## Default idle time in minutes
   set idleTime 28
   setudef flag idleDevoice     

### Bind Cron every 5 mins ###
   
   bind cron - {*/5 * * * *} [namespace current]::idle:cron

#Bind on pub msg from V flag users

   bind pubm V|V * [namespace current]::idle:voice

### MAIN PROC ###   

   proc idle:cron {min hour day month weekday} {
      variable idleTime
      set now [clock seconds]
      foreach channel [channels] {
         if {![channel get $channel idleDevoice] || ![botisop $channel]} continue
      foreach member [chanlist $channel] {
            if {[isbotnick $member] || [isop $member $channel] || ![isvoice $member $channel] || [matchattr [nick2hand $member] +G|+G $channel]} continue
          #  set handle [nick2hand $member $channel]
          #  if {[matchattr $handle e]} return
            set chanidle [getchanidle $member $channel]
            if {$chanidle >= $idleTime} {
               pushmode $channel -v $member
            }
         }
          flushmode $channel
      }
}

   proc idle:voice {nick uhost hand chan text} {
      if {![botisop $chan] || [isvoice $nick $chan]} return
      pushmode $chan +v $nick
      }

}



Last edited by simo on Wed Aug 03, 2022 4:11 am; edited 1 time in total
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1058
Location: France

PostPosted: Wed Aug 03, 2022 3:56 am    Post subject: Reply with quote

With a better indentation, you might have seen that the flushmode is in the wrong place.
It must be in the foreach channel loop. Actually, it flushes only for the last channel, so it may slow the application of the modes for the firsts channels in eggdrop list.
Code:
proc idle:cron {min hour day month weekday} {
   variable idleTime
   set now [clock seconds]
   foreach channel [channels] {
      if {![channel get $channel idleDevoice] || ![botisop $channel]} continue
      foreach member [chanlist $channel] {
         if {[isbotnick $member] || [isop $member $channel] || ![isvoice $member $channel] || [matchattr [nick2hand $member] +G|+G $channel]} continue
         #  set handle [nick2hand $member $channel]
         #  if {[matchattr $handle e]} return
         set chanidle [getchanidle $member $channel]
         if {$chanidle >= $idleTime} {
            pushmode $channel -v $member
         }
      }
      flushmode $channel
   }
}

_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 969

PostPosted: Wed Aug 03, 2022 4:12 am    Post subject: Reply with quote

thanks for pointing out CrazyCat i changed it in the post
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 Previous  1, 2
Page 2 of 2

 
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