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.

write a message, depending on the number of lines written

Help for those learning Tcl or writing their own scripts.
Post Reply
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

write a message, depending on the number of lines written

Post by juanamores »

I want the bot to write a message, depending on the number of lines written in the channel.
You can individually configure the channels for this action?
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks :)
w
willyw
Revered One
Posts: 1205
Joined: Thu Jan 15, 2009 12:55 am

Re: write a message, depending on the number of lines writte

Post by willyw »

juanamores wrote:I want the bot to write a message, depending on the number of lines written in the channel.
You can individually configure the channels for this action?
How about a protection script? One that watches for 'flooding' by number of lines posted?

For example, AllProtection can be configured to just warn.
Edit that warning, and wouldn't that do what you want?
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Re: write a message, depending on the number of lines writte

Post by juanamores »

Is There some more specific snippet?
I need my bot radio advertising write songs that are broadcast on channel activity.
There is a time of night that the channels are not active and what I want is that if no one writes, the bot no more type advertising on that channel.
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks :)
w
willyw
Revered One
Posts: 1205
Joined: Thu Jan 15, 2009 12:55 am

Re: write a message, depending on the number of lines writte

Post by willyw »

Ah. Ok.
That's different from what I originally thought you wanted.

Using the tcl command getchanidle and a foreach loop iterating through a list of nicks currently in the channel, it shouldn't be too difficult to write a tcl script that can determine if no user has spoken in the channel for more than x minutes. I suppose you would want to do this check often, and that could be controlled by a cron bind.

As to how you would integrate this determination with your current script that is doing the announcements now - we'd have to examine that script and perhaps you would have to modify it too.

If you know some TCL, have a look here:
http://www.eggheads.org/support/egghtml ... mands.html
and text search it for
getchanidle

Perhaps someone else will come along with another idea for you too.
What I have mentioned above is just the first thing that came to my mind.
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
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

I might go about this somewhat differently.

Make a small script that will keep track of the idleness of the channel.
I would do this by simply storing the timestamp of the last post to the channel, in a global variable...

Code: Select all

# Set the channel to monitor #
set wasidle(chan) "#sumchan"

# Set the time (in minutes) for the channel to be considered idle #
set wasidle(time) "15"

#### END OF SETTINGS ####

bind pubm - "* $wasidle(chan)" was:idle

# force this eggdrop conf setting to be disabled #
set exclusive-binds 0

# convert minutes to seconds, and save result #
set wasidle(time) [expr {$wasidle(time) * 60}]

if {![info exists wasidle(lastut)]} { set wasidle(lastut) [unixtime] }

proc was:idle {nk uh hn ch tx} {
  global wasidle
  set wasidle(lastut) [unixtime]
  return 0
}

Then, at the top of the process that does not want to continue if the channel is idle, I might add something like this...

Code: Select all

  global wasidle
  if {[info exists wasidle(lastut)]} {
    if {([unixtime]-$wasidle(lastut)) > $wasidle(time)} { return 0 }
  }

NOTE: the exact code to add to the process, and where to add it, may differ depending on the fine points of the existing code.
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Post by juanamores »

SpiKe^^ It's an intelligent way to solve the problem but... is there any way to consider idle when other bots writes ?
The idea lies in to except nicks from those bots because what I want the bot to publish advertisments if nobody user (human) is writting.
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks :)
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Maybe this is closer to what you were looking for.
You will need to make sure the other bots are added to this bot and have the b flag.

Code: Select all

# Set the channel to monitor #
set wasidle(chan) "#sumchan"

# Set the time (in minutes) for the channel to be considered idle #
set wasidle(time) "15"

# Set userfile flags to be exempt from idle monitoring #
# note: set this empty to not exempt anyone #
set wasidle(exempt) "b|b"

#### END OF SETTINGS ####

bind pubm - "$wasidle(chan) *" was:idle

# force this eggdrop conf setting to be disabled #
set exclusive-binds 0

# convert minutes to seconds, and save result #
set wasidle(time) [expr {$wasidle(time) * 60}]

if {![info exists wasidle(lastut)]} { set wasidle(lastut) [unixtime] }

proc was:idle {nk uh hn ch tx} {
  global wasidle
  if {$wasidle(exempt) eq "" || ![matchattr $hn $wasidle(exempt) $ch]} {
    set wasidle(lastut) [unixtime]
  }
  return 0
}

Note: edited the above bind pubm line to now be correct.

You will still need to modify the existing script(s) as above.
Last edited by SpiKe^^ on Thu Nov 05, 2015 6:54 pm, edited 2 times in total.
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Post by juanamores »

A couple of questions, my friend...

1) May I add bots that are not of my property in my bot and give them b flag bearing in mind they are not going to identify with my bot ?
My bot is in many channels where you can find other bots that are not mine.

2) Could you tell me the command to give them the b flag ?

3) How can I set multiples channels?

Thank you for your attention my friend :)
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks :)
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

juanamores wrote:1) May I add bots that are not of my property in my bot and give them b flag...
Yes, I don't think that really makes any difference.
In your case though, I think I would maybe use a custom exempt flag, that can be any upper case letter.
Example: set wasidle(exempt) "E|E"
In dcc chat with your bot, do:
.help adduser
.help chattr
juanamores wrote:...bearing in mind they are not going to identify with my bot ?
The bot doesn't require any sort of "identify" in order for it to know a properly added user/bot in its userfile.
Users/bots are recognized any time they match one of the host masks added for that user/bot.
If the user/bot has a change of username or host, you may need to add a new host mask so the bot knows who they are.
In dcc chat with your bot, do:
.help +host
juanamores wrote:2) Could you tell me the command to give them the b flag ?
You really need to learn some about how to properly operate eggdrop bots.
In dcc chat with your bot, do:
.help +bot
Doing: .+bot botnick :will add a bot to the userfile, with the b flag and a host mask if the new bot is on a channel with your bot.
juanamores wrote:3) How can I set multiples channels?
The script as wrote above, is a single channel script.
Do you really have more than one channel that you need to pause ads when they go idle?
Let me know if you do, and maybe I can make it more multichannel capable.
Multichannel will make the edits in the pausing script(s) much harder for you to figure out:)
It may be best for you to post the script you are currently wanting to work with.
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Post by juanamores »

Thank SpiKe^^ :D
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks :)
Post Reply