Debian Codegraph @

lua/ghost/handle.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 function gh_handle_game_userjoin(game, account)
10 -- check that game owner is ghost bot
11 if not gh_is_bot(game.owner) then return end
12
13 -- send ping silently
14 gh_set_silentflag(account.name)
15
16 local botaccount = api.account_get_by_name(game.owner)
17 -- send ping to bot (to save result)
18 command_ping(botaccount, "/ping")
19
20 if (config.ghost_dota_server) then
21 -- user who is owner of the hostbot in the current game
22 local owner = gh_find_userbot_by_game(game.name)
23 -- if game is not ladder
24 if string:empty(gh_get_userbot_gametype(owner)) then return end
25
26
27 for u in string.split(game.players, ",") do
28 -- show stats of the player who joined the game for each other player
29 local useracc = api.account_get_by_name(u)
30 command_stats(useracc, "/stats " .. account.name)
31
32 -- show stats of each player in the game to a player who joined the game
33 command_stats(account, "/stats " .. u)
34 end
35 api.message_send_text(account.name, message_type_info, nil, localize(account.name, "Joined ladder game. Game owner: {}", owner))
36 end
37 end
38
39 function gh_handle_user_login(account)
40 if gh_is_bot(account.name) then
41 -- activate pvpgn mode on ghost side
42 gh_message_send(account.name, "/pvpgn init");
43 DEBUG("init bot " .. account.name)
44 end
45 end