{"action":"created","comment":{"url":"https://api.github.com/repos/nullworks/cathook/pulls/comments/229665051","pull_request_review_id":170214003,"id":229665051,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyOTY2NTA1MQ==","diff_hunk":"@@ -0,0 +1,141 @@\n+/*\n+ * DominateSay.cpp\n+ *\n+ *\tCreated on: October 30, 2018\n+ */\n+\n+#include <hacks/DominateSay.hpp>\n+#include <settings/Int.hpp>\n+#include \"common.hpp\"\n+\n+static settings::Int dominatesay_mode{ \"dominatesay.mode\", \"0\" };\n+static settings::String filename{ \"dominatesay.file\", \"dominatesay.txt\" };\n+\n+static CatCommand reload_command(\"dominatesay_reload\", \"Reload dominatesays\",\n+                                 []() {\n+                                     hacks::shared::dominatesay::reload();\n+                                 });\n+\n+namespace hacks::shared::dominatesay\n+{\n+\n+const std::string tf_classes_dominatesay[] = { \"class\",   \"scout\",   \"sniper\",\n+                                               \"soldier\", \"demoman\", \"medic\",\n+                                               \"heavy\",   \"pyro\",    \"spy\",\n+                                               \"engineer\" };\n+\n+const std::string tf_teams_dominatesay[] = { \"RED\", \"BLU\" };\n+\n+static std::string lastmsg{};\n+\n+TextFile file{};\n+\n+std::string ComposeDominateSay(IGameEvent *event)\n+{\n+    const std::vector<std::string> *source = nullptr;\n+    switch (*dominatesay_mode)\n+    {\n+    case 1:\n+        source = &file.lines;\n+        break;\n+    case 2:\n+        source = &builtin_default;\n+        break;\n+    case 3:\n+        source = &jp_anime;\n+        break;\n+    default:\n+        break;\n+    }\n+    if (!source || source->empty())\n+        return \"\";\n+    if (!event)\n+        return \"\";\n+    int vid  = event->GetInt(\"dominated\");\n+    int kid  = event->GetInt(\"dominator\");\n+    int dnum = event->GetInt(\"dominations\");\n+\n+    //\tthis is actually impossible but just in case.\n+    if (g_IEngine->GetPlayerForUserID(kid) != g_IEngine->GetLocalPlayer())\n+        return \"\";\n+\n+    std::string msg = source->at(rand() % source->size());\n+\n+    while (msg == lastmsg && source->size() > 1)\n+        msg = source->at(rand() % source->size());\n+    lastmsg = msg;\n+    player_info_s info{};\n+\n+    g_IEngine->GetPlayerInfo(g_IEngine->GetPlayerForUserID(vid), &info);\n+    ReplaceString(msg, \"%name%\", std::string(info.name));\n+\n+    CachedEntity *ent = ENTITY(g_IEngine->GetPlayerForUserID(vid));\n+    int clz           = g_pPlayerResource->GetClass(ent);\n+\n+    ReplaceString(msg, \"%class%\", tf_classes_dominatesay[clz]);\n+    player_info_s infok{};\n+    g_IEngine->GetPlayerInfo(g_IEngine->GetPlayerForUserID(kid), &infok);\n+\n+    ReplaceString(msg, \"%dominum%\", std::to_string(dnum));\n+    ReplaceString(msg, \"%killer%\", std::string(infok.name));\n+    ReplaceString(msg, \"%team%\", tf_teams_dominatesay[ent->m_iTeam() - 2]);\n+    ReplaceString(msg, \"%myteam%\",\n+                  tf_teams_dominatesay[LOCAL_E->m_iTeam() - 2]);\n+    ReplaceString(msg, \"%myclass%\",\n+                  tf_classes_dominatesay[g_pPlayerResource->GetClass(LOCAL_E)]);\n+    ReplaceString(msg, \"\\\\n\", \"\\n\");\n+    return msg;\n+}\n+\n+class DominateSayEventListener : public IGameEventListener2\n+{\n+    void FireGameEvent(IGameEvent *event) override\n+    {\n+        if (!dominatesay_mode)\n+            return;\n+        std::string message =\n+            hacks::shared::dominatesay::ComposeDominateSay(event);\n+        if (!message.empty())\n+            chat_stack::Say(message, false);\n+    }\n+};\n+\n+static DominateSayEventListener listener{};\n+\n+void reload()\n+{\n+    file.Load(*filename);\n+}\n+\n+void init()\n+{\n+    g_IEventManager2->AddListener(&listener, (const char *) \"player_domination\",\n+                                  false);\n+}\n+\n+void shutdown()\n+{\n+    g_IEventManager2->RemoveListener(&listener);\n+}\n+\n+//\ta much better default dominatesay would be appreciated.\n+const std::vector<std::string> builtin_default = {\n+    \"dominating %name%! (%dominum% dominations)\",\n+    \"%name%, getting tapped?\",\n+    \"%killer% is dominating the server with %dominum% dominations!\",\n+};\n+\n+//\tsame goes to this one\n+const std::vector<std::string> jp_anime = { ","path":"src/hacks/DominateSay.cpp","position":129,"original_position":129,"commit_id":"2db1c80a0cfd0261bc8e98ffb0797386dbd7d3bc","original_commit_id":"2db1c80a0cfd0261bc8e98ffb0797386dbd7d3bc","user":{"login":"TotallyNotElite","id":38938720,"node_id":"MDQ6VXNlcjM4OTM4NzIw","avatar_url":"https://avatars2.githubusercontent.com/u/38938720?v=4","gravatar_id":"","url":"https://api.github.com/users/TotallyNotElite","html_url":"https://github.com/TotallyNotElite","followers_url":"https://api.github.com/users/TotallyNotElite/followers","following_url":"https://api.github.com/users/TotallyNotElite/following{/other_user}","gists_url":"https://api.github.com/users/TotallyNotElite/gists{/gist_id}","starred_url":"https://api.github.com/users/TotallyNotElite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TotallyNotElite/subscriptions","organizations_url":"https://api.github.com/users/TotallyNotElite/orgs","repos_url":"https://api.github.com/users/TotallyNotElite/repos","events_url":"https://api.github.com/users/TotallyNotElite/events{/privacy}","received_events_url":"https://api.github.com/users/TotallyNotElite/received_events","type":"User","site_admin":false},"body":"wtf did i just read xd","created_at":"2018-10-31T12:02:26Z","updated_at":"2018-10-31T12:03:11Z","html_url":"https://github.com/nullworks/cathook/pull/624#discussion_r229665051","pull_request_url":"https://api.github.com/repos/nullworks/cathook/pulls/624","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/nullworks/cathook/pulls/comments/229665051"},"html":{"href":"https://github.com/nullworks/cathook/pull/624#discussion_r229665051"},"pull_request":{"href":"https://api.github.com/repos/nullworks/cathook/pulls/624"}}},"pull_request":{"url":"https://api.github.com/repos/nullworks/cathook/pulls/624","id":227115747,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI3MTE1NzQ3","html_url":"https://github.com/nullworks/cathook/pull/624","diff_url":"https://github.com/nullworks/cathook/pull/624.diff","patch_url":"https://github.com/nullworks/cathook/pull/624.patch","issue_url":"https://api.github.com/repos/nullworks/cathook/issues/624","number":624,"state":"open","locked":false,"title":"DominateSay","user":{"login":"surepy","id":24486494,"node_id":"MDQ6VXNlcjI0NDg2NDk0","avatar_url":"https://avatars3.githubusercontent.com/u/24486494?v=4","gravatar_id":"","url":"https://api.github.com/users/surepy","html_url":"https://github.com/surepy","followers_url":"https://api.github.com/users/surepy/followers","following_url":"https://api.github.com/users/surepy/following{/other_user}","gists_url":"https://api.github.com/users/surepy/gists{/gist_id}","starred_url":"https://api.github.com/users/surepy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/surepy/subscriptions","organizations_url":"https://api.github.com/users/surepy/orgs","repos_url":"https://api.github.com/users/surepy/repos","events_url":"https://api.github.com/users/surepy/events{/privacy}","received_events_url":"https://api.github.com/users/surepy/received_events","type":"User","site_admin":false},"body":"\"todo - Chat and Related - dominatesay\"\r\n\r\ntotally did not copypaste killsay","created_at":"2018-10-30T23:38:46Z","updated_at":"2018-10-31T12:03:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e7ef995d3692c493689b17bd2afdfd22cefb7f84","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/nullworks/cathook/pulls/624/commits","review_comments_url":"https://api.github.com/repos/nullworks/cathook/pulls/624/comments","review_comment_url":"https://api.github.com/repos/nullworks/cathook/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nullworks/cathook/issues/624/comments","statuses_url":"https://api.github.com/repos/nullworks/cathook/statuses/2db1c80a0cfd0261bc8e98ffb0797386dbd7d3bc","head":{"label":"surepy:master","ref":"master","sha":"2db1c80a0cfd0261bc8e98ffb0797386dbd7d3bc","user":{"login":"surepy","id":24486494,"node_id":"MDQ6VXNlcjI0NDg2NDk0","avatar_url":"https://avatars3.githubusercontent.com/u/24486494?v=4","gravatar_id":"","url":"https://api.github.com/users/surepy","html_url":"https://github.com/surepy","followers_url":"https://api.github.com/users/surepy/followers","following_url":"https://api.github.com/users/surepy/following{/other_user}","gists_url":"https://api.github.com/users/surepy/gists{/gist_id}","starred_url":"https://api.github.com/users/surepy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/surepy/subscriptions","organizations_url":"https://api.github.com/users/surepy/orgs","repos_url":"https://api.github.com/users/surepy/repos","events_url":"https://api.github.com/users/surepy/events{/privacy}","received_events_url":"https://api.github.com/users/surepy/received_events","type":"User","site_admin":false},"repo":{"id":143567975,"node_id":"MDEwOlJlcG9zaXRvcnkxNDM1Njc5NzU=","name":"cathook","full_name":"surepy/cathook","private":false,"owner":{"login":"surepy","id":24486494,"node_id":"MDQ6VXNlcjI0NDg2NDk0","avatar_url":"https://avatars3.githubusercontent.com/u/24486494?v=4","gravatar_id":"","url":"https://api.github.com/users/surepy","html_url":"https://github.com/surepy","followers_url":"https://api.github.com/users/surepy/followers","following_url":"https://api.github.com/users/surepy/following{/other_user}","gists_url":"https://api.github.com/users/surepy/gists{/gist_id}","starred_url":"https://api.github.com/users/surepy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/surepy/subscriptions","organizations_url":"https://api.github.com/users/surepy/orgs","repos_url":"https://api.github.com/users/surepy/repos","events_url":"https://api.github.com/users/surepy/events{/privacy}","received_events_url":"https://api.github.com/users/surepy/received_events","type":"User","site_admin":false},"html_url":"https://github.com/surepy/cathook","description":"idk","fork":true,"url":"https://api.github.com/repos/surepy/cathook","forks_url":"https://api.github.com/repos/surepy/cathook/forks","keys_url":"https://api.github.com/repos/surepy/cathook/keys{/key_id}","collaborators_url":"https://api.github.com/repos/surepy/cathook/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/surepy/cathook/teams","hooks_url":"https://api.github.com/repos/surepy/cathook/hooks","issue_events_url":"https://api.github.com/repos/surepy/cathook/issues/events{/number}","events_url":"https://api.github.com/repos/surepy/cathook/events","assignees_url":"https://api.github.com/repos/surepy/cathook/assignees{/user}","branches_url":"https://api.github.com/repos/surepy/cathook/branches{/branch}","tags_url":"https://api.github.com/repos/surepy/cathook/tags","blobs_url":"https://api.github.com/repos/surepy/cathook/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/surepy/cathook/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/surepy/cathook/git/refs{/sha}","trees_url":"https://api.github.com/repos/surepy/cathook/git/trees{/sha}","statuses_url":"https://api.github.com/repos/surepy/cathook/statuses/{sha}","languages_url":"https://api.github.com/repos/surepy/cathook/languages","stargazers_url":"https://api.github.com/repos/surepy/cathook/stargazers","contributors_url":"https://api.github.com/repos/surepy/cathook/contributors","subscribers_url":"https://api.github.com/repos/surepy/cathook/subscribers","subscription_url":"https://api.github.com/repos/surepy/cathook/subscription","commits_url":"https://api.github.com/repos/surepy/cathook/commits{/sha}","git_commits_url":"https://api.github.com/repos/surepy/cathook/git/commits{/sha}","comments_url":"https://api.github.com/repos/surepy/cathook/comments{/number}","issue_comment_url":"https://api.github.com/repos/surepy/cathook/issues/comments{/number}","contents_url":"https://api.github.com/repos/surepy/cathook/contents/{+path}","compare_url":"https://api.github.com/repos/surepy/cathook/compare/{base}...{head}","merges_url":"https://api.github.com/repos/surepy/cathook/merges","archive_url":"https://api.github.com/repos/surepy/cathook/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/surepy/cathook/downloads","issues_url":"https://api.github.com/repos/surepy/cathook/issues{/number}","pulls_url":"https://api.github.com/repos/surepy/cathook/pulls{/number}","milestones_url":"https://api.github.com/repos/surepy/cathook/milestones{/number}","notifications_url":"https://api.github.com/repos/surepy/cathook/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/surepy/cathook/labels{/name}","releases_url":"https://api.github.com/repos/surepy/cathook/releases{/id}","deployments_url":"https://api.github.com/repos/surepy/cathook/deployments","created_at":"2018-08-04T22:48:46Z","updated_at":"2018-10-30T23:38:33Z","pushed_at":"2018-10-30T23:38:32Z","git_url":"git://github.com/surepy/cathook.git","ssh_url":"git@github.com:surepy/cathook.git","clone_url":"https://github.com/surepy/cathook.git","svn_url":"https://github.com/surepy/cathook","homepage":"","size":30825,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"nullworks:master","ref":"master","sha":"11e4abe410f026e4332e7805da5daf18801d4fd5","user":{"login":"nullworks","id":38817348,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM4ODE3MzQ4","avatar_url":"https://avatars1.githubusercontent.com/u/38817348?v=4","gravatar_id":"","url":"https://api.github.com/users/nullworks","html_url":"https://github.com/nullworks","followers_url":"https://api.github.com/users/nullworks/followers","following_url":"https://api.github.com/users/nullworks/following{/other_user}","gists_url":"https://api.github.com/users/nullworks/gists{/gist_id}","starred_url":"https://api.github.com/users/nullworks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nullworks/subscriptions","organizations_url":"https://api.github.com/users/nullworks/orgs","repos_url":"https://api.github.com/users/nullworks/repos","events_url":"https://api.github.com/users/nullworks/events{/privacy}","received_events_url":"https://api.github.com/users/nullworks/received_events","type":"Organization","site_admin":false},"repo":{"id":83015607,"node_id":"MDEwOlJlcG9zaXRvcnk4MzAxNTYwNw==","name":"cathook","full_name":"nullworks/cathook","private":false,"owner":{"login":"nullworks","id":38817348,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM4ODE3MzQ4","avatar_url":"https://avatars1.githubusercontent.com/u/38817348?v=4","gravatar_id":"","url":"https://api.github.com/users/nullworks","html_url":"https://github.com/nullworks","followers_url":"https://api.github.com/users/nullworks/followers","following_url":"https://api.github.com/users/nullworks/following{/other_user}","gists_url":"https://api.github.com/users/nullworks/gists{/gist_id}","starred_url":"https://api.github.com/users/nullworks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nullworks/subscriptions","organizations_url":"https://api.github.com/users/nullworks/orgs","repos_url":"https://api.github.com/users/nullworks/repos","events_url":"https://api.github.com/users/nullworks/events{/privacy}","received_events_url":"https://api.github.com/users/nullworks/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/nullworks/cathook","description":"Training Software for the game Team Fortress 2","fork":false,"url":"https://api.github.com/repos/nullworks/cathook","forks_url":"https://api.github.com/repos/nullworks/cathook/forks","keys_url":"https://api.github.com/repos/nullworks/cathook/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nullworks/cathook/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nullworks/cathook/teams","hooks_url":"https://api.github.com/repos/nullworks/cathook/hooks","issue_events_url":"https://api.github.com/repos/nullworks/cathook/issues/events{/number}","events_url":"https://api.github.com/repos/nullworks/cathook/events","assignees_url":"https://api.github.com/repos/nullworks/cathook/assignees{/user}","branches_url":"https://api.github.com/repos/nullworks/cathook/branches{/branch}","tags_url":"https://api.github.com/repos/nullworks/cathook/tags","blobs_url":"https://api.github.com/repos/nullworks/cathook/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nullworks/cathook/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nullworks/cathook/git/refs{/sha}","trees_url":"https://api.github.com/repos/nullworks/cathook/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nullworks/cathook/statuses/{sha}","languages_url":"https://api.github.com/repos/nullworks/cathook/languages","stargazers_url":"https://api.github.com/repos/nullworks/cathook/stargazers","contributors_url":"https://api.github.com/repos/nullworks/cathook/contributors","subscribers_url":"https://api.github.com/repos/nullworks/cathook/subscribers","subscription_url":"https://api.github.com/repos/nullworks/cathook/subscription","commits_url":"https://api.github.com/repos/nullworks/cathook/commits{/sha}","git_commits_url":"https://api.github.com/repos/nullworks/cathook/git/commits{/sha}","comments_url":"https://api.github.com/repos/nullworks/cathook/comments{/number}","issue_comment_url":"https://api.github.com/repos/nullworks/cathook/issues/comments{/number}","contents_url":"https://api.github.com/repos/nullworks/cathook/contents/{+path}","compare_url":"https://api.github.com/repos/nullworks/cathook/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nullworks/cathook/merges","archive_url":"https://api.github.com/repos/nullworks/cathook/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nullworks/cathook/downloads","issues_url":"https://api.github.com/repos/nullworks/cathook/issues{/number}","pulls_url":"https://api.github.com/repos/nullworks/cathook/pulls{/number}","milestones_url":"https://api.github.com/repos/nullworks/cathook/milestones{/number}","notifications_url":"https://api.github.com/repos/nullworks/cathook/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nullworks/cathook/labels{/name}","releases_url":"https://api.github.com/repos/nullworks/cathook/releases{/id}","deployments_url":"https://api.github.com/repos/nullworks/cathook/deployments","created_at":"2017-02-24T07:47:00Z","updated_at":"2018-10-30T20:37:34Z","pushed_at":"2018-10-30T23:38:47Z","git_url":"git://github.com/nullworks/cathook.git","ssh_url":"git@github.com:nullworks/cathook.git","clone_url":"https://github.com/nullworks/cathook.git","svn_url":"https://github.com/nullworks/cathook","homepage":"","size":30957,"stargazers_count":103,"watchers_count":103,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":52,"mirror_url":null,"archived":false,"open_issues_count":45,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":52,"open_issues":45,"watchers":103,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nullworks/cathook/pulls/624"},"html":{"href":"https://github.com/nullworks/cathook/pull/624"},"issue":{"href":"https://api.github.com/repos/nullworks/cathook/issues/624"},"comments":{"href":"https://api.github.com/repos/nullworks/cathook/issues/624/comments"},"review_comments":{"href":"https://api.github.com/repos/nullworks/cathook/pulls/624/comments"},"review_comment":{"href":"https://api.github.com/repos/nullworks/cathook/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nullworks/cathook/pulls/624/commits"},"statuses":{"href":"https://api.github.com/repos/nullworks/cathook/statuses/2db1c80a0cfd0261bc8e98ffb0797386dbd7d3bc"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"TotallyNotElite"}}