From Time to Time, mostly after a Netsplit or a Q Bot Update a Channel Topic will not be set again, so there is no topic anymore.
In cases like that its needed to set the Topic manually back to what it was before.
Well, i am looking for a Quakenet script, that is doing this automatically.
- Check, in intervals, if Topc is set...
- If not, just set it back to the last, current one
Would be great if any could help me with that. Thanks a lot
bind time - "00 * * * *" change:topic
set temp(topic) "topic goes here"
set temp(chan) "#channel"
proc change:topic {min hour day month year} {
global temp
if {[onchan $::botnick $temp(chan)]} {
putserv "TOPIC $temp(chan) :I will refresh the topic"
utimer 5 [list putserv "TOPIC $temp(chan) :$temp(topic)"]
}
}
It will refresh the topic with the topic set at temp(topic) every hour at minute 00. Of course the script can be made to save the topics using specified commands on IRC so you wont need to edit the .tcl but that is something else. This is the simple version.
Problem is that i´m having a script with what i set special parts of the Topic.
So its needed that the script just checks if there is a topic set and if not set it.
So the Topic should be taken from the channel and saved in a txt File
Every Script i found in archive just does a refresh every X minutes, but´s not what i am looking for...
# July 28, 2013
# http://forum.egghelp.org/viewtopic.php?t=19487
# This script is VERY basic. Has no checking in it. For file, to see if bot is even on channel, to see if bot is op'd, etc.
# If it suits your needs, you might like to edit those things in.
# Name your channel here
set topic_chan "#eggdrop"
# path and filename of the file to hold the topic line
# Be sure this file exists - there is no checking for it in the script!
# The easy way: let the script create it. Load the script, change the topic as you would normally, then check for existence of the file, and its contents.
set topic_file "scripts/added/experiment_for_somebody/topic_file.txt"
# Here you can change the frequency that script checks to see if topic exists
# ref: http://www.eggheads.org/support/egghtml/1.6.21/tcl-commands.html
# ref: http://ss64.com/bash/crontab.html
bind cron - "0,10,20,30,40,50 * * * *" checktopic
bind topc - "$topic_chan *" savenewtopic
proc checktopic {min hour day month weekday} {
global topic_chan topic_file
if {[topic $topic_chan] == ""} {
#reference: http://forum.egghelp.org/viewtopic.php?t=6885
set fname $topic_file
set fp [open $fname "r"]
set data [read -nonewline $fp]
close $fp
putserv "topic $topic_chan :$data"
}
}
proc savenewtopic {nick uhost handle chan topic} {
global topic_file
if {$topic == ""} {
return 0
}
#reference: http://forum.egghelp.org/viewtopic.php?t=6885
set fname $topic_file
set fp [open $fname "w"]
puts $fp [topic $chan]
close $fp
}
Tested briefly, and seemed to work. That is, if I understood what you wanted.
just create a user defined flag like topic or whatever you want and write/read it from there?
If you are -
I suppose I never thought of it, because he asked for it to be a file.
As long as he doesn't have some other specific reason that requires use of a file, then yours is an interesting idea.
Also, if he's having this topic issue, shouldn't this be fixed for all channels?
He didn't ask for it to be multi-channel, but that would be the next step.
Might you want to also include a channel flag, so that it can be enabled/disabled via .chanset, on a channel-by-channel basis?
I was just trying some refresh Script and most of them used Files where the topics have been stored. And because i dont know TCL i thought that might be a good idea. But hey i have really no idea.
It would be great to have it multi channel supporting.
And yes if you dont mind, an option to turn it off/on via .chanset? would gorgeous.
ceasar´s is working well. It would be nice to have a possibility to turn it on off for channels
@willyw: Your´s also storing the topic, had forgotten to op the Bot, my fault :/
Maybe a check would be nice if the bot has op and if not an output to channel that the bot need op in order to work proper?!
Buts not adding the topic back. From what i see the cron should start after 10 mins?
Carefully examine your configuration of:
set topic_file
as it must be incorrect.
From the .jpg that you posted, I will venture that you need to include a leading / , if you wish you to use absolute paths.
If you wish to use relative paths, then it looks like it might be:
scripts/db/topicrefresh.db
Tcl error [topc_topicme]: wrong # args: should be "checktopic min hour day month weekday"
What is [topc_topicme] ?
As for that error, all I can say is that when I run the script it does not appear.
If you would like to post a copy of the script exactly as you are using it now, I'll see what I can see. Others may too.
Maybe something that reminds me/or channel message, to op the bot
Do:
.help chaninfo
and read about need-op
You could put a command in there to have the bot send you a private message, when it detects that it is not op'd.
and an option for different channels would be great.
I like caesar's method better than mine. Let's wait for him to respond here, as he will probably just need to include something to make an On/Off switch on a channel-by-channel basis, to have everything you wanted.
Sorry for being confusing.
No problem at all. Communication is the key, and that's what forum's are for.