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.

On message[solved]

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
b
blake
Master
Posts: 201
Joined: Mon Feb 23, 2009 9:42 am
Contact:

On message[solved]

Post by blake »

Hey

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.
b
blake
Master
Posts: 201
Joined: Mon Feb 23, 2009 9:42 am
Contact:

Post by blake »

I have tried the following code but its not doing anything its not even showing errors any one got any ideas how to do this

Code: Select all

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
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

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):

Code: Select all

bind msg - "*" user:message
proc user:message {nick host handle text} {
  set text [stripcodes bcruag $text]
  if {[regexp -- {Severe Warnings: ([[:alnum:][:space:][:punct:]]*?) \( ?[[:digit:]]+@severewarn.* ?\)} $text match warning]} {
    puthelp "PRIVMSG #Twitter :!tweet : $warning"
  }
}
Might have to tune the pattern depening on permitted contents of the messages.
NML_375
b
blake
Master
Posts: 201
Joined: Mon Feb 23, 2009 9:42 am
Contact:

Post by blake »

Hey

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.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

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.

Code: Select all

bind msgm - "Severe Warnings:*" user:message
proc user:message {nick host handle text} {
  set text [stripcodes bcruag $text]
  set pattern {Severe Warnings: ([[:alnum:][:space:][:punct:]]*?) \( ?[[:digit:]]+@severewarn.* ?\)}
  if {[string equal -nocase $nick "tweeter"] && [regexp -- $pattern $text match warning]} {
    puthelp "PRIVMSG #Twitter :!tweet : $warning"
  }
}
Last edited by nml375 on Sat Jul 21, 2012 4:00 pm, edited 1 time in total.
NML_375
b
blake
Master
Posts: 201
Joined: Mon Feb 23, 2009 9:42 am
Contact:

Post by blake »

Tried this its stll not sending any out put to the channel showing no errors
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Minor typo in my last post, fixed now.
(used "Severe Warning:" instead of "Severe Warnings:" in the binding)
NML_375
b
blake
Master
Posts: 201
Joined: Mon Feb 23, 2009 9:42 am
Contact:

Post by blake »

That hasnt made any difference

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
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

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.

Code: Select all

bind pubm - "% Severe Warnings:*" user:message
proc user:message {nick host handle channel text} {
  set text [stripcodes bcruag $text]
  set pattern {Severe Warnings: ([[:alnum:][:space:][:punct:]]*?) \( ?[[:digit:]]+@severewarn.* ?\)}
  if {[string equal -nocase $nick "tweeter"] && [regexp -- $pattern $text match warning]} {
    puthelp "PRIVMSG #Twitter :!tweet : $warning"
  }
}
NML_375
b
blake
Master
Posts: 201
Joined: Mon Feb 23, 2009 9:42 am
Contact:

Post by blake »

Hey

Sorry nml375 but that dont seem to be working either thanks for your help though
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

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)
NML_375
b
blake
Master
Posts: 201
Joined: Mon Feb 23, 2009 9:42 am
Contact:

Post by blake »

That has not worked :)
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Hard to say then. I assume "Tweeter" is a different eggdrop than the one running this script.
NML_375
b
blake
Master
Posts: 201
Joined: Mon Feb 23, 2009 9:42 am
Contact:

Post by blake »

They are both the same the tweeter eggdrop is running speechless burdy script both eggdrops are eggdrop v1.6.20
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

				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
Post Reply