Add a new Channel API for experimental plugins feature (#5141)
This commit is contained in:
@@ -126,97 +126,6 @@ int c2_register_callback(lua_State *L)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int c2_send_msg(lua_State *L)
|
||||
{
|
||||
QString text;
|
||||
QString channel;
|
||||
if (lua_gettop(L) != 2)
|
||||
{
|
||||
luaL_error(L, "send_msg needs exactly 2 arguments (channel and text)");
|
||||
lua::push(L, false);
|
||||
return 1;
|
||||
}
|
||||
if (!lua::pop(L, &text))
|
||||
{
|
||||
luaL_error(
|
||||
L, "cannot get text (2nd argument of send_msg, expected a string)");
|
||||
lua::push(L, false);
|
||||
return 1;
|
||||
}
|
||||
if (!lua::pop(L, &channel))
|
||||
{
|
||||
luaL_error(
|
||||
L,
|
||||
"cannot get channel (1st argument of send_msg, expected a string)");
|
||||
lua::push(L, false);
|
||||
return 1;
|
||||
}
|
||||
|
||||
const auto chn = getApp()->twitch->getChannelOrEmpty(channel);
|
||||
if (chn->isEmpty())
|
||||
{
|
||||
auto *pl = getIApp()->getPlugins()->getPluginByStatePtr(L);
|
||||
|
||||
qCWarning(chatterinoLua)
|
||||
<< "Plugin" << pl->id
|
||||
<< "tried to send a message (using send_msg) to channel" << channel
|
||||
<< "which is not known";
|
||||
lua::push(L, false);
|
||||
return 1;
|
||||
}
|
||||
QString message = text;
|
||||
message = message.replace('\n', ' ');
|
||||
QString outText =
|
||||
getIApp()->getCommands()->execCommand(message, chn, false);
|
||||
chn->sendMessage(outText);
|
||||
lua::push(L, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int c2_system_msg(lua_State *L)
|
||||
{
|
||||
if (lua_gettop(L) != 2)
|
||||
{
|
||||
luaL_error(L,
|
||||
"system_msg needs exactly 2 arguments (channel and text)");
|
||||
lua::push(L, false);
|
||||
return 1;
|
||||
}
|
||||
QString channel;
|
||||
QString text;
|
||||
|
||||
if (!lua::pop(L, &text))
|
||||
{
|
||||
luaL_error(
|
||||
L,
|
||||
"cannot get text (2nd argument of system_msg, expected a string)");
|
||||
lua::push(L, false);
|
||||
return 1;
|
||||
}
|
||||
if (!lua::pop(L, &channel))
|
||||
{
|
||||
luaL_error(L, "cannot get channel (1st argument of system_msg, "
|
||||
"expected a string)");
|
||||
lua::push(L, false);
|
||||
return 1;
|
||||
}
|
||||
|
||||
const auto chn = getApp()->twitch->getChannelOrEmpty(channel);
|
||||
if (chn->isEmpty())
|
||||
{
|
||||
auto *pl = getIApp()->getPlugins()->getPluginByStatePtr(L);
|
||||
qCWarning(chatterinoLua)
|
||||
<< "Plugin" << pl->id
|
||||
<< "tried to show a system message (using system_msg) in channel"
|
||||
<< channel << "which is not known";
|
||||
lua::push(L, false);
|
||||
return 1;
|
||||
}
|
||||
chn->addMessage(makeSystemMessage(text));
|
||||
lua::push(L, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int c2_log(lua_State *L)
|
||||
{
|
||||
auto *pl = getIApp()->getPlugins()->getPluginByStatePtr(L);
|
||||
|
||||
Reference in New Issue
Block a user