From 84372efec291c3576f8d5bd79ffc7fbf648b5e8d Mon Sep 17 00:00:00 2001 From: Turbosmurfen <59809061+turbosmurfen@users.noreply.github.com> Date: Mon, 29 Jan 2024 17:02:17 +0100 Subject: [PATCH] Added Artist and Title and volume control removal Added Artist and Title. Removed volume controls because they changed the master volume. Added an updated beta version of spoton.mrc. --- README.md | 21 ++++----- spoton.mrc | 62 ++++++++++++------------- spoton/Main.cpp | 121 +++++++++++++++++++++++++++++++----------------- 3 files changed, 115 insertions(+), 89 deletions(-) diff --git a/README.md b/README.md index 6a77855..2304ed2 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,6 @@ # Spoton - Spotify Now Playing for mIRC -**Version 1.1.5 and newer fixes a memory leak, updating is highly recommended.** - ![Spoton on mIRC 7.67](https://github.com/turbosmurfen/spoton/blob/main/img/spoton_example.png) Spoton running on mIRC 7.67 @@ -16,9 +14,9 @@ Spoton running on mIRC 7.67 * **Supported Operating System**: Windows Vista, 7, 8.1, 10 and 11. * **Visual C++ Redistributable 2015-2022 (x86)** -* **Tested mIRC version**: 7.61 >= 7.72 -* **Tested Spotify Version**: 1.1.91 >= 1.1.99 -* **Harddrive Space**: 17,5 KB. +* **Tested mIRC version**: 7.61 >= 7.76 +* **Tested Spotify Version**: 1.1.91 >= 1.2.29 +* **Harddrive Space**: 18,5 KB. # Installation @@ -47,6 +45,8 @@ Use: _$dll(pathtospoton\spoton.dll,**command**,)_ | status | 2 | Spotify is playing advertisement. | | status | 3 | Spotify is playing a song. | song | artist - title | Will output artist and title. | +| artist | artist | Will output the artist. (if text contains " - ") | +| title | title | Will output the title. (if text contains " - ") | ### Controlling Spotify from mIRC @@ -54,16 +54,15 @@ Use: _/dll pathtospoton\spoton.dll control **command**_ | Command |Description | | --- | --- | -| playpause | Plays or Pause the track. | +| playpause | Plays or Pauses the track. | +| play | Plays the track. | +| pause | Pauses the track. | | stop | Stops the playing track. | | replay | Play the track from the beginning. | | next | Play next track. | | previous | Play previous track. | | forward | Forward the current track. | | rewind | Rewind the current track. | -| volup | Increase the volume in Spotify. | -| voldown | Decrease the volume in Spotify. | -| volmute | Mute or Unmute Spotify volume. | ### Send current song to chat @@ -117,7 +116,3 @@ I have learned more about making mIRC reading and writing for DLL-file from [Wik Thanks to [@Westor](https://github.com/westor7) for helping me out with fixing vulnerables and other things in the mIRC Beta Addon for Spoton. Thanks to [@moobsmc](https://github.com/moobsmc) for Stop Control for Spotify. Thanks to [@Madis0](https://github.com/Madis0) for helping me with the readme and other things. - -# Future for Spoton - -I want to thanks everyone that have helped me and also have tested Spoton from beta stage and upon latest version of Spoton. I have put my time on other things than learning me C++. And I want to say that I no longer is going to update Spoton. If someone else want to update Spoton or use it's code, feel free to do that. diff --git a/spoton.mrc b/spoton.mrc index 6553c46..979528a 100644 --- a/spoton.mrc +++ b/spoton.mrc @@ -1,25 +1,22 @@ -;Welcome to SpotOn mIRC Addon. Since this is only in beta. -;You could not do so much. I'm not a good MSL coder, so this is the result in beta. -; -; This addon works best with Spoton 1.1.0 or later. +;Welcome to Spoton mIRC Addon. Beta 0.0.2. +;This addon works best with Spoton 1.1.8 or later. -menu menubar,channel { +menu menubar,channel,query { - - SpotOn - .Menu - ..Open Menu:spssh | dialog -m sps sps + Spoton + .Interface:spssh | dialog -m sps sps .- .Control + ..Play/Pause:/dll spoton.dll control playpause ..Play:/dll spoton.dll control play - ..Replay:/dll spoton.dll control rplay ..Pause:/dll spoton.dll control pause + ..Replay:/dll spoton.dll control replay ..Next:/dll spoton.dll control next - ..Previous:/dll spoton.dll control prev - ..Volume Up:/dll spoton.dll control volup - ..Volume Down:/dll spoton.dll control voldown - ..Mute Volume:/dll spoton.dll control volmute - .$iif($menu == channel,-) - .$iif($menu == channel,Say):snp + ..Previous:/dll spoton.dll control previous + ..Rewind:/dll spoton.dll control rewind + ..Forward:/dll spoton.dll control forward + .$iif($menu == channel,query)- + .$iif($menu == channel,query)say:snp } dialog sps { @@ -92,10 +89,7 @@ alias -l spssh { ;Add new features from SpotOn alias -l spfrmx { - var %spuyt = [Song] $str($chr(9),2) Shows the Artist - Title $+ $crlf - ;var %spuyt = %spuyt $+ [Artist] $str($chr(9),2) Shows the Artist $+ $crlf - ;var %spuyt = %spuyt $+ [Title] $str($chr(9),2) Shows the Title $+ $crlf - return %spuyt + return $+([song],$str($chr(9),2),Shows the Artist - Title,$crlf,[artist],$str($chr(9),2),Shows the Artist,$crlf,[title],$str($chr(9),2),Shows the Title) } ;Generate says into the window @@ -129,15 +123,12 @@ menu @saylist { Remove:write -dl $+ $sline(@saylists,1).ln says.txt | spotwin } -;## 0therz ## +;## 0ther ## -;Replace x with SpotOn features. -alias -l spfrm { - var %f1 = $replace($1-,[song],$dll($spfind,song,)) - ;var %f2 = $replace(%f1,[artist],$dll($spfind,artist,)) - ;var %f3 = $replace(%f2,[title],$dll($spfind,title,)) - return $spc(%f1) +;Replace value with data from [x] [y] [z] +alias -1 spfrm { + return $spc($replace($1-,[song],$dll($spfind,song,),[artist],$dll($spfind,artist,),[title],$dll($spfind,title,))) } ;Check if channel have +c (Colors enabled) @@ -150,26 +141,31 @@ alias -l spc { } ;Checks if spoton.dll exists and return the path -alias -l spfind { +alias spfind { if ($exists($+($nofile($script),spoton.dll))) { return $+($nofile($script),spoton.dll) } - else { echo -ag * Can't find the DLL-file. | halt } + else { echo 04 -ag * [Spoton] - Can't find spoton.dll. | halt } } -;If SpotOn is playing a song (Status Code: 3), write out to the channel/pm. +;If Spoton is playing a song (Status Code: 3), write out to the channel/pm. alias snp { if ($dll($spfind,status,0) == 3) { - say $spfrm(%saythis) + if ($server != $null) { + say $spfrm(%saythis) + } + else { + echo 04 -ag * [Spoton] - You are not connected to an IRC-Server. + } } - else { echo -ag * Spotify is $replace($dll($spfind,status,0),0,Not running,1,Paused,2,Playing Advertisement) | halt } + else { echo 02 -ag * [Spoton] - Spotify is $replace($dll($spfind,status,0),0,Not running,1,Paused,2,Playing Advertisement) $+ . | halt } } ;Setup everything that is needed when loaded. on *:load:{ if (!%saythis) { set %saythis Spotify ยป [song] } spssh - echo -ag Spoton is loaded! + echo 02 -ag * [Spoton] - Spoton is loaded! } on *:unload:{ @@ -179,5 +175,5 @@ on *:unload:{ if ($window(@spss)) { window -c $v1 } if ($isfile(says.txt)) { .remove says.txt } unset %saythis - echo -ag SpotOn is now unloaded! + echo 02 -ag * [Spoton] - SpotOn is now unloaded! } diff --git a/spoton/Main.cpp b/spoton/Main.cpp index 208fe23..94053fc 100644 --- a/spoton/Main.cpp +++ b/spoton/Main.cpp @@ -18,7 +18,7 @@ limitations under the License. /* Everything Else -Copyright 2022 Turbosmurfen +Copyright 2023 Turbosmurfen Licensed under the Creative Commons License, version 4.0 https://creativecommons.org/licenses/by/4.0/ @@ -36,31 +36,31 @@ Licensed under the Creative Commons License, version 4.0 #include #define WIN32_LEAN_AND_MEAN #pragma comment(linker, "/EXPORT:song=_song@24") +#pragma comment(linker, "/EXPORT:artist=_artist@24") +#pragma comment(linker, "/EXPORT:title=_title@24") #pragma comment(linker, "/EXPORT:creator=_creator@24") #pragma comment(linker, "/EXPORT:version=_version@24") #pragma comment(linker, "/EXPORT:status=_status@24") #pragma comment(linker, "/EXPORT:control=_control@24") using namespace std; -string title{}; +string text{}; vector pids; -int status_{ 0 }; +int status_{0}; HWND hWNd{}; -char version_[] = "1.1.7"; +char version_[] = "1.1.8"; char createdby[] = "Created by: Turbosmurfen"; //Media Control -enum Control { - - PlayPause = 917504, - Stop = 851968, - NextTrack = 720896, - PreviousTrack = 786432, - RewindTrack = 3276800, - ForwardTrack = 3211264, - VolumeUp = 655360, - VolumeDown = 589824, - VolumeMute = 524288 +enum MediaControl { + Play = 3014656, //APPCOMMAND_MEDIA_PLAY * 0x10000 + Pause = 3080192, //APPCOMMAND_MEDIA_PAUSE * 0x10000 + PlayPause = 917504, //APPCOMMAND_MEDIA_PLAY_PAUSE * 0x10000 + Stop = 851968, //APPCOMMAND_MEDIA_STOP * 0x10000 + NextTrack = 720896, //APPCOMMAND_MEDIA_NEXTTRACK * 0x10000 + PreviousTrack = 786432, //APPCOMMAND_MEDIA_PREVIOUSTRACK * 0x10000 + RewindTrack = 3276800, //APPCOMMAND_MEDIA_REWIND * 0x10000 + ForwardTrack = 3211264, //APPCOMMAND_MEDIA_FAST_FORWARD * 0x10000 }; @@ -82,7 +82,7 @@ void readData(wstring input, HWND hWnd) { WideCharToMultiByte(CP_UTF8, 0, input.c_str(), -1, &str[0], count, NULL, NULL); std::replace(str.begin(), str.end(), '\n', ' '); std::replace(str.begin(), str.end(), '\r', ' '); - title = str; + text = str; status_ = 3; hWNd = hWnd; } @@ -139,83 +139,118 @@ static void ReadData() { } } -//Writes out title of the song +//Writes out Artist - Title extern "C" int __stdcall song(HWND mWnd, HWND aWnd, CHAR * data, char* parms, BOOL show, BOOL nopause) { ReadData(); - if (title.empty()) { + if (text.empty()) { return 0; } else { - strcpy_s(data, title.size() + 1, title.c_str()); + strcpy_s(data, text.size() + 1, text.c_str()); return 3; } } +//Only return the Artist if " - " exists. +extern "C" int __stdcall artist(HWND mWnd, HWND aWnd, CHAR * data, char* parms, BOOL show, BOOL nopause) +{ + ReadData(); + if (text.empty()) { + return 0; + } + else { + size_t findPos = text.find(" - "); + if (findPos != std::string::npos) { + string artist = text.substr(0, findPos); + strcpy_s(data, artist.size() + 1, artist.c_str()); + return 3; + } + else { + return 0; + } + } +} + +//Only return the Title if " - " exists. +extern "C" int __stdcall title(HWND mWnd, HWND aWnd, CHAR * data, char* parms, BOOL show, BOOL nopause) +{ + ReadData(); + if (text.empty()) { + return 0; + } + else { + size_t findPos = text.find(" - "); + if (findPos != std::string::npos) { + string title = text.substr(findPos + 3); + strcpy_s(data, title.size() + 1, title.c_str()); + return 3; + } + else { + return 0; + } + } +} + //Media Controls extern "C" int __stdcall control(HWND mWnd, HWND aWnd, CHAR * data, char* parms, BOOL show, BOOL nopause) { - - std::string cmd(data); + + string cmd(data); if (!cmd.empty()) { ReadData(); //Track controls if (cmd == "playpause") { - if (hWNd) SendMessage(hWNd, WM_APPCOMMAND, 0, Control::PlayPause); + if (hWNd) SendMessage(hWNd, WM_APPCOMMAND, 0, MediaControl::PlayPause); + } + else if (cmd == "play") { + if (hWNd) SendMessage(hWNd, WM_APPCOMMAND, 0, MediaControl::Play); + } + else if (cmd == "pause") { + if (hWNd) SendMessage(hWNd, WM_APPCOMMAND, 0, MediaControl::Pause); } else if (cmd == "stop") { - if (hWNd) SendMessage(hWNd, WM_APPCOMMAND, 0, Control::Stop); + if (hWNd) SendMessage(hWNd, WM_APPCOMMAND, 0, MediaControl::Stop); } else if (cmd == "next") { - if (hWNd) SendMessage(hWNd, WM_APPCOMMAND, 0, Control::NextTrack); + if (hWNd) SendMessage(hWNd, WM_APPCOMMAND, 0, MediaControl::NextTrack); } else if (cmd == "replay") { - if (hWNd) SendMessage(hWNd, WM_APPCOMMAND, 0, Control::PreviousTrack); + if (hWNd) SendMessage(hWNd, WM_APPCOMMAND, 0, MediaControl::PreviousTrack); } else if (cmd == "previous") { if (hWNd) { - SendMessage(hWNd, WM_APPCOMMAND, 0, Control::PreviousTrack); - SendMessage(hWNd, WM_APPCOMMAND, 0, Control::PreviousTrack); + SendMessage(hWNd, WM_APPCOMMAND, 0, MediaControl::PreviousTrack); + SendMessage(hWNd, WM_APPCOMMAND, 0, MediaControl::PreviousTrack); } } else if (cmd == "forward") { - if (hWNd) SendMessage(hWNd, WM_APPCOMMAND, 0, Control::ForwardTrack); + if (hWNd) SendMessage(hWNd, WM_APPCOMMAND, 0, MediaControl::ForwardTrack); } else if (cmd == "rewind") { - if (hWNd) SendMessage(hWNd, WM_APPCOMMAND, 0, Control::RewindTrack); - } - - //Volume Control - else if (cmd == "volup") { - if (hWNd) SendMessage(hWNd, WM_APPCOMMAND, 0, Control::VolumeUp); - } - else if (cmd == "voldown") { - if (hWNd) SendMessage(hWNd, WM_APPCOMMAND, 0, Control::VolumeDown); - } - else if (cmd == "volmute") { - if (hWNd) SendMessage(hWNd, WM_APPCOMMAND, 0, Control::VolumeMute); + if (hWNd) SendMessage(hWNd, WM_APPCOMMAND, 0, MediaControl::RewindTrack); } } return 0; } -//Created By +//Sending out who made this project. extern "C" int __stdcall creator(HWND mWnd, HWND aWnd, CHAR * data, char* parms, BOOL show, BOOL nopause) { strcpy_s(data, strlen(createdby) + 1, createdby); return 3; } -//Current Version +//Sending out which version of Spoton that you use. extern "C" int __stdcall version(HWND mWnd, HWND aWnd, CHAR * data, char* parms, BOOL show, BOOL nopause) { strcpy_s(data, strlen(version_) + 1, version_); return 3; } -/* Check for status +/* Sending out the numbers of status (0-3) * 0 - Spotify is not running * 1 - Spotify is paused * 2 - Spotfy is playing Advertisement