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

Commit bc0bb5a

Browse files
author
noriokun4649
committed
番組情報取得できるはず
1 parent a628e65 commit bc0bb5a

File tree

1 file changed

+33
-17
lines changed

1 file changed

+33
-17
lines changed

TvTestRPC/TvTestRPC.cpp

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class CMyPlugin : public TVTest::CTVTestPlugin
1212
bool pluginState;
1313
void discordInit();
1414
void UpdateState();
15-
time_t SystemTime2Timet(const SYSTEMTIME& st);
15+
time_t SystemTime2Timet(const SYSTEMTIME&);
1616
bool GetPluginInfo(TVTest::PluginInfo *pInfo) override
1717
{
1818
pInfo->Type = TVTest::PLUGIN_TYPE_NORMAL;
@@ -56,25 +56,38 @@ void CMyPlugin::UpdateState()
5656
Info.MaxEventText = sizeof(eventText) / sizeof(eventText[0]);
5757
Info.pszEventExtText = eventExtText;
5858
Info.MaxEventExtText = sizeof(eventExtText) / sizeof(eventExtText[0]);
59-
if (m_pApp->GetCurrentChannelInfo(&ChannelInfo) && m_pApp->GetCurrentProgramInfo(&Info)) {
60-
DiscordRichPresence discordPresence;
61-
memset(&discordPresence, 0, sizeof(discordPresence));
62-
discordPresence.details = wide_to_utf8(ChannelInfo.szChannelName).c_str();
63-
discordPresence.state = wide_to_utf8(Info.pszEventName).c_str();
64-
discordPresence.startTimestamp = SystemTime2Timet(Info.StartTime);
65-
discordPresence.endTimestamp = SystemTime2Timet(Info.StartTime) + Info.Duration;
66-
discordPresence.largeImageKey = "tvtest";
67-
discordPresence.partyId = "";
68-
discordPresence.partySize = 0;
69-
discordPresence.partyMax = 0;
70-
discordPresence.matchSecret = "";
71-
discordPresence.joinSecret = "";
72-
discordPresence.spectateSecret = "";
73-
discordPresence.instance = 0;
74-
Discord_UpdatePresence(&discordPresence);
59+
std::string channelName;
60+
std::string eventNamed;
61+
time_t start;
62+
time_t end;
63+
64+
if (m_pApp->GetCurrentProgramInfo(&Info)) {
65+
eventNamed = wide_to_utf8(Info.pszEventName);
66+
end = SystemTime2Timet(Info.StartTime) + Info.Duration;
67+
start = SystemTime2Timet(Info.StartTime);
7568
}
69+
if (m_pApp->GetCurrentChannelInfo(&ChannelInfo) ) {
70+
m_pApp->AddLog(ChannelInfo.szChannelName);
71+
channelName = wide_to_utf8(ChannelInfo.szChannelName);
72+
}
73+
DiscordRichPresence discordPresence;
74+
memset(&discordPresence, 0, sizeof(discordPresence));
75+
discordPresence.details = channelName.c_str();
76+
discordPresence.state = eventNamed.c_str();
77+
discordPresence.startTimestamp = start;
78+
discordPresence.endTimestamp = end;
79+
discordPresence.largeImageKey = "tvtest";
80+
discordPresence.partyId = "";
81+
discordPresence.partySize = 0;
82+
discordPresence.partyMax = 0;
83+
discordPresence.matchSecret = "";
84+
discordPresence.joinSecret = "";
85+
discordPresence.spectateSecret = "";
86+
discordPresence.instance = 0;
87+
Discord_UpdatePresence(&discordPresence);
7688
}
7789

90+
7891
time_t CMyPlugin::SystemTime2Timet(const SYSTEMTIME& st)
7992
{
8093
struct tm gm = { st.wSecond, st.wMinute, st.wHour, st.wDay, st.wMonth - 1, st.wYear - 1900, st.wDayOfWeek, 0, 0 };
@@ -104,6 +117,9 @@ LRESULT CALLBACK CMyPlugin::EventCallback(UINT Event, LPARAM lParam1, LPARAM lPa
104117
case TVTest::EVENT_CHANNELCHANGE:
105118
pThis->UpdateState();
106119
return TRUE;
120+
case TVTest::EVENT_SERVICECHANGE:
121+
pThis->UpdateState();
122+
return TRUE;
107123
}
108124
return 0;
109125
}

0 commit comments

Comments
 (0)