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.

Category

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
B
BigToe
Halfop
Posts: 99
Joined: Thu Dec 30, 2010 4:49 pm

Category

Post by BigToe »

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/201307 ... s-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
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Give this a try.

Code: Select all

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.
B
BigToe
Halfop
Posts: 99
Joined: Thu Dec 30, 2010 4:49 pm

Post by BigToe »

Thank you caesar

I am getting this error:
[11:05] Tcl error [pubm:category]: bad option "-nocase": must be -exact, -glob, -regexp, or --
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

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

Code: Select all

switch -nocase -- $category { 
with:

Code: Select all

switch -- [string tolower $category] { 
and should work fine.
Once the game is over, the king and the pawn go back in the same box.
B
BigToe
Halfop
Posts: 99
Joined: Thu Dec 30, 2010 4:49 pm

Post by BigToe »

Hi now there are no errors but it doesnt work either
B
BigToe
Halfop
Posts: 99
Joined: Thu Dec 30, 2010 4:49 pm

Post by BigToe »

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

thank you very much for your help!!
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

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