| View previous topic :: View next topic |
| Author |
Message |
BigToe Halfop
Joined: 30 Dec 2010 Posts: 99
|
Posted: Tue Jul 09, 2013 1:10 pm Post subject: Category |
|
|
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 |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Wed Jul 10, 2013 1:13 am Post subject: |
|
|
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 |
|
 |
BigToe Halfop
Joined: 30 Dec 2010 Posts: 99
|
Posted: Wed Jul 10, 2013 5:05 am Post subject: |
|
|
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 |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Wed Jul 10, 2013 7:30 am Post subject: |
|
|
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 |
|
 |
BigToe Halfop
Joined: 30 Dec 2010 Posts: 99
|
Posted: Wed Jul 10, 2013 8:53 am Post subject: |
|
|
| Hi now there are no errors but it doesnt work either |
|
| Back to top |
|
 |
BigToe Halfop
Joined: 30 Dec 2010 Posts: 99
|
Posted: Wed Jul 10, 2013 9:51 am Post subject: |
|
|
Oh it does work - you didnt mention i should use lowercase
thank you very much for your help!! |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Wed Jul 10, 2013 12:01 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
|