Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- on daysInMonth for theDate -- returns an integer
- copy theDate to d
- set d's day to 32
- 32 - (d's day)
- end daysInMonth
- using terms from application "Colloquy"
- on process user command c with arguments for view
- if c is "itunes" then
- set itunes_active to false
- tell application "Finder"
- if (get name of every process) contains "iTunes" then
- set itunes_active to true
- end if
- end tell
- if itunes_active then
- set itunes_message to do_itunes()
- tell view to send message itunes_message with action tense
- end if
- return true
- end if
- return false
- end process user command
- end using terms from
- on do_itunes()
- set got_track to false
- tell application "iTunes"
- if player state is playing then
- set theTrack to name of the current track
- set theArtist to artist of the current track
- set playedCount to ((played count of the current track) + 1) as string
- set playdate to date added of the current track
- set got_track to true
- end if
- end tell
- set today to current date
- -- we have the track info
- if got_track then
- -- create the contents of the message
- set monthdays to daysInMonth for (playdate)
- set dayshad to (day of today) - (day of playdate)
- set monthshad to (month of today) - (month of playdate)
- if dayshad is less than 0 then
- set monthshad to monthshad - 1
- set dayshad to dayshad + monthdays
- end if
- set yearshad to (year of today) - (year of playdate)
- if monthshad is less than 0 then
- set yearshad to yearshad - 1
- set monthshad to monthshad + 12
- end if
- if yearshad is 0 then
- set yearDis to ""
- else
- if yearshad is greater than 1 then
- set yearPlu to "s"
- else
- set yearPlu to ""
- end if
- set yearDis to yearshad & " year" & yearPlu as text
- end if
- if monthshad is 0 then
- set monthDis to ""
- else
- if monthshad is greater than 1 then
- set monthPlu to "s"
- else
- set monthPlu to ""
- end if
- set monthDis to monthshad & " month" & monthPlu as text
- end if
- if dayshad is 0 then
- set dayDis to ""
- else
- if dayshad is greater than 1 then
- set dayPlu to "s"
- else
- set dayPlu to ""
- end if
- set dayDis to dayshad & " day" & dayPlu as text
- end if
- if dayDis is not "" then
- if monthDis is not "" or yearDis is not "" then
- set dayDis to " and " & dayDis
- end if
- end if
- if monthDis is not "" and yearDis is not "" then
- if dayDis is "" then
- set monthDis to " and " & monthDis
- else
- set monthDis to ", " & monthDis
- end if
- end if
- set weekTH to yearDis & monthDis & dayDis
- if weekTH is "" then
- set weekTH to "few hours"
- end if
- if length of playedCount is greater than 1 then
- set tens to text ((length of playedCount) - 1) thru (length of playedCount) of playedCount
- set tens to tens as number
- else
- set tens to playedCount as number
- end if
- if tens is greater than 10 and tens is less than 20 then
- set timeTH to playedCount & "th"
- else
- if last character of playedCount is "1" then
- set timeTH to playedCount & "st"
- else
- if last character of playedCount is "2" then
- set timeTH to playedCount & "nd"
- else
- if last character of playedCount is "3" then
- set timeTH to playedCount & "rd"
- else
- set timeTH to playedCount & "th"
- end if
- end if
- end if
- end if
- set the theContents to "is listening to \"" & theTrack & "\" by " & theArtist & " for the " & timeTH & " time in the " & weekTH & " that he's had the track."
- return theContents
- end if -- end of we have track info
- end do_itunes
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement