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

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
a41
Voice


Joined: 15 Feb 2018
Posts: 8

PostPosted: Thu Feb 15, 2018 8:01 pm    Post subject: Auto Voice System Reply with quote

I have been in search of specific requirement for a script that can do the following.

- Add a user to an auto-voice list.
- Voice user on join which is in the list.
- De-voice inactive user after 60 minutes.
- Voice the user when it becomes active (from the list)

I have searched a lot but was unable to find that would do this from the list of users.

I am not good in TCL so any help would be really appreciated.

xox
Back to top
View user's profile Send private message
caesar
Ass Kicker


Joined: 14 Oct 2001
Posts: 3488
Location: Area 51

PostPosted: Fri Feb 16, 2018 3:14 am    Post subject: Reply with quote

What do you mean by "Add a user to an auto-voice list." ? You do this or the bot dose it based on an action or something? The rest is easy peasy.
_________________
You may say anything about me, but at least don't misspell my name. xD
Back to top
View user's profile Send private message
a41
Voice


Joined: 15 Feb 2018
Posts: 8

PostPosted: Fri Feb 16, 2018 1:00 pm    Post subject: Reply with quote

like !autovoice nick
that it maintains a list of users that will get voice. not everyone.
Back to top
View user's profile Send private message
caesar
Ass Kicker


Joined: 14 Oct 2001
Posts: 3488
Location: Area 51

PostPosted: Mon Feb 19, 2018 2:09 am    Post subject: Reply with quote

Two questions:

1. In what format should the host-mask of the user you want to add to this list should be like?

2. Want to create a user and add hosts there or want to maintain a list? Easiest would be adding hosts to a specific auto-voice user, else would have to create the saving function so the list would be maintained upon a restart or killing the bot for whatever reason and starting it back.
_________________
You may say anything about me, but at least don't misspell my name. xD
Back to top
View user's profile Send private message
a41
Voice


Joined: 15 Feb 2018
Posts: 8

PostPosted: Mon Feb 19, 2018 2:51 pm    Post subject: Reply with quote

THe userlist should be maintained so incase the bot restarts or get offline. It still works.

I think a simplest way is to user Bot user list with +g for autovoice. I maybe wrong, this way the list will be maintained.

Logically i think if idle time is checked and if the user is in the list with +g (autovoice) it should give voice back to an active user.

I have seen autovoice scripts on join but a user already in channel but devoiced, this should give voice back once the user become active.

That is what I am trying to achieve in this.
Back to top
View user's profile Send private message
caesar
Ass Kicker


Joined: 14 Oct 2001
Posts: 3488
Location: Area 51

PostPosted: Tue Feb 20, 2018 9:07 am    Post subject: Reply with quote

Code:

namespace eval idleDevoice {

   # Default idle time in minutes
   set idleTime 60

   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 &g] {
            if {[isbotnick $member]} continue
            if {[isop $member $channel] || ![isvoice $member $channel]} continue
            set chanidle [getchanidle $member $channel]
            if {$chanidle >= $idleTime} {
               lappend userList $member
            }
         }
         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
      }
   }
}

Haven't tested anything cos don't have the time nor the possibility at the moment to test stuff out.

Edit: Fixed an error.
_________________
You may say anything about me, but at least don't misspell my name. xD


Last edited by caesar on Tue Feb 20, 2018 2:45 pm; edited 1 time in total
Back to top
View user's profile Send private message
a41
Voice


Joined: 15 Feb 2018
Posts: 8

PostPosted: Tue Feb 20, 2018 12:36 pm    Post subject: Reply with quote

thank you! i will test and see what I find out.
Back to top
View user's profile Send private message
caesar
Ass Kicker


Joined: 14 Oct 2001
Posts: 3488
Location: Area 51

PostPosted: Tue Feb 20, 2018 2:46 pm    Post subject: Reply with quote

The:
Code:

if {![isvoice $nick $chan]} return

should have been without ! like
Code:

if {[isvoice $nick $chan]} return

meaning if nick is already voiced we don't try to voice them again.

Edit: Oh, and forgot to mention in first post that you have to set the channels where you want this to be active with: .chanset #channel +idleDevoice

For testing purposes should set the idleTime to a few minutes to see if things work or not.
_________________
You may say anything about me, but at least don't misspell my name. xD
Back to top
View user's profile Send private message
a41
Voice


Joined: 15 Feb 2018
Posts: 8

PostPosted: Wed Feb 28, 2018 6:05 pm    Post subject: Reply with quote

This is the error I got.

Tcl error [::idleDevoice::idle:cron]: can't read "userList": no such variable
Back to top
View user's profile Send private message
caesar
Ass Kicker


Joined: 14 Oct 2001
Posts: 3488
Location: Area 51

PostPosted: Thu Mar 01, 2018 1:53 am    Post subject: Reply with quote

Ah, right. Replace the:
Code:

idle:push $channel $userList

line with:
Code:

if {[info exists userList]} {
   idle:push $channel $userList
}

_________________
You may say anything about me, but at least don't misspell my name. xD
Back to top
View user's profile Send private message
a41
Voice


Joined: 15 Feb 2018
Posts: 8

PostPosted: Fri Mar 02, 2018 6:29 pm    Post subject: Reply with quote

I am running it and it works fine. There are a few things that I have noticed.

- It does not devoice a user for 60 minutes that is not in list. (means any manually voiced user stays voiced)

- Is there a way to add exclusion for devoice for certain nicks?

thanks for your help.
Back to top
View user's profile Send private message
caesar
Ass Kicker


Joined: 14 Oct 2001
Posts: 3488
Location: Area 51

PostPosted: Sat Mar 03, 2018 2:33 am    Post subject: Reply with quote

Was under impression that only the users that are in that special voiced user should be voiced/devoiced. We can easily fix this by changing this line:
Code:

foreach member [chanlist $channel &g] {

to this:
Code:

foreach member [chanlist $channel] {

As for nick exclusions that's easy, we add this function:
Code:

proc idle:nick {nick} {
   set skip [list "user_1" "user_2" "user_3" "and so on"]
   if {[isbotnick $nick] || [expr [lsearch -nocase $skip $nick]] > -1} return 0
   return 1
}

at the end of the code but still inside the last }, and then before:
Code:

set chanidle [getchanidle $member $channel]

add:
Code:

if {[idle:nick $member]} continue

If you want those nick exclusions to be different for each channel or editable "online" (meaning not having to edit the tcl file and rehash the bot) then need to change things a bit. Just let me know if it's the case.
_________________
You may say anything about me, but at least don't misspell my name. xD
Back to top
View user's profile Send private message
a41
Voice


Joined: 15 Feb 2018
Posts: 8

PostPosted: Sun Mar 04, 2018 12:50 am    Post subject: Reply with quote

Devoice works but adding the exclusion portion producing this error

Tcl error [::idleDevoice::idle:cron]: invalid command name "0"
Back to top
View user's profile Send private message
a41
Voice


Joined: 15 Feb 2018
Posts: 8

PostPosted: Sun Mar 04, 2018 2:17 am    Post subject: Reply with quote

I had to remove the user exclusion as everything stopped working other than voicing a user. Devoice stopped working.
Code:



namespace eval idleDevoice {

   # Default idle time in minutes
   set idleTime 60

   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 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
      }
   }
}
Back to top
View user's profile Send private message
caesar
Ass Kicker


Joined: 14 Oct 2001
Posts: 3488
Location: Area 51

PostPosted: Mon Mar 05, 2018 2:38 am    Post subject: Reply with quote

Ah, in that case replace the idle:nick function with:
Code:

proc idle:nick {nick} {
   set skip [list "user_1" "user_2" "user_3" "and so on"]
   set test [expr {[lsearch -nocase $skip $nick] > -1 ? "1" : "0"}]
}

and instead of the:
Code:

if {[idle:nick $member]} continue

add:
Code:

if {[isbotnick $nick] || [idle:nick $member]} continue

inside that foreach loop.
_________________
You may say anything about me, but at least don't misspell my name. xD
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
Page 1 of 1

 
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