githubirchandler.py 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #! /usr/bin/env python
  2. # -*- coding: utf8 -*-
  3. #
  4. # gitlab irc sender
  5. # Copyright (C) 2016-2017 Andrei Karas (4144)
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 3 of the License, or
  10. # any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. from code.configuration import Configuration
  20. from code.core import Core
  21. class GithubIrcHandler():
  22. def printBuildFailed(self, channel, project, branch, data, commit, url, description):
  23. Core.messageHandler.add(channel, Configuration.irc_github_build_failed_message.format(
  24. project = project,
  25. shortid = commit[:Configuration.commit_size],
  26. branch = branch,
  27. url = url,
  28. description = description
  29. ))
  30. def printBuildSuccess(self, channel, project, branch, data, commit, url, description):
  31. Core.messageHandler.add(channel, Configuration.irc_github_build_success_message.format(
  32. project = project,
  33. shortid = commit[:Configuration.commit_size],
  34. branch = branch,
  35. url = url,
  36. description = description
  37. ))
  38. def printCustomMessage(self, channel, message):
  39. Core.messageHandler.add(channel, message)
  40. def printIssuesOpened(self, channel, project, data, url, iid, title):
  41. Core.messageHandler.add(channel, Configuration.irc_github_issues_opened_message.format(
  42. project = project,
  43. url = url,
  44. author = data["sender"]["login"],
  45. title = title,
  46. id = iid
  47. ))
  48. def printIssuesEdited(self, channel, project, data, url, iid, title):
  49. Core.messageHandler.add(channel, Configuration.irc_github_issues_edited_message.format(
  50. project = project,
  51. url = url,
  52. author = data["sender"]["login"],
  53. title = title,
  54. id = iid
  55. ))
  56. def printIssuesClosed(self, channel, project, data, url, iid, title):
  57. Core.messageHandler.add(channel, Configuration.irc_github_issues_closed_message.format(
  58. project = project,
  59. url = url,
  60. author = data["sender"]["login"],
  61. title = title,
  62. id = iid
  63. ))
  64. def printIssuesReopened(self, channel, project, data, url, iid, title):
  65. Core.messageHandler.add(channel, Configuration.irc_github_issues_reopened_message.format(
  66. project = project,
  67. url = url,
  68. author = data["sender"]["login"],
  69. title = title,
  70. id = iid
  71. ))
  72. def printIssueCommentCreated(self, channel, project, data, url, iid, title):
  73. Core.messageHandler.add(channel, Configuration.irc_github_issue_comment_created_message.format(
  74. project = project,
  75. url = url,
  76. author = data["sender"]["login"],
  77. title = title,
  78. id = iid
  79. ))
  80. def printIssueCommentEdited(self, channel, project, data, url, iid, title):
  81. Core.messageHandler.add(channel, Configuration.irc_github_issue_comment_edited_message.format(
  82. project = project,
  83. url = url,
  84. author = data["sender"]["login"],
  85. title = title,
  86. id = iid
  87. ))
  88. def printIssueCommentDeleted(self, channel, project, data, url, iid, title):
  89. Core.messageHandler.add(channel, Configuration.irc_github_issue_comment_deleted_message.format(
  90. project = project,
  91. url = url,
  92. author = data["sender"]["login"],
  93. title = title,
  94. id = iid
  95. ))