mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2008
Posts: 19
K
Pikka bird
OP Offline
Pikka bird
K
Joined: Jan 2008
Posts: 19
below is a script I tried that does work but for some reason beyond me when it does post to a channel I have open ex. #Channel it posts to the channel using my nick and everyone can see it and they assume its me spamming. Is there some way to fix this code so it posts a tweet from my timeline without it looking like I posted it with my nick?

Also, assuming you can fix the first problem above, when it does post to the #Channel (without my nick )I need it to post it in such a way that audio alarm I have set to go off on a keyword in mirc option settings works too because right now they don't since it looks like I am posting with my nick.

btw, I am using the: ....Message(msg #Channel)option and the ....Bot Message(.msg #Channel) option did nothing for some reason.

Any help would be greatly appreciated.

mike


;Twitter Channel
;;;;;;;;;;;;;;;;;
;::Start Setup::;
;;;;;;;;;;;;;;;;;
;Edit the lines below to reflect your Twitter Application info.
alias -l consumer_key return PutYourConsumerKeyHere
alias -l consumer_secret return PutYourConsumerSecretHere
alias -l oauth_token return PutYourOauthTokenHere
alias -l oauth_token_secret return PutYourOauthTokenSecretHere
;;;;;;;;;;;;;;;
;::End Setup::;
;;;;;;;;;;;;;;;
menu * {
.Twitter Stream
..$iif($timer(mIRCTwitter),Off,On): {
if ($timer(mIRCTwitter)) {
.timermIRCTwitter off
hadd -m mIRCTwitter Status 0
}
else {
mIRCTwitter
.timermIRCTwitter -o 0 $iif($hget(mIRCTwitter,Delay),$hget(mIRCTwitter,Delay),60) mIRCTwitter
hadd -m mIRCTwitter Status 1
}
}
..SetUp
...Set Delay:hadd -m mIRCTwitter Delay $iif($$?="Enter Delay in Seconds" > 29,$!,60) | mtsave
...Set Method of Output
....Bot Message(.msg #Channel):hadd mIRCTwitter Method $network .msg $$?="Enter the Channel Name including the #prefix" | mtsave
....Message(msg #Channel):hadd mIRCTwitter Method $network msg $$?="Enter the Channel Name including the #prefix" | mtsave
....Echo(Echo -at):hadd mIRCTwitter Method echo -at | mtsave
....Window(Echo -t @Twitter):hadd mIRCTwitter Method echo -t @Twitter | mtsave
}
alias -l mIRCTwitter mTwitterGetStatus echo -a $consumer_key $consumer_secret $oauth_token $oauth_token_secret
alias mIRCTweet mTwitterUpdate echo -a $consumer_key $consumer_secret $oauth_token $oauth_token_secret $1-
;Syntax mTwitterUpdate echo -a consumer_key consumer_secret oauth_token oauth_token_secret status update here
;Note that echo -a can be changed to msg $chan or notice $nick ( must be two words )
alias -l mTwitterUpdate {
var %ots $ctime, %sockname mTwitterUpdate, %once $md5(%sockname)
var %os $signature(post,http://twitter.com/statuses/update.xml,$3,$4,$5,$6,%once,%ots,$+(status=,$tuenc($7-)))
.sockclose %sockname
sockopen %sockname twitter.com 80
sockmark %sockname $1-2 $space2comma($+(oauth_nonce=,$qt(%once)) $osmqt $+(oauth_timestamp=,$qt(%ots)) $+(oauth_consumer_key=,$qt($tuenc($3))) $&
$+(oauth_token=,$qt($tuenc($5))) $+(oauth_signature=,$qt($suenc(%os))) $overqt) $+(status=,$tuenc($7-))
}
on *:sockopen:mTwitterUpdate: {
if ($sockerr) echo -st Socket Error $nopath($script)
else {
tokenize 32 $sock($sockname).mark
sockwrite -n $sockname POST /statuses/update.xml HTTP/1.1
sockwrite -n $sockname Host: twitter.com
sockwrite -n $sockname User-Agent: Lawnmower 9.64
sockwrite -n $sockname Authorization: OAuth realm="/statuses/update.xml", $3
sockwrite -n $sockname Content-Type: application/x-www-form-urlencoded
sockwrite -n $sockname Content-Length: $len($4)
sockwrite -n $sockname
sockwrite -n $sockname $4
sockwrite -n $sockname
}
}
on *:sockread:mTwitterUpdate: {
if ($sockerr) { $gettok($sock($sockname).mark,1-2,32) Unknown Socket error $nopath($script) }
else {
var %mTwitterUpdatevar | sockread %mTwitterUpdatevar
if (HTTP/1.1 401 isin %mTwitterUpdatevar) {
$gettok($sock($sockname).mark,1-2,32) Password/Username Error --> %mTwitterUpdatevar
sockclose $sockname | return
}
elseif (HTTP/1.1 502 isin %mTwitterUpdatevar) || (HTTP/1.1 503 isin %mTwitterUpdatevar) {
$gettok($sock($sockname).mark,1-2,32) Server Busy Error --> %mTwitterUpdatevar
sockclose $sockname | return
}
elseif (HTTP/1.1 500 isin %mTwitterUpdatevar) {
$gettok($sock($sockname).mark,1-2,32) Server Side Error --> %mTwitterUpdatevar
sockclose $sockname | return
}
elseif (HTTP/1.1 403 isin %mTwitterUpdatevar) {
$gettok($sock($sockname).mark,1-2,32) Connection Actively Refused --> %mTwitterUpdatevar
sockclose $sockname | return
}
elseif (HTTP/1.1 400 isin %mTwitterUpdatevar) {
$gettok($sock($sockname).mark,1-2,32) Unknown Error --> %mTwitterUpdatevar
sockclose $sockname | return
}
elseif (HTTP/1.1 200 isin %mTwitterUpdatevar) {
$gettok($sock($sockname).mark,1-2,32) Updating Status Please Wait.........
}
elseif (</status> isin %mTwitterUpdatevar) {
.timer 1 3 $gettok($sock($sockname).mark,1-2,32) Your Status has been updated smile
sockclose $sockname | return
}
}
}
alias -l mTwitterGetStatus {
var %ots $ctime, %sockname mTwitterGetStatus, %once $md5(%sockname), %sinceid $iif($hget(mirctwitter,last_id),$v1,1)
var %os $signature(GET,http://twitter.com/statuses/home_timeline.rss,$3,$4,$5,$6,%once,%ots,$+(since_id=,%sinceid))
.sockclose %sockname
sockopen %sockname twitter.com 80
sockmark %sockname $1-2 $space2comma($+(oauth_nonce=,$qt(%once)) $osmqt $+(oauth_timestamp=,$qt(%ots)) $+(oauth_consumer_key=,$qt($tuenc($3))) $&
$+(oauth_token=,$qt($tuenc($5))) $+(oauth_signature=,$qt($suenc(%os))) $overqt $+(since_id=,%sinceid)) 1 1
}
on *:sockopen:mTwitterGetStatus: {
if ($sockerr) echo -st Socket Error $nopath($script)
else {
tokenize 32 $sock($sockname).mark
sockwrite -n $sockname GET /statuses/home_timeline.rss? $+ $+(since_id=,$iif($hget(mirctwitter,last_id),$v1,1)) HTTP/1.1
sockwrite -n $sockname Host: twitter.com
sockwrite -n $sockname User-Agent: Lawnmower 9.64
sockwrite -n $sockname Authorization: OAuth realm="/statuses/home_timeline.rss", $3
sockwrite -n $sockname Content-Type: application/x-www-form-urlencoded
sockwrite -n $sockname $crlf
}
}
On *:sockread:mTwitterGetStatus: {
if ($sockerr) { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
else {
var %mTwitterGetStatus | sockread %mTwitterGetStatus
if (<item> isin %mTwitterGetStatus) { sockmark $sockname $puttok($sock($sockname).mark,1,3,32) }
elseif ($regex(%mTwitterGetStatus,/<title>Twitter\s\/\s(.*)\swith\sfriends<\/title>/i)) hadd -m mIRCTwitter Name $+(@,$regml(1))
elseif ($gettok($sock($sockname).mark,4,32)) && ($regex(%mTwitterGetStatus,/<guid>http:\/\/twitter\.com\/.*\/statuses\/(.*?)<\/guid>/i)) {
hadd mirctwitter Last_ID $regml(1)
sockmark $sockname $puttok($sock($sockname).mark,0,4,32)
}
elseif ($gettok($sock($sockname).mark,3,32)) && ($regex(%mTwitterGetStatus,<title>(.*)</title>)) {
sockmark $sockname $puttok($sock($sockname).mark,$calc($gettok($sock($sockname).mark,5,32) + 1),5,32)
var %Method $hget(mIRCTwitter,Method), %match $regml(1)
if (%Method == echo -at) { %Method $fix&#($+(09<07,$gettok(%match,1,58),09>04) $gettok(%match,2-,58)) }
elseif ($me ison $gettok(%Method,3,32)) {
.timer 1 $gettok($sock($sockname).mark,5,32) $gettok(%Method,2-,32) $fix&#($+(09<07,$gettok(%match,1,58),09>04) $gettok(%match,2-,58))
}
else {
if (!$window(@Twitter)) { window -E @Twitter }
var %NextTweet $fix&#($+(09<07,$gettok($regml(1),1,58),09>04) $gettok($regml(1),2-,58)) 02,08[04RT02]
echo -t @Twitter %NextTweet
if ($istok(%NextTweet,$hget(mIRCTwitter,Name),32)) {
if (!$window($hget(mIRCTwitter,Name))) { window -E $hget(mIRCTwitter,Name) }
echo -t $hget(mIRCTwitter,Name) %NextTweet
noop $tip($hget(mIRCTwitter,Name),Twitter $hget(mIRCTwitter,Name),%NextTweet,60,,,,)
}
}
}
}
}
;Syntax $signature(POST/GET,URL,consumer_key,consumer_secret,oauth_token,oauth_token_secret,oauth_nonce,oauth_timestamp,PostData)
alias -l signature {
var %method $+($upper($1),&), %url $+($tuenc($2),&), %ck $tuenc&($+(oauth_consumer_key=,$3)), %ot $tuenc&($+(oauth_token=,$5))
var %once $tuenc&($+(oauth_nonce=,$7)), %ots $tuenc&($+(oauth_timestamp=,$8)), %post $iif($9-,$tuenc($+(&,$9-)))
return $hmacsha1($+($4,&,$iif($6,$6)),$+(%method,%url,%ck,%once,$tuenc&($osm),%ots,%ot,$tuenc($over),%post))
}
alias -l osm return oauth_signature_method=HMAC-SHA1
alias -l osmqt return oauth_signature_method="HMAC-SHA1"
alias -l over return oauth_version=1.0
alias -l overqt return oauth_version="1.0"
alias -l tuenc return $regsubex($replace($1-,+,$chr(32)),/([^a-z0-9._-])/ig,% $+ $base($asc(\t),10,16,2))
alias -l suenc return $regsubex($1-,/([^a-z0-9._-])/ig,% $+ $base($asc(\t),10,16,2))
alias -l space2comma return $replace($1-,$chr(32),$chr(44))
alias -l tuenc& return $tuenc($+($1,&))
;hmacsha1 by Ford_Lawnmower irc.GeekShed.net #Script-Help
;Syntax hmacsha1 key message or $hmacsha1(key,message)
alias -l hmacsha1 {
var %key $1, %data $2
bset -c &key 1 $regsubex(%key,/(.)/g, $asc(\1) $chr(32))
bset -c &data 1 $regsubex(%data,/(.)/g, $asc(\1) $chr(32))
if ($bvar(&key,0) > 64) bset -c &key 1 $hex2chr($sha1(&key,1))
bset -c &ipad 1 $xorall($str($+(54,$chr(32)),64),$bvar(&key,1-))
bset -c &opad 1 $xorall($str($+(92,$chr(32)),64),$bvar(&key,1-))
bcopy &ipad $calc($bvar(&ipad,0) + 1) &data 1 -1
bset -c &ipad 1 $hex2chr($sha1(&ipad,1))
bcopy &opad $calc($bvar(&opad,0) + 1) &ipad 1 -1
bset -c &return 1 $hex2chr($sha1(&opad,1))
noop $encode(&return, mb)
$iif($isid,return,$iif(#,say,echo -a)) $bvar(&return, 1-).text
}
alias -l hex2chr return $regsubex($1-,/(.{2})/g, $base(\t,16,10) $chr(32))
alias -l xorall {
var %p $1, %k $2, %end $iif($regex($1,/([\d]{1,})/g) > $regex($2,/([\d]{1,})/g),$v1,$v2)
return $regsubex($str(.,%end),/(.)/g,$+($xor($iif($gettok(%p,\n,32),$v1,0),$iif($gettok(%k,\n,32),$v1,0)),$chr(32)))
}
On *:input:@Twitter,$hget(mIRCTwitter,Name): {
if ($left($1,1) != /) {
haltdef
echo -t $active $+(07<09,$mid($hget(mIRCTwitter,Name),2-),07>09) $1-
mIRCTweet $1-
}
}
alias -l fix&# {
return $regsubex($replace($regsubex($1-,/\&\#([0-9]{1,});/g,$utf8(\t)),",",&,&,>,>,<,<,&#39;,',$chr(9),$chr(32)),$&
/([$\|%\[\]\}\{][^\s]*)/g,$+($chr(2),$chr(2),\t))
}
alias -l UTF8 {
if ($version >= 7) return $chr($1)
elseif ($1 < 255) { return $chr($1) }
elseif ($1 >= 256) && ($1 < 2048) { return $+($chr($calc(192 + $div($1,64))),$chr($calc(128 + $mod($1,64)))) }
elseif ($1 >= 2048) && ($1 < 65536) { return $+($chr($calc(224 + $div($1,4096))),$chr($calc(128 + $mod($div($1,64),64))),$chr($calc(128 + $mod($1,64)))) }
elseif ($1 >= 65536) && ($1 < 2097152) {
return $+($chr($calc(240 + $div($1,262144))),$chr($calc(128 + $mod($div($1,4096),64))),$chr($calc(128 + $mod($div($1,64),64))),$&
$chr($calc(128 + $mod($1,64))))
}
}
alias -l div { return $int($calc($1 / $2)) }
alias -l mod {
var %int $int($calc($1 / $2))
return $calc($1 - (%int * $2))
}
alias -l H2U { return $utf8($base($1,16,10)) }
alias -l mtsave {
if ($hget(mIRCTwitter,Status)) {
.timermIRCTwitter -o 0 $iif($hget(mIRCTwitter,Delay),$hget(mIRCTwitter,Delay),60) mIRCTwitter
}
if ($hget(mIRCTwitter)) { hsave mIRCTwitter mIRCTwitter.hsh }
}
on ^$*:HOTLINK:/^<([^<>]*)>/S:@Twitter,$hget(mIRCTwitter,Name):{
if ($1) { return }
halt
}
on ^$*:HOTLINK:/^\[RT\]/S:@Twitter,$hget(mIRCTwitter,Name):{
if ($1) { return }
halt
}
on $*:HOTLINK:/^<([^<>]*)>/S:@Twitter,$hget(mIRCTwitter,Name):{
if ($mouse.key) { editbox $active $+(@,$strip($regml(1))) }
halt
}
on $*:HOTLINK:/^\[RT\]/S:@Twitter,$hget(mIRCTwitter,Name):{
if ($mouse.key) {
noop $regex($hotline,/<([^<>]*)>(.*)\[RT\]/S)
editbox $active RT $strip($+(@,$regml(1)) $regml(2))
}
halt
}
On *:Start: {
hmake mIRCTwitter 1
if ($isfile(mIRCTwitter.hsh)) { hload mIRCTwitter mIRCTwitter.hsh | mtsave }
}
On *:Unload: {
if ($hget(mIRCTwitter)) { hfree mIRCTwitter }
if ($isfile(mIRCTwitter.hsh)) { .remove mIRCTwitter.hsh }
}

Last edited by kwiknuts; 03/11/11 07:01 PM.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
The message to a channel will always come from the nick who is running the script. You can't hide that. You can run this on a bot (another copy of mIRC) using a different nick, but it will still be coming from whatever nick is running the script.

And if they think you're spamming, then it sounds like they don't want that information sent to the channel. If that's the case, you shouldn't do so.


Invision Support
#Invision on irc.irchighway.net
Joined: Jan 2008
Posts: 19
K
Pikka bird
OP Offline
Pikka bird
K
Joined: Jan 2008
Posts: 19
Ok

So would it then be possible to add some script somewhere such that whenever it posts a tweet ( and I will just have it post it to a seperate channel of my own so others dont see it ) that it plays a wav file which would help be be alerted ?

I think its something like an SPLAY command and file location I just dont know where to put it in this script to make it work right.

thanks

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
If the intent is that only you can see the tweets, why not set "method of output" to either "echo" or "window" in the script's menu? Both should result in a local display (i.e. only visible by you). While "window" should create a dedicated window, "echo" should place the output into your currently active mIRC window.

You can add sound notifications with the splay command at:
Quote:
if (%Method == echo -at) { %Method $fix&#($+(09<07,$gettok(%match,1,58),09>04) $gettok(%match,2-,58)) | splay <soundfile> }
for "echo", all on one line,

and at:
Quote:
echo -t @Twitter %NextTweet | splay <soundfile>
for "window" respectively.

You can put a filename, or (mandatory if the soundfile isn't located in the sound directory as specified in mIRC options) a full path to a soundfile. Don't forget to enclose path\filename in quotation marks if it contains any space chars.
Note that these suggestions derive from looking at your code - I did not test it. smile

Joined: Jan 2008
Posts: 19
K
Pikka bird
OP Offline
Pikka bird
K
Joined: Jan 2008
Posts: 19
Horstl thanks for the help

Ok if I use the @Twitter window method where it opens a new window called @Twitter it does work except for the fact that the window options of setting it to desktop and on top are greyed out unlike other channels that have that option. Is there a way to make that @Twitter window able to be set to desktop and ontop outside of the mirc window so I can move it anywhere on my desktop?

Also I'd like to be able in that @Twitter window to set the time hack on it so I can see what time the tweets were posted.

thanks again

mike

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
To allow desktop-toggling of the @twitter window, add the "D" switch at:
Quote:
if (!$window(@Twitter)) { window -ED @Twitter }
You may also add the "d" switch to have it open on desktop right away, and the "o" switch to force it on top (/help /window).


Assuming that you mean mIRC timestamps by "time hack", at the current line:
Quote:
echo -t @Twitter %NextTweet
the "-t" will timestamp new lines if "timestamp events" is enabled at mIRC options > IRC > messages. However, you can force a default timestamp if you change this line to:
Quote:
echo @Twitter $timestamp %NextTweet
You may also hardcode a different timestamp format in place of $timestamp (/help $asctime).

Joined: Jan 2008
Posts: 19
K
Pikka bird
OP Offline
Pikka bird
K
Joined: Jan 2008
Posts: 19
those worked great!

as far as the:

echo -t @Twitter %NextTweet | splay <soundfile>
for "window" respectively.

my code is now:

echo @Twitter $timestamp %NextTweet | splay <C:\Program Files\mIRC\sounds\meepmeep.wav>

that doesn't work for the @Twitter window option for some reason, no sound at all

this message appears

* /splay: no such file '<C:\Program Files\mIRC\sounds\meepmeep.wav>' (line 134, remote.ini)

but the file is there

any ideas?

Last edited by kwiknuts; 04/11/11 02:32 PM.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Don't use <>'s around the path/file. Use quotation marks: ""

"c:\program files\mIRC\sounds\meepmeep.wav"


Invision Support
#Invision on irc.irchighway.net
Joined: Jan 2008
Posts: 19
K
Pikka bird
OP Offline
Pikka bird
K
Joined: Jan 2008
Posts: 19
Ok got everything working correctly now thanks.

Next fix:

At the end of each tweet in the @Twitter window this script puts a " [RT] " in bright yellow that for me is very annoying and distracting. It's clickable to make a retweet but I really dont need the capability or distractions. How in the script can I delete this? I tried rem-ing out some script but that didnt work. Just want it not to show at all.

Also where in script can I change the color of the tweet from current red to lets say yellow?

Thanks

Last edited by kwiknuts; 09/11/11 12:02 AM.
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
At this line:
Quote:
var %NextTweet $fix&#($+(09<07,$gettok($regml(1),1,58),09>04) $gettok($regml(1),2-,58)) 02,08[04RT02]
the green part is the [RT] you want to remove
the red part of ctrl-k+04 is the control code that colours your tweet text - either put a different two-digit color number, or a ctrl-o for no color

Joined: Jan 2008
Posts: 19
K
Pikka bird
OP Offline
Pikka bird
K
Joined: Jan 2008
Posts: 19
thanks Horstl those last ones worked nice.

A couple of final tweaks:

1. In mirc / display /options I have the " show line marker " set but for some reason it does not work for this @Twitter window with the tweets, but it does work for other normal channels. What can we put in the script to make the @Twitter window also set this line marker when the window has been minimized ( for when I leave then come back and want to see whats new since I left and minimized it ) ??

2. I tried playing with the font settings for this @Twitter window and it does change it using the menu for the window, but when I restart mirc the new font settings revert back to default font settings for mirc. What in the script can be changed to keep the chosen font settings for this @Twitter window?

thanks again

Mike

Last edited by kwiknuts; 13/11/11 11:01 PM.
Joined: Jan 2004
Posts: 1,361
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,361
1. Use the -m switch in the /window command which creates your @twitter window. This switch is for line markers. A list of switches for the /window command can be accessed with /help /window

2. Simply specify the font name and size after the window title in the window definition, this is also in the command documentation.

Quote:
window -EDm @Twitter Arial 12


Link Copied to Clipboard