Could someone do the following I am looking for an on message script that will do the following when my tweeter bot shows a message from Severe Warnings my weather bot will send a tweet
This is the message on channel
<Tweeter> Severe Warnings: Severe Thunderstorm Warning for St. Louis County in MN until 10:30am CDT. #mnwx ( 226329880487403520@severewarn - 58s ago via ReadyWarn )
I want my weather bot to beable to tweet just this part of that tweet
Severe Thunderstorm Warning for St. Louis County in MN until 10:30am CDT. #mnwx
it should ignore Severe Warnings: and ( 226329880487403520@severewarn - 58s ago via ReadyWarn ) part of the message
I am using speechless burdy to send the tweet so it would send this to the channel on message
!tweet Severe Thunderstorm Warning for St. Louis County in MN until 10:30am CDT. #mnwx
obviously it wont be that everytime and sometimes Severe Thunderstorm Warning might also be Severe Tornado watch/warning
Thanks in advance
Last edited by blake on Sun Jul 29, 2012 10:25 am, edited 1 time in total.
bind msg - "*" user:message
proc user:message {nick uhost handle text dest} {
set text [stripcodes bcruag $text]
if {[string equal -nocase "tweeter" $nick] && [string match -nocase "severe warnings:*" $text]} {
putserv "PRIVMSG #Twitter : !tweet : [string trim [join [lrange [split $text {:}] 1 end]]]"
}
}
I know this will only strip the text severe warnings so if any one has any idea how to get this working and also strip ( 226329880487403520@severewarn - 58s ago via ReadyWarn ) id be great full
When using the msg binding, the proc is called with four parameters (nickname, user@host, handle, and text) - your proc expects a fifth parameter (dest). You'll have to remove that fifth one (or provide a default value for it) for it to work with your binding.
As for the more advanced parts of your request, I'd probably use regular expression matching rather than glob-based matching (string match):
I have tried that it is not doing anything at all could it be because this part is in bold Severe Warnings
this is the output
<+Tweeter> Severe Warnings: Severe Thunderstorm Warning for Johnston, Sampson, and Wayne County in NC until 4:45pm EDT. #ncwx ( 226763682313539584@severewarn - 11s ago via ReadyWarn )
Last edited by blake on Sat Jul 21, 2012 3:44 pm, edited 1 time in total.
Control-codes such as bold would be stripped using the stripcodes command.
I've successfully tested the regexp pattern against the string you posted.
One thing that strikes me now though, is that you are using a msg binding, not an msgm binding. You can't use wildcards with msg bindings, and the "command" part is only matched against the first word spoken. You'll need msgm instead.
it still isnt outputting anything to the channel when it sees
<+Tweeter> Severe Warnings: Severe Thunderstorm Warning for Johnston, Sampson, and Wayne County in NC until 4:45pm EDT. #ncwx ( 226763682313539584@severewarn - 11s ago via ReadyWarn )
this is also on the channel #twitter its not being sent via private message its a channel message
Well, if it's sent to a channel, you need the pubm binding, not the msg or msgm bindings... Which also means that the proc has to be modified to take the new set of parameters.
I roughly recall channel text being stripped of any control characters prior being matched, but just in case I'm wrong; try replacing the mask in the binding with just "*"
(bind pubm - "*" user:message)
if {![isbotnick $nick]} {
if {![info exists skip]} {
putserv "$to :$tt" ; set sp 0
}
} else {
if {[string equal -nocase "friends" $type]} {
if {($twitter($tuser,lastidf) < $id && ![string equal -nocase $screen $tuser]) || ($twitter($tuser,lastidf) == $id && [info exists sp] && ![string equal -nocase $screen $tuser])} {
if {![info exists skip]} {
# ---> code added starts here - automations should retweet
# is the user that just tweeted the one we want?
if {[string equal -nocase "severewarn" $screen]]} {
# yes - set query with id to retweet
set q [list [list id $id]]
# map url with id of tweet to retweet
set rt [string map [list "%id%" "$id"] $twitter(retweet)]
# issue retweet - silently
if {[catch {set rtt [proc:twitter:oauth $rt POST $chan $q]} error]} { putlog "$twitter(logo) Auto-Retweet: $error" }
}
# <--- code added ends here
putserv "$to :$tt" ; set sp 0
}
if {![info exists pure]} {
set twitter($tuser,lastidf) $id
set pure 0
}
}
} else {
You can do this all within birdy itself by a slight hack. This will allow it to detect when its running its friends automation, and during the initial spew of this check if it should "retweet" the message if it matches your pattern. Hopefully you can understand the code above enough to understand how to hack it in. The procedure you want to do this in is called, proc:twitter:restapi. This is more natural, a retweet of something like this, than taking the tweet and claiming it for your own. Consider this a more ethical approach to what you want to do.
Note: This requires you have issued .. +follow severewarn .. and they have not blocked you, this will then retweet every single one of their tweets into your own timeline. If you want it more refined or something, let me know. ;D