Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
番組情報取得できるはず
Browse files Browse the repository at this point in the history
  • Loading branch information
noriokun4649 committed May 15, 2019
1 parent a628e65 commit bc0bb5a
Showing 1 changed file with 33 additions and 17 deletions.
50 changes: 33 additions & 17 deletions TvTestRPC/TvTestRPC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class CMyPlugin : public TVTest::CTVTestPlugin
bool pluginState;
void discordInit();
void UpdateState();
time_t SystemTime2Timet(const SYSTEMTIME& st);
time_t SystemTime2Timet(const SYSTEMTIME&);
bool GetPluginInfo(TVTest::PluginInfo *pInfo) override
{
pInfo->Type = TVTest::PLUGIN_TYPE_NORMAL;
Expand Down Expand Up @@ -56,25 +56,38 @@ void CMyPlugin::UpdateState()
Info.MaxEventText = sizeof(eventText) / sizeof(eventText[0]);
Info.pszEventExtText = eventExtText;
Info.MaxEventExtText = sizeof(eventExtText) / sizeof(eventExtText[0]);
if (m_pApp->GetCurrentChannelInfo(&ChannelInfo) && m_pApp->GetCurrentProgramInfo(&Info)) {
DiscordRichPresence discordPresence;
memset(&discordPresence, 0, sizeof(discordPresence));
discordPresence.details = wide_to_utf8(ChannelInfo.szChannelName).c_str();
discordPresence.state = wide_to_utf8(Info.pszEventName).c_str();
discordPresence.startTimestamp = SystemTime2Timet(Info.StartTime);
discordPresence.endTimestamp = SystemTime2Timet(Info.StartTime) + Info.Duration;
discordPresence.largeImageKey = "tvtest";
discordPresence.partyId = "";
discordPresence.partySize = 0;
discordPresence.partyMax = 0;
discordPresence.matchSecret = "";
discordPresence.joinSecret = "";
discordPresence.spectateSecret = "";
discordPresence.instance = 0;
Discord_UpdatePresence(&discordPresence);
std::string channelName;
std::string eventNamed;
time_t start;
time_t end;

if (m_pApp->GetCurrentProgramInfo(&Info)) {
eventNamed = wide_to_utf8(Info.pszEventName);
end = SystemTime2Timet(Info.StartTime) + Info.Duration;
start = SystemTime2Timet(Info.StartTime);
}
if (m_pApp->GetCurrentChannelInfo(&ChannelInfo) ) {
m_pApp->AddLog(ChannelInfo.szChannelName);
channelName = wide_to_utf8(ChannelInfo.szChannelName);
}
DiscordRichPresence discordPresence;
memset(&discordPresence, 0, sizeof(discordPresence));
discordPresence.details = channelName.c_str();
discordPresence.state = eventNamed.c_str();
discordPresence.startTimestamp = start;
discordPresence.endTimestamp = end;
discordPresence.largeImageKey = "tvtest";
discordPresence.partyId = "";
discordPresence.partySize = 0;
discordPresence.partyMax = 0;
discordPresence.matchSecret = "";
discordPresence.joinSecret = "";
discordPresence.spectateSecret = "";
discordPresence.instance = 0;
Discord_UpdatePresence(&discordPresence);
}


time_t CMyPlugin::SystemTime2Timet(const SYSTEMTIME& st)
{
struct tm gm = { st.wSecond, st.wMinute, st.wHour, st.wDay, st.wMonth - 1, st.wYear - 1900, st.wDayOfWeek, 0, 0 };
Expand Down Expand Up @@ -104,6 +117,9 @@ LRESULT CALLBACK CMyPlugin::EventCallback(UINT Event, LPARAM lParam1, LPARAM lPa
case TVTest::EVENT_CHANNELCHANGE:
pThis->UpdateState();
return TRUE;
case TVTest::EVENT_SERVICECHANGE:
pThis->UpdateState();
return TRUE;
}
return 0;
}

0 comments on commit bc0bb5a

Please sign in to comment.