Debian Codegraph @

lua/command/redirect.lua

raw symbols SCIP
1 --[[
2 Copyright (C) 2014 HarpyWar ([email protected])
3
4 This file is a part of the PvPGN Project http://pvpgn.pro
5 Licensed under the same terms as Lua itself.
6 ]]--
7
8
9 -- Send text to user from server. Works like /announce,
10 -- but directly to user and message text is not red.
11 -- /redirect <username> <message>
12 function command_redirect(account, text)
13
14 local args = split_command(text, 2)
15
16 if not args[1] or not args[2] then
17 api.describe_command(account.name, args[0])
18 return -1
19 end
20
21 -- get destination account
22 local dest = api.account_get_by_name(args[1])
23
24 if next(dest) == nil or dest.online == "false" then
25 api.message_send_text(account.name, message_type_error, account.name, localize(account.name, "User \"{}\" is offline", args[1]))
26 return -1
27 end
28
29 api.message_send_text(dest.name, message_type_info, dest.name, args[2])
30
31 return 0
32 end