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.

Quakenet, no Topic, Script checks and set Topic

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
F
Fraud
Op
Posts: 101
Joined: Mon May 19, 2008 7:57 am

Quakenet, no Topic, Script checks and set Topic

Post by Fraud »

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
User avatar
Madalin
Master
Posts: 310
Joined: Fri Jun 24, 2005 11:36 am
Location: Constanta, Romania
Contact:

Post by Madalin »

You can try this code

Code: Select all

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.
F
Fraud
Op
Posts: 101
Joined: Mon May 19, 2008 7:57 am

Post by Fraud »

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...
w
willyw
Revered One
Posts: 1200
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

Code: Select all

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

I hope this helps.
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Why don't you just create a user defined flag like topic or whatever you want and write/read it from there?

Also, if he's having this topic issue, shouldn't this be fixed for all channels?

Code: Select all

bind cron - {?0*} topic:check
bind topc - * topic:save
setudef str topic

proc topic:check {min hour day month weekday} { 
	foreach chan [channels] {
		if {![string length [topic $chan]]} {
			topic:restore $chan
		}
	}
}

proc topic:save {nick uhost hand chan topic} {
	channel set $chan topic $topic
}

proc topic:restore {chan} {
	if {![botisop $chan]} return
	set topic [channel get $chan topic]
	if {![string lengtht $topic]} return
	puthelp "TOPIC $chan $topic"
}
Haven't tested so let me know if you get any errors.
Once the game is over, the king and the pawn go back in the same box.
w
willyw
Revered One
Posts: 1200
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

caesar wrote:Why don't you
Are you addressing me?
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?
F
Fraud
Op
Posts: 101
Joined: Mon May 19, 2008 7:57 am

Post by Fraud »

Hey Guys.
Well seems i forget a bit.

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.

Appreciated
w
willyw
Revered One
Posts: 1200
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

Fraud wrote:Hey Guys.
...

You forgot to say how both of the above worked, when you carefully tested them separately.

:)
F
Fraud
Op
Posts: 101
Joined: Mon May 19, 2008 7:57 am

Post by Fraud »

Did not tested them right now. Sorry, wanted to reply first.
F
Fraud
Op
Posts: 101
Joined: Mon May 19, 2008 7:57 am

Post by Fraud »

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?
w
willyw
Revered One
Posts: 1200
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

Fraud wrote:Ok yours is causing an error

Tcl error [savenewtopic]: couldn't open "home/eggdrop/myEggdrop/scripts/db/topicrefresh.db": no such file or directory
...
http://abload.de/image.php?img=unbenannt43yj2.jpg

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

Use this pastebin: http://paste.tclhelp.net/
Last edited by willyw on Mon Jul 29, 2013 3:41 pm, edited 1 time in total.
F
Fraud
Op
Posts: 101
Joined: Mon May 19, 2008 7:57 am

Post by Fraud »

Made mistakes, just rehased the bot, after a restart it works all fine.


Both are working fine.

Maybe something that reminds me/or channel message, to op the bot and an option for different channels would be great.

Sorry for being confusing.
21:43.29 .•• me changed the topic to
21:49.31 .•• myBot changed the topic to Test Test test
Tell me if i can leave a donation
w
willyw
Revered One
Posts: 1200
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

Fraud wrote:Made mistakes,

Welcome to the human race.
:)
Both are working fine.
Good to know.
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.
:)
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Code: Select all

bind cron - {?0*} topic:check
bind topc - * topic:save
setudef str topic
setudef flag saveTopic

proc topic:check {min hour day month weekday} {
	foreach chan [channels] {
		if {![channel get $chan saveTopic]} continue
		if {![string length [topic $chan]]} {
			topic:restore $chan
		}
	}
}

proc topic:save {nick uhost hand chan topic} {
	if {[channel get $chan saveTopic]} {
		channel set $chan topic $topic
	}
}

proc topic:restore {chan} {
	if {![botisop $chan]} return
	set topic [channel get $chan topic]
	if {![string lengtht $topic]} return
	puthelp "TOPIC $chan $topic"
}
Just enable/disable it with .chanset #channel +saveTopic or -saveTopic

Edit: fixed.
Last edited by caesar on Thu Aug 08, 2013 9:20 am, edited 2 times in total.
Once the game is over, the king and the pawn go back in the same box.
F
Fraud
Op
Posts: 101
Joined: Mon May 19, 2008 7:57 am

Post by Fraud »

I do get this error
Tcl error [topic:save]: wrong # args: no script following "[channel get $chan saveTopic]" argument
Post Reply