{"action":"created","comment":{"url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/pulls/comments/190511381","pull_request_review_id":122900633,"id":190511381,"diff_hunk":"@@ -0,0 +1,148 @@\n+package pkg\n+\n+import (\n+\t\"time\"\n+\t\"os\"\n+\t\"io/ioutil\"\n+\t\"encoding/csv\"\n+\t\"bytes\"\n+\t\"io\"\n+\t\"strings\"\n+\t\"errors\"\n+\t\"log\"\n+)\n+\n+const DB_FILE = \"calendar_db.csv\"\n+const DB_COLUMNS = \"date,title,description\\n\"\n+const DB_COLUMNS_TITLE = \"Date\\tTitle\\tDesc.\"\n+\n+type Calendar interface {\n+\tAdd(date time.Time, title, description string) (string, error)\n+\tList(date time.Time) (string, error)\n+\tRemove(title string) (string, error)\n+}\n+\n+type CalendarImp struct {\n+\n+}\n+\n+func (calendar *CalendarImp) Add(date time.Time, title, description string) (string, error) {\n+\tcreateDbIfNeeded()\n+\tfile, err := os.OpenFile(DB_FILE, os.O_WRONLY|os.O_APPEND, 0755)\n+\tif err != nil {\n+\t\treturn \"\", err\n+\t}\n+\tdefer file.Close()\n+\twriter := csv.NewWriter(file)\n+\tdefer writer.Flush()\n+\n+\trecord := []string{\n+\t\tdate.Format(\"02/01/2006\"),\n+\t\ttitle,\n+\t\tdescription,\n+\t}\n+\tlog.Print(\"CalendarImp.Add(): record = \")\n+\tlog.Print(record)\n+\n+\terr = writer.Write(record)\n+\tif err != nil {\n+\t\treturn \"\", err\n+\t}\n+\treturn \"Event added!\", nil\n+}\n+\n+func (calendar *CalendarImp) List(date time.Time) (string, error){\n+\tretStr := DB_COLUMNS_TITLE\n+\t// retStr += \"date = \" + date.Format(\"02/01/2006\")\n+\treader, err := calendar.readDb()\n+\tif err != nil {\n+\t\treturn \"\", err\n+\t}\n+\tfor {\n+\t\tlog.Print(\"List(): reading record\")\n+\t\trecord, err := reader.Read()\n+\t\tif err == io.EOF {\n+\t\t\tlog.Print(\"List(): EOF\")\n+\t\t\tbreak;\n+\t\t}\n+\t\tif err != nil {\n+\t\t\treturn \"\", err\n+\t\t}\n+\t\tretStr += \"\\n\"\n+\t\tretStr += strings.Join(record, \"\\t\")\n+\t}\n+\treturn retStr, nil\n+}\n+\n+func (calendar *CalendarImp) Remove(title string) (string, error) {\n+\tlog.Print(\"Remove()\")\n+\treader, err := calendar.readDb()\n+\tif err != nil {\n+\t\treturn \"\", err\n+\t}\n+\tfile, err := os.OpenFile(DB_FILE, os.O_RDWR, 0755)\n+\tif err != nil {\n+\t\treturn \"\", err\n+\t}\n+\tdefer file.Close()\n+\twriter := csv.NewWriter(file)\n+\tdefer writer.Flush()\n+\t/*header, err := reader.Read()\n+\tif err != nil {\n+\t\treturn \"\", err\n+\t}\n+\twriter.Write(header)*/\n+\tfound := false\n+\tfor {\n+\t\trecord, err := reader.Read()\n+\t\tif err == io.EOF {\n+\t\t\tbreak;\n+\t\t}\n+\t\tif err != nil {\n+\t\t\treturn \"\", err\n+\t\t}\n+\t\tif record[1] != title {\n+\t\t\terror := writer.Write(record)\n+\t\t\tif error != nil {\n+\t\t\t\treturn \"\", error\n+\t\t\t}\n+\t\t\tlog.Print(\"'\" + record[1] + \"' != '\" + title + \"'\")\n+\t\t} else {","path":"plugins/calendar/pkg/calendarImp.go","position":106,"original_position":110,"commit_id":"7240460cb23d0583e8899d07b8fe1f948d410fe5","original_commit_id":"2b4de6115d9848551b61f58307aea59a17f7641d","user":{"login":"DiSiqueira","id":683170,"avatar_url":"https://avatars3.githubusercontent.com/u/683170?v=4","gravatar_id":"","url":"https://api.github.com/users/DiSiqueira","html_url":"https://github.com/DiSiqueira","followers_url":"https://api.github.com/users/DiSiqueira/followers","following_url":"https://api.github.com/users/DiSiqueira/following{/other_user}","gists_url":"https://api.github.com/users/DiSiqueira/gists{/gist_id}","starred_url":"https://api.github.com/users/DiSiqueira/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DiSiqueira/subscriptions","organizations_url":"https://api.github.com/users/DiSiqueira/orgs","repos_url":"https://api.github.com/users/DiSiqueira/repos","events_url":"https://api.github.com/users/DiSiqueira/events{/privacy}","received_events_url":"https://api.github.com/users/DiSiqueira/received_events","type":"User","site_admin":false},"body":"So you can use `continue` instead of `break`.","created_at":"2018-05-24T08:57:34Z","updated_at":"2018-05-24T08:57:34Z","html_url":"https://github.com/DiSiqueira/UltraSlackBot/pull/1#discussion_r190511381","pull_request_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/pulls/1","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/pulls/comments/190511381"},"html":{"href":"https://github.com/DiSiqueira/UltraSlackBot/pull/1#discussion_r190511381"},"pull_request":{"href":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/pulls/1"}},"in_reply_to_id":190350737},"pull_request":{"url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/pulls/1","id":189835577,"html_url":"https://github.com/DiSiqueira/UltraSlackBot/pull/1","diff_url":"https://github.com/DiSiqueira/UltraSlackBot/pull/1.diff","patch_url":"https://github.com/DiSiqueira/UltraSlackBot/pull/1.patch","issue_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/issues/1","number":1,"state":"open","locked":false,"title":"Adding Calendar Plugin","user":{"login":"vmcarvalho","id":11527462,"avatar_url":"https://avatars2.githubusercontent.com/u/11527462?v=4","gravatar_id":"","url":"https://api.github.com/users/vmcarvalho","html_url":"https://github.com/vmcarvalho","followers_url":"https://api.github.com/users/vmcarvalho/followers","following_url":"https://api.github.com/users/vmcarvalho/following{/other_user}","gists_url":"https://api.github.com/users/vmcarvalho/gists{/gist_id}","starred_url":"https://api.github.com/users/vmcarvalho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmcarvalho/subscriptions","organizations_url":"https://api.github.com/users/vmcarvalho/orgs","repos_url":"https://api.github.com/users/vmcarvalho/repos","events_url":"https://api.github.com/users/vmcarvalho/events{/privacy}","received_events_url":"https://api.github.com/users/vmcarvalho/received_events","type":"User","site_admin":false},"body":"Simple plugin to keep a list of events containing a date, title and description","created_at":"2018-05-23T01:44:33Z","updated_at":"2018-05-24T08:57:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"38d67f098a590fbab2d1439d225be64783d1a92b","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/pulls/1/commits","review_comments_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/pulls/1/comments","review_comment_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/pulls/comments{/number}","comments_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/issues/1/comments","statuses_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/statuses/7240460cb23d0583e8899d07b8fe1f948d410fe5","head":{"label":"vmcarvalho:master","ref":"master","sha":"7240460cb23d0583e8899d07b8fe1f948d410fe5","user":{"login":"vmcarvalho","id":11527462,"avatar_url":"https://avatars2.githubusercontent.com/u/11527462?v=4","gravatar_id":"","url":"https://api.github.com/users/vmcarvalho","html_url":"https://github.com/vmcarvalho","followers_url":"https://api.github.com/users/vmcarvalho/followers","following_url":"https://api.github.com/users/vmcarvalho/following{/other_user}","gists_url":"https://api.github.com/users/vmcarvalho/gists{/gist_id}","starred_url":"https://api.github.com/users/vmcarvalho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmcarvalho/subscriptions","organizations_url":"https://api.github.com/users/vmcarvalho/orgs","repos_url":"https://api.github.com/users/vmcarvalho/repos","events_url":"https://api.github.com/users/vmcarvalho/events{/privacy}","received_events_url":"https://api.github.com/users/vmcarvalho/received_events","type":"User","site_admin":false},"repo":{"id":133871143,"name":"UltraSlackBot","full_name":"vmcarvalho/UltraSlackBot","owner":{"login":"vmcarvalho","id":11527462,"avatar_url":"https://avatars2.githubusercontent.com/u/11527462?v=4","gravatar_id":"","url":"https://api.github.com/users/vmcarvalho","html_url":"https://github.com/vmcarvalho","followers_url":"https://api.github.com/users/vmcarvalho/followers","following_url":"https://api.github.com/users/vmcarvalho/following{/other_user}","gists_url":"https://api.github.com/users/vmcarvalho/gists{/gist_id}","starred_url":"https://api.github.com/users/vmcarvalho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmcarvalho/subscriptions","organizations_url":"https://api.github.com/users/vmcarvalho/orgs","repos_url":"https://api.github.com/users/vmcarvalho/repos","events_url":"https://api.github.com/users/vmcarvalho/events{/privacy}","received_events_url":"https://api.github.com/users/vmcarvalho/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vmcarvalho/UltraSlackBot","description":null,"fork":true,"url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot","forks_url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot/forks","keys_url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot/teams","hooks_url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot/hooks","issue_events_url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot/issues/events{/number}","events_url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot/events","assignees_url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot/assignees{/user}","branches_url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot/branches{/branch}","tags_url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot/tags","blobs_url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot/git/refs{/sha}","trees_url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot/statuses/{sha}","languages_url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot/languages","stargazers_url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot/stargazers","contributors_url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot/contributors","subscribers_url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot/subscribers","subscription_url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot/subscription","commits_url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot/commits{/sha}","git_commits_url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot/git/commits{/sha}","comments_url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot/comments{/number}","issue_comment_url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot/issues/comments{/number}","contents_url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot/contents/{+path}","compare_url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot/merges","archive_url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot/downloads","issues_url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot/issues{/number}","pulls_url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot/pulls{/number}","milestones_url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot/milestones{/number}","notifications_url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot/labels{/name}","releases_url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot/releases{/id}","deployments_url":"https://api.github.com/repos/vmcarvalho/UltraSlackBot/deployments","created_at":"2018-05-17T21:39:38Z","updated_at":"2018-05-24T01:02:42Z","pushed_at":"2018-05-24T01:02:40Z","git_url":"git://github.com/vmcarvalho/UltraSlackBot.git","ssh_url":"git@github.com:vmcarvalho/UltraSlackBot.git","clone_url":"https://github.com/vmcarvalho/UltraSlackBot.git","svn_url":"https://github.com/vmcarvalho/UltraSlackBot","homepage":null,"size":40,"stargazers_count":0,"watchers_count":0,"language":"Go","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":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"DiSiqueira:master","ref":"master","sha":"63268b19f468e21b8528e80b08184a53e3b3fefa","user":{"login":"DiSiqueira","id":683170,"avatar_url":"https://avatars3.githubusercontent.com/u/683170?v=4","gravatar_id":"","url":"https://api.github.com/users/DiSiqueira","html_url":"https://github.com/DiSiqueira","followers_url":"https://api.github.com/users/DiSiqueira/followers","following_url":"https://api.github.com/users/DiSiqueira/following{/other_user}","gists_url":"https://api.github.com/users/DiSiqueira/gists{/gist_id}","starred_url":"https://api.github.com/users/DiSiqueira/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DiSiqueira/subscriptions","organizations_url":"https://api.github.com/users/DiSiqueira/orgs","repos_url":"https://api.github.com/users/DiSiqueira/repos","events_url":"https://api.github.com/users/DiSiqueira/events{/privacy}","received_events_url":"https://api.github.com/users/DiSiqueira/received_events","type":"User","site_admin":false},"repo":{"id":131194044,"name":"UltraSlackBot","full_name":"DiSiqueira/UltraSlackBot","owner":{"login":"DiSiqueira","id":683170,"avatar_url":"https://avatars3.githubusercontent.com/u/683170?v=4","gravatar_id":"","url":"https://api.github.com/users/DiSiqueira","html_url":"https://github.com/DiSiqueira","followers_url":"https://api.github.com/users/DiSiqueira/followers","following_url":"https://api.github.com/users/DiSiqueira/following{/other_user}","gists_url":"https://api.github.com/users/DiSiqueira/gists{/gist_id}","starred_url":"https://api.github.com/users/DiSiqueira/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DiSiqueira/subscriptions","organizations_url":"https://api.github.com/users/DiSiqueira/orgs","repos_url":"https://api.github.com/users/DiSiqueira/repos","events_url":"https://api.github.com/users/DiSiqueira/events{/privacy}","received_events_url":"https://api.github.com/users/DiSiqueira/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/DiSiqueira/UltraSlackBot","description":null,"fork":false,"url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot","forks_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/forks","keys_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/teams","hooks_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/hooks","issue_events_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/issues/events{/number}","events_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/events","assignees_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/assignees{/user}","branches_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/branches{/branch}","tags_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/tags","blobs_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/git/refs{/sha}","trees_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/statuses/{sha}","languages_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/languages","stargazers_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/stargazers","contributors_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/contributors","subscribers_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/subscribers","subscription_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/subscription","commits_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/commits{/sha}","git_commits_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/git/commits{/sha}","comments_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/comments{/number}","issue_comment_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/issues/comments{/number}","contents_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/contents/{+path}","compare_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/merges","archive_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/downloads","issues_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/issues{/number}","pulls_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/pulls{/number}","milestones_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/milestones{/number}","notifications_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/labels{/name}","releases_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/releases{/id}","deployments_url":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/deployments","created_at":"2018-04-26T18:13:45Z","updated_at":"2018-05-22T09:33:13Z","pushed_at":"2018-05-24T01:02:41Z","git_url":"git://github.com/DiSiqueira/UltraSlackBot.git","ssh_url":"git@github.com:DiSiqueira/UltraSlackBot.git","clone_url":"https://github.com/DiSiqueira/UltraSlackBot.git","svn_url":"https://github.com/DiSiqueira/UltraSlackBot","homepage":null,"size":38,"stargazers_count":3,"watchers_count":3,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":1,"open_issues":1,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/pulls/1"},"html":{"href":"https://github.com/DiSiqueira/UltraSlackBot/pull/1"},"issue":{"href":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/issues/1"},"comments":{"href":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/DiSiqueira/UltraSlackBot/statuses/7240460cb23d0583e8899d07b8fe1f948d410fe5"}},"author_association":"NONE"}}
{"actor":{"display_login":"DiSiqueira"}}