{"action":"created","comment":{"url":"https://api.github.com/repos/inspircd/inspircd-extras/pulls/comments/179763288","pull_request_review_id":110070183,"id":179763288,"diff_hunk":"@@ -0,0 +1,123 @@\n+/*\n+ * InspIRCd -- Internet Relay Chat Daemon\n+ *\n+ *   Copyright (C) 2018 genius30000 <genius3000@g3k.solutions>\n+ *   Copyright (C) 2010 Daniel De Graaf <danieldg@inspircd.org>\n+ *   Copyright (C) 2007-2008 Robin Burchell <robin+git@viroteck.net>\n+ *   Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>\n+ *   Copyright (C) 2003, 2006 Craig Edwards <craigedwards@brainbox.cc>\n+ *   Copyright (C) 2005 Craig McLure <craig@chatspike.net>\n+ *\n+ * This file is part of InspIRCd.  InspIRCd is free software: you can\n+ * redistribute it and/or modify it under the terms of the GNU General Public\n+ * License as published by the Free Software Foundation, version 2.\n+ *\n+ * This program is distributed in the hope that it will be useful, but WITHOUT\n+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more\n+ * details.\n+ *\n+ * You should have received a copy of the GNU General Public License\n+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.\n+ */\n+\n+/* $ModAuthor: genius3000 */\n+/* $ModAuthorMail: genius3000@g3k.solutions */\n+/* $ModDesc: Send a random notice (quote) from a file to all users at a set interval. */\n+/* $ModDepends: core 2.0 */\n+/* $ModConfig: <randomnotice file=\"data/randomnotices.db\" interval=\"30m\"> */\n+/* \"file\" needs to be a text file with each 'notice' on a new line\n+ * \"interval\" is a time-string (1y7d8h6m3s format)\n+ * options of: \"prefix\" and \"suffix\" are also available\n+ */\n+\n+#include \"inspircd.h\"\n+\n+\n+class ModuleRandomNotice : public Module\n+{\n+\tFileReader* notices = NULL;\n+\tstd::string prefix;\n+\tstd::string suffix;\n+\ttime_t lastsent;\n+\tlong interval;\n+\n+\t/* insp20's Timer class doesn't allow changing the interval of an added Timer, so we just check\n+\t * the current time to our 'last sent' time plus the wait interval.\n+\t * This is similar to how spanningtree's AutoConnect works, to allow Rehash changes to interval.\n+\t */\n+\tvoid SendNotice(time_t curtime)\n+\t{\n+\t\tif ((lastsent + interval > curtime) || !notices)\n+\t\t\treturn;\n+\n+\t\tunsigned int fsize = notices->FileSize();\n+\t\tif (!fsize)\n+\t\t\treturn;\n+\n+\t\tconst std::string notice = notices->GetLine(ServerInstance->GenRandomInt(fsize));\n+\t\tif (notice.empty())\n+\t\t\treturn;\n+\n+\t\tfor (LocalUserList::const_iterator i = ServerInstance->Users->local_users.begin(); i != ServerInstance->Users->local_users.end(); ++i)\n+\t\t{\n+\t\t\tLocalUser* lu = *i;\n+\n+\t\t\tif (lu->registered == REG_ALL)\n+\t\t\t\tlu->WriteServ(\"NOTICE %s :%s%s%s\", lu->nick.c_str(), prefix.c_str(), notice.c_str(), suffix.c_str());\n+\t\t}\n+\t\tlastsent = curtime;\n+\t}\n+\n+ public:\n+\tModuleRandomNotice()\n+\t\t: lastsent(0)\n+\t\t, interval(1800)\n+\t{\n+\t}\n+\n+\tvoid init()\n+\t{\n+\t\tOnRehash(NULL);\n+\t\tImplementation eventlist[] = { I_OnBackgroundTimer, I_OnRehash };\n+\t\tServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));\n+\t}\n+\n+\tvoid OnRehash(User*)\n+\t{\n+\t\tConfigTag* tag = ServerInstance->Config->ConfValue(\"randomnotice\");\n+\t\tstd::string n_file = tag->getString(\"file\", \"data/randomnotices.db\");","path":"2.0/m_randomnotice.cpp","position":89,"original_position":89,"commit_id":"8873ff23ae1a77122803013a2a3183915cea28c6","original_commit_id":"8873ff23ae1a77122803013a2a3183915cea28c6","user":{"login":"SaberUK","id":1565825,"avatar_url":"https://avatars1.githubusercontent.com/u/1565825?v=4","gravatar_id":"","url":"https://api.github.com/users/SaberUK","html_url":"https://github.com/SaberUK","followers_url":"https://api.github.com/users/SaberUK/followers","following_url":"https://api.github.com/users/SaberUK/following{/other_user}","gists_url":"https://api.github.com/users/SaberUK/gists{/gist_id}","starred_url":"https://api.github.com/users/SaberUK/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SaberUK/subscriptions","organizations_url":"https://api.github.com/users/SaberUK/orgs","repos_url":"https://api.github.com/users/SaberUK/repos","events_url":"https://api.github.com/users/SaberUK/events{/privacy}","received_events_url":"https://api.github.com/users/SaberUK/received_events","type":"User","site_admin":false},"body":"The database should be in the conf directory and should end in .txt for consistency with other text files like motd.txt and rules.txt.","created_at":"2018-04-06T13:49:33Z","updated_at":"2018-04-06T13:49:33Z","html_url":"https://github.com/inspircd/inspircd-extras/pull/137#discussion_r179763288","pull_request_url":"https://api.github.com/repos/inspircd/inspircd-extras/pulls/137","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/inspircd/inspircd-extras/pulls/comments/179763288"},"html":{"href":"https://github.com/inspircd/inspircd-extras/pull/137#discussion_r179763288"},"pull_request":{"href":"https://api.github.com/repos/inspircd/inspircd-extras/pulls/137"}}},"pull_request":{"url":"https://api.github.com/repos/inspircd/inspircd-extras/pulls/137","id":179931071,"html_url":"https://github.com/inspircd/inspircd-extras/pull/137","diff_url":"https://github.com/inspircd/inspircd-extras/pull/137.diff","patch_url":"https://github.com/inspircd/inspircd-extras/pull/137.patch","issue_url":"https://api.github.com/repos/inspircd/inspircd-extras/issues/137","number":137,"state":"open","locked":false,"title":"Add m_randomnotice - Random notices at a set interval","user":{"login":"genius3000","id":16250417,"avatar_url":"https://avatars0.githubusercontent.com/u/16250417?v=4","gravatar_id":"","url":"https://api.github.com/users/genius3000","html_url":"https://github.com/genius3000","followers_url":"https://api.github.com/users/genius3000/followers","following_url":"https://api.github.com/users/genius3000/following{/other_user}","gists_url":"https://api.github.com/users/genius3000/gists{/gist_id}","starred_url":"https://api.github.com/users/genius3000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/genius3000/subscriptions","organizations_url":"https://api.github.com/users/genius3000/orgs","repos_url":"https://api.github.com/users/genius3000/repos","events_url":"https://api.github.com/users/genius3000/events{/privacy}","received_events_url":"https://api.github.com/users/genius3000/received_events","type":"User","site_admin":false},"body":"A re-work of insp20's vendor module m_randquote.\r\nModified to send on an interval setting instead of on connect or with a command.\r\nStill reads from a file and keeps the suffix and prefix options.\r\n\r\nResolves #42 ","created_at":"2018-04-06T12:12:17Z","updated_at":"2018-04-06T13:49:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c684d776bfa41958a5f63bba505cdfbd6500f9f5","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/inspircd/inspircd-extras/pulls/137/commits","review_comments_url":"https://api.github.com/repos/inspircd/inspircd-extras/pulls/137/comments","review_comment_url":"https://api.github.com/repos/inspircd/inspircd-extras/pulls/comments{/number}","comments_url":"https://api.github.com/repos/inspircd/inspircd-extras/issues/137/comments","statuses_url":"https://api.github.com/repos/inspircd/inspircd-extras/statuses/8873ff23ae1a77122803013a2a3183915cea28c6","head":{"label":"genius3000:master+add_randomnotice","ref":"master+add_randomnotice","sha":"8873ff23ae1a77122803013a2a3183915cea28c6","user":{"login":"genius3000","id":16250417,"avatar_url":"https://avatars0.githubusercontent.com/u/16250417?v=4","gravatar_id":"","url":"https://api.github.com/users/genius3000","html_url":"https://github.com/genius3000","followers_url":"https://api.github.com/users/genius3000/followers","following_url":"https://api.github.com/users/genius3000/following{/other_user}","gists_url":"https://api.github.com/users/genius3000/gists{/gist_id}","starred_url":"https://api.github.com/users/genius3000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/genius3000/subscriptions","organizations_url":"https://api.github.com/users/genius3000/orgs","repos_url":"https://api.github.com/users/genius3000/repos","events_url":"https://api.github.com/users/genius3000/events{/privacy}","received_events_url":"https://api.github.com/users/genius3000/received_events","type":"User","site_admin":false},"repo":{"id":67380009,"name":"inspircd-extras","full_name":"genius3000/inspircd-extras","owner":{"login":"genius3000","id":16250417,"avatar_url":"https://avatars0.githubusercontent.com/u/16250417?v=4","gravatar_id":"","url":"https://api.github.com/users/genius3000","html_url":"https://github.com/genius3000","followers_url":"https://api.github.com/users/genius3000/followers","following_url":"https://api.github.com/users/genius3000/following{/other_user}","gists_url":"https://api.github.com/users/genius3000/gists{/gist_id}","starred_url":"https://api.github.com/users/genius3000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/genius3000/subscriptions","organizations_url":"https://api.github.com/users/genius3000/orgs","repos_url":"https://api.github.com/users/genius3000/repos","events_url":"https://api.github.com/users/genius3000/events{/privacy}","received_events_url":"https://api.github.com/users/genius3000/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/genius3000/inspircd-extras","description":"Extra modules for InspIRCd.","fork":true,"url":"https://api.github.com/repos/genius3000/inspircd-extras","forks_url":"https://api.github.com/repos/genius3000/inspircd-extras/forks","keys_url":"https://api.github.com/repos/genius3000/inspircd-extras/keys{/key_id}","collaborators_url":"https://api.github.com/repos/genius3000/inspircd-extras/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/genius3000/inspircd-extras/teams","hooks_url":"https://api.github.com/repos/genius3000/inspircd-extras/hooks","issue_events_url":"https://api.github.com/repos/genius3000/inspircd-extras/issues/events{/number}","events_url":"https://api.github.com/repos/genius3000/inspircd-extras/events","assignees_url":"https://api.github.com/repos/genius3000/inspircd-extras/assignees{/user}","branches_url":"https://api.github.com/repos/genius3000/inspircd-extras/branches{/branch}","tags_url":"https://api.github.com/repos/genius3000/inspircd-extras/tags","blobs_url":"https://api.github.com/repos/genius3000/inspircd-extras/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/genius3000/inspircd-extras/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/genius3000/inspircd-extras/git/refs{/sha}","trees_url":"https://api.github.com/repos/genius3000/inspircd-extras/git/trees{/sha}","statuses_url":"https://api.github.com/repos/genius3000/inspircd-extras/statuses/{sha}","languages_url":"https://api.github.com/repos/genius3000/inspircd-extras/languages","stargazers_url":"https://api.github.com/repos/genius3000/inspircd-extras/stargazers","contributors_url":"https://api.github.com/repos/genius3000/inspircd-extras/contributors","subscribers_url":"https://api.github.com/repos/genius3000/inspircd-extras/subscribers","subscription_url":"https://api.github.com/repos/genius3000/inspircd-extras/subscription","commits_url":"https://api.github.com/repos/genius3000/inspircd-extras/commits{/sha}","git_commits_url":"https://api.github.com/repos/genius3000/inspircd-extras/git/commits{/sha}","comments_url":"https://api.github.com/repos/genius3000/inspircd-extras/comments{/number}","issue_comment_url":"https://api.github.com/repos/genius3000/inspircd-extras/issues/comments{/number}","contents_url":"https://api.github.com/repos/genius3000/inspircd-extras/contents/{+path}","compare_url":"https://api.github.com/repos/genius3000/inspircd-extras/compare/{base}...{head}","merges_url":"https://api.github.com/repos/genius3000/inspircd-extras/merges","archive_url":"https://api.github.com/repos/genius3000/inspircd-extras/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/genius3000/inspircd-extras/downloads","issues_url":"https://api.github.com/repos/genius3000/inspircd-extras/issues{/number}","pulls_url":"https://api.github.com/repos/genius3000/inspircd-extras/pulls{/number}","milestones_url":"https://api.github.com/repos/genius3000/inspircd-extras/milestones{/number}","notifications_url":"https://api.github.com/repos/genius3000/inspircd-extras/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/genius3000/inspircd-extras/labels{/name}","releases_url":"https://api.github.com/repos/genius3000/inspircd-extras/releases{/id}","deployments_url":"https://api.github.com/repos/genius3000/inspircd-extras/deployments","created_at":"2016-09-05T02:03:23Z","updated_at":"2018-04-03T04:09:28Z","pushed_at":"2018-04-06T12:11:22Z","git_url":"git://github.com/genius3000/inspircd-extras.git","ssh_url":"git@github.com:genius3000/inspircd-extras.git","clone_url":"https://github.com/genius3000/inspircd-extras.git","svn_url":"https://github.com/genius3000/inspircd-extras","homepage":"http://inspircd.github.com","size":504,"stargazers_count":1,"watchers_count":1,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"inspircd:master","ref":"master","sha":"3717df61512679cc2fda2b66a471b7e029d05754","user":{"login":"inspircd","id":1560750,"avatar_url":"https://avatars0.githubusercontent.com/u/1560750?v=4","gravatar_id":"","url":"https://api.github.com/users/inspircd","html_url":"https://github.com/inspircd","followers_url":"https://api.github.com/users/inspircd/followers","following_url":"https://api.github.com/users/inspircd/following{/other_user}","gists_url":"https://api.github.com/users/inspircd/gists{/gist_id}","starred_url":"https://api.github.com/users/inspircd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inspircd/subscriptions","organizations_url":"https://api.github.com/users/inspircd/orgs","repos_url":"https://api.github.com/users/inspircd/repos","events_url":"https://api.github.com/users/inspircd/events{/privacy}","received_events_url":"https://api.github.com/users/inspircd/received_events","type":"Organization","site_admin":false},"repo":{"id":3786321,"name":"inspircd-extras","full_name":"inspircd/inspircd-extras","owner":{"login":"inspircd","id":1560750,"avatar_url":"https://avatars0.githubusercontent.com/u/1560750?v=4","gravatar_id":"","url":"https://api.github.com/users/inspircd","html_url":"https://github.com/inspircd","followers_url":"https://api.github.com/users/inspircd/followers","following_url":"https://api.github.com/users/inspircd/following{/other_user}","gists_url":"https://api.github.com/users/inspircd/gists{/gist_id}","starred_url":"https://api.github.com/users/inspircd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inspircd/subscriptions","organizations_url":"https://api.github.com/users/inspircd/orgs","repos_url":"https://api.github.com/users/inspircd/repos","events_url":"https://api.github.com/users/inspircd/events{/privacy}","received_events_url":"https://api.github.com/users/inspircd/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/inspircd/inspircd-extras","description":"Extra modules for InspIRCd.","fork":false,"url":"https://api.github.com/repos/inspircd/inspircd-extras","forks_url":"https://api.github.com/repos/inspircd/inspircd-extras/forks","keys_url":"https://api.github.com/repos/inspircd/inspircd-extras/keys{/key_id}","collaborators_url":"https://api.github.com/repos/inspircd/inspircd-extras/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/inspircd/inspircd-extras/teams","hooks_url":"https://api.github.com/repos/inspircd/inspircd-extras/hooks","issue_events_url":"https://api.github.com/repos/inspircd/inspircd-extras/issues/events{/number}","events_url":"https://api.github.com/repos/inspircd/inspircd-extras/events","assignees_url":"https://api.github.com/repos/inspircd/inspircd-extras/assignees{/user}","branches_url":"https://api.github.com/repos/inspircd/inspircd-extras/branches{/branch}","tags_url":"https://api.github.com/repos/inspircd/inspircd-extras/tags","blobs_url":"https://api.github.com/repos/inspircd/inspircd-extras/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/inspircd/inspircd-extras/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/inspircd/inspircd-extras/git/refs{/sha}","trees_url":"https://api.github.com/repos/inspircd/inspircd-extras/git/trees{/sha}","statuses_url":"https://api.github.com/repos/inspircd/inspircd-extras/statuses/{sha}","languages_url":"https://api.github.com/repos/inspircd/inspircd-extras/languages","stargazers_url":"https://api.github.com/repos/inspircd/inspircd-extras/stargazers","contributors_url":"https://api.github.com/repos/inspircd/inspircd-extras/contributors","subscribers_url":"https://api.github.com/repos/inspircd/inspircd-extras/subscribers","subscription_url":"https://api.github.com/repos/inspircd/inspircd-extras/subscription","commits_url":"https://api.github.com/repos/inspircd/inspircd-extras/commits{/sha}","git_commits_url":"https://api.github.com/repos/inspircd/inspircd-extras/git/commits{/sha}","comments_url":"https://api.github.com/repos/inspircd/inspircd-extras/comments{/number}","issue_comment_url":"https://api.github.com/repos/inspircd/inspircd-extras/issues/comments{/number}","contents_url":"https://api.github.com/repos/inspircd/inspircd-extras/contents/{+path}","compare_url":"https://api.github.com/repos/inspircd/inspircd-extras/compare/{base}...{head}","merges_url":"https://api.github.com/repos/inspircd/inspircd-extras/merges","archive_url":"https://api.github.com/repos/inspircd/inspircd-extras/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/inspircd/inspircd-extras/downloads","issues_url":"https://api.github.com/repos/inspircd/inspircd-extras/issues{/number}","pulls_url":"https://api.github.com/repos/inspircd/inspircd-extras/pulls{/number}","milestones_url":"https://api.github.com/repos/inspircd/inspircd-extras/milestones{/number}","notifications_url":"https://api.github.com/repos/inspircd/inspircd-extras/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/inspircd/inspircd-extras/labels{/name}","releases_url":"https://api.github.com/repos/inspircd/inspircd-extras/releases{/id}","deployments_url":"https://api.github.com/repos/inspircd/inspircd-extras/deployments","created_at":"2012-03-21T12:38:31Z","updated_at":"2018-04-03T04:04:36Z","pushed_at":"2018-04-06T12:12:18Z","git_url":"git://github.com/inspircd/inspircd-extras.git","ssh_url":"git@github.com:inspircd/inspircd-extras.git","clone_url":"https://github.com/inspircd/inspircd-extras.git","svn_url":"https://github.com/inspircd/inspircd-extras","homepage":"http://inspircd.github.com","size":472,"stargazers_count":56,"watchers_count":56,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":51,"mirror_url":null,"archived":false,"open_issues_count":21,"license":null,"forks":51,"open_issues":21,"watchers":56,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/inspircd/inspircd-extras/pulls/137"},"html":{"href":"https://github.com/inspircd/inspircd-extras/pull/137"},"issue":{"href":"https://api.github.com/repos/inspircd/inspircd-extras/issues/137"},"comments":{"href":"https://api.github.com/repos/inspircd/inspircd-extras/issues/137/comments"},"review_comments":{"href":"https://api.github.com/repos/inspircd/inspircd-extras/pulls/137/comments"},"review_comment":{"href":"https://api.github.com/repos/inspircd/inspircd-extras/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/inspircd/inspircd-extras/pulls/137/commits"},"statuses":{"href":"https://api.github.com/repos/inspircd/inspircd-extras/statuses/8873ff23ae1a77122803013a2a3183915cea28c6"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"SaberUK"}}