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 

Quakenet, no Topic, Script checks and set Topic
Goto page 1, 2  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
Fraud
Op


Joined: 19 May 2008
Posts: 101

PostPosted: Sun Jul 28, 2013 8:31 am    Post subject: Quakenet, no Topic, Script checks and set Topic Reply with quote

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
Back to top
View user's profile Send private message
Madalin
Master


Joined: 24 Jun 2005
Posts: 310
Location: Constanta, Romania

PostPosted: Sun Jul 28, 2013 12:48 pm    Post subject: Reply with quote

You can try this code

Code:

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.
_________________
https://github.com/MadaliNTCL - To chat with me: https://tawk.to/MadaliNTCL
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Fraud
Op


Joined: 19 May 2008
Posts: 101

PostPosted: Sun Jul 28, 2013 12:54 pm    Post subject: Reply with quote

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...
Back to top
View user's profile Send private message
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1175

PostPosted: Sun Jul 28, 2013 3:50 pm    Post subject: Reply with quote

Code:

# 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.
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Mon Jul 29, 2013 1:18 am    Post subject: Reply with quote

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:

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.
Back to top
View user's profile Send private message
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1175

PostPosted: Mon Jul 29, 2013 1:07 pm    Post subject: Reply with quote

caesar wrote:
Why don't you



Are you addressing me?

Quote:

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.

Quote:

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

Might you want to also include a channel flag, so that it can be enabled/disabled via .chanset, on a channel-by-channel basis?
Back to top
View user's profile Send private message
Fraud
Op


Joined: 19 May 2008
Posts: 101

PostPosted: Mon Jul 29, 2013 2:33 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1175

PostPosted: Mon Jul 29, 2013 2:45 pm    Post subject: Reply with quote

Fraud wrote:
Hey Guys.
...



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

Smile
Back to top
View user's profile Send private message
Fraud
Op


Joined: 19 May 2008
Posts: 101

PostPosted: Mon Jul 29, 2013 2:54 pm    Post subject: Reply with quote

Did not tested them right now. Sorry, wanted to reply first.
Back to top
View user's profile Send private message
Fraud
Op


Joined: 19 May 2008
Posts: 101

PostPosted: Mon Jul 29, 2013 3:02 pm    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1175

PostPosted: Mon Jul 29, 2013 3:36 pm    Post subject: Reply with quote

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


Quote:


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
Back to top
View user's profile Send private message
Fraud
Op


Joined: 19 May 2008
Posts: 101

PostPosted: Mon Jul 29, 2013 3:41 pm    Post subject: Reply with quote

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.

Quote:
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
Back to top
View user's profile Send private message
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1175

PostPosted: Mon Jul 29, 2013 3:52 pm    Post subject: Reply with quote

Fraud wrote:
Made mistakes,




Welcome to the human race.
Smile

Quote:

Both are working fine.


Good to know.

Quote:

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.

Quote:

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.

Quote:

Sorry for being confusing.


No problem at all. Communication is the key, and that's what forum's are for.
Smile
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Tue Jul 30, 2013 1:37 am    Post subject: Reply with quote

Code:

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.
_________________
Once the game is over, the king and the pawn go back in the same box.


Last edited by caesar on Thu Aug 08, 2013 9:20 am; edited 2 times in total
Back to top
View user's profile Send private message
Fraud
Op


Joined: 19 May 2008
Posts: 101

PostPosted: Thu Aug 08, 2013 8:19 am    Post subject: Reply with quote

I do get this error
Quote:

Tcl error [topic:save]: wrong # args: no script following "[channel get $chan saveTopic]" argument
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 1, 2  Next
Page 1 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