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 

Category

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


Joined: 30 Dec 2010
Posts: 99

PostPosted: Tue Jul 09, 2013 1:10 pm    Post subject: Category Reply with quote

Hello I need your help loyal tcl fans!

I need your help with matching a text when written in a certain chat room, the text is usually in the following snytax

<Nickname> Have you been a victim of meeting malpractice? - http://www.bbc.com/capital/story/20130709-why-office-meetings-go-wrong (culture)

Which is actually the article headline, itself link and the 'category'.

I want a script that I can define for each category to which channel the line will be relayed

for example, culture would go to #culture, weather would go to #weather and Economy could go to #allfriends - so you can actually define for each category where to relay the message

I request your help dear tcl fans!!
thanxx
Back to top
View user's profile Send private message
caesar
Mint Rubber


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

PostPosted: Wed Jul 10, 2013 1:13 am    Post subject: Reply with quote

Give this a try.
Code:

bind pubm * * pubm:category

proc pubm:category {nick uhost hand chan text} {
   if {![string match -nocase $chan "#channel"]} return
   set category [string trim [lindex [split $text] end] {()}]
   switch -nocase -- $category {
      default {
         return
      }
      "culture" {
         puthelp "PRIVMSG #culture :$text"
      }
      "weather" {
         puthelp "PRIVMSG #weather :$text"
      }
      "economy" {
         puthelp "PRIVMSG #allfriends :$text"
      }
   }
}

Replace #channel with the actual channel name you get the lines.

PS: Haven't tested so reply back if you get any errors or it's not working.
_________________
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
BigToe
Halfop


Joined: 30 Dec 2010
Posts: 99

PostPosted: Wed Jul 10, 2013 5:05 am    Post subject: Reply with quote

Thank you caesar

I am getting this error:

Quote:
[11:05] Tcl error [pubm:category]: bad option "-nocase": must be -exact, -glob, -regexp, or --
Back to top
View user's profile Send private message
caesar
Mint Rubber


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

PostPosted: Wed Jul 10, 2013 7:30 am    Post subject: Reply with quote

This means you have an older version of TCL, most likely 8.4. Anyway, replace:
Code:

switch -nocase -- $category {

with:
Code:

switch -- [string tolower $category] {

and should work fine.
_________________
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
BigToe
Halfop


Joined: 30 Dec 2010
Posts: 99

PostPosted: Wed Jul 10, 2013 8:53 am    Post subject: Reply with quote

Hi now there are no errors but it doesnt work either
Back to top
View user's profile Send private message
BigToe
Halfop


Joined: 30 Dec 2010
Posts: 99

PostPosted: Wed Jul 10, 2013 9:51 am    Post subject: Reply with quote

Oh it does work - you didnt mention i should use lowercase

thank you very much for your help!!
Back to top
View user's profile Send private message
caesar
Mint Rubber


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

PostPosted: Wed Jul 10, 2013 12:01 pm    Post subject: Reply with quote

The string tolower should take care of the letter cases so should match the text without doing any changes to it.

Anyway, glad it got sorted out and it's working. Smile
_________________
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
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