├── .github ├── ISSUE_TEMPLATE │ ├── bug.md │ ├── documentation.md │ ├── features.md │ ├── proposal.md │ └── question.md ├── pull_request_template.md ├── reviewer_config.yml └── workflows │ ├── auto-assign.yml │ ├── auto-reviewer.yml │ └── greetings.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── Dockerfile ├── LICENSE ├── README.md ├── action.yml ├── img ├── White and Green Gaming Badge Logo.png └── sample.jpeg ├── requirements.txt └── src └── main.py /.github/ISSUE_TEMPLATE/bug.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 🐛 Bug Report 3 | about: Submit a bug report to help us improve 4 | labels: "bug" 5 | --- 6 | 7 | ## 🐛 Bug Report 8 | 9 | (A clear and concise description of what the bug is.) 10 | 11 | ### Have you read the [Contributing Guidelines on Pull Requests]()? 12 | 13 | (Write your answer here.) 14 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/documentation.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 📚 Documentation 3 | about: Report an issue related to documentation 4 | labels: "documentation" 5 | --- 6 | 7 | ## 📚 Documentation 8 | 9 | (A clear and concise description of what the issue is.) 10 | 11 | ### Have you read the [Contributing Guidelines on Pull Requests]()? 12 | 13 | (Write your answer here.) 14 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/features.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 🚀 Feature 3 | about: Submit a proposal for a new feature 4 | labels: "feature" 5 | --- 6 | 7 | ## 🚀 Feature 8 | 9 | (A clear and concise description of what the feature is.) 10 | 11 | ### Have you read the [Contributing Guidelines on Pull Requests](https://github.com/TesseractCoding/NeoAlgo/blob/master/CONTRIBUTING.md#reporting-new-issues)? 12 | 13 | (Write your answer here.) 14 | 15 | ## Motivation 16 | 17 | (Please outline the motivation for the proposal.) 18 | 19 | ## Pitch 20 | 21 | (Please explain why this feature should be implemented and how it would be used.) 22 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/proposal.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 💥 Proposal 3 | about: Propose a non-trivial change to Issue_Watcher 4 | labels: "proposal" 5 | --- 6 | 7 | ## 💥 Proposal 8 | 9 | (A clear and concise description of what the proposal is.) 10 | 11 | ### Have you read the [Contributing Guidelines on Pull Requests](https://github.com/TesseractCoding/NeoAlgo/blob/master/CONTRIBUTING.md#reporting-new-issues)? 12 | 13 | (Write your answer here.) 14 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: ❓ Questions and Help 3 | about: If you have questions, please check the below links 4 | labels: "question" 5 | --- 6 | 7 | ## ❓ Questions and Help 8 | 9 | ### Please note that this issue tracker is not a help form and this issue will be closed. 10 | 11 | Please contact us instead. 12 | 13 | - [Website](https://www.tesseractcoding.tech/) 14 | - [Email](team@tesseractcoding.tech) 15 | - [GitHub](https://github.com/TesseractCoding) 16 | - [Instagram](https://www.instagram.com/tesseractcoding/) 17 | - [LinkedIn](https://www.linkedin.com/company/tesseract-coding/) 18 | - [Medium](https://medium.com/tesseract-coding) 19 | - [Telegram](https://t.me/tesseractcoding) 20 | - [YouTube](https://www.youtube.com/c/TesseractCoding/) 21 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | 10 | 11 | ### Have you read the [Contributing Guidelines on Pull Requests]()? 12 | 13 | (Write your answer here.) 14 | 15 | ### Description 16 | 17 | (Write your answer here.) 18 | 19 | ### Checklist 20 | 21 | - [ ] I've read the contribution guidelines. 22 | - [ ] I've checked the issue list before deciding what to submit. 23 | - [ ] I've edited the `README.md` and link to my code. 24 | 25 | ## Related Issues or Pull Requests 26 | 27 | (Write your answer here.) 28 | -------------------------------------------------------------------------------- /.github/reviewer_config.yml: -------------------------------------------------------------------------------- 1 | # Set to true to add reviewers to pull requests 2 | addReviewers: true 3 | 4 | # Set to true to add assignees to pull requests 5 | addAssignees: false 6 | 7 | # A list of reviewers to be added to pull requests (GitHub user name) 8 | reviewers: 9 | - anushkrishnav 10 | - HarshCasper 11 | - iamrajiv 12 | - atarax665 -------------------------------------------------------------------------------- /.github/workflows/auto-assign.yml: -------------------------------------------------------------------------------- 1 | name: Assign 2 | 3 | on: 4 | schedule: 5 | - cron: '*/2 * * * *' 6 | issue_comment: 7 | types: [created] 8 | 9 | jobs: 10 | slash_assign: 11 | # If the acton was triggered by a new comment that starts with `/assign` 12 | # or a on a schedule 13 | if: > 14 | (github.event_name == 'issue_comment' && startsWith(github.event.comment.body, '/assign')) || 15 | github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' 16 | runs-on: ubuntu-latest 17 | steps: 18 | - name: Assign the user or unassign stale assignments 19 | uses: JasonEtco/slash-assign-action@v0.0.3 20 | with: 21 | assigned_label: Assigned 22 | days_until_warning: 7 23 | days_until_unassign: 14 24 | stale_assignment_label: Open 25 | -------------------------------------------------------------------------------- /.github/workflows/auto-reviewer.yml: -------------------------------------------------------------------------------- 1 | name: 'Auto Assign Reviewers to Pull Requests' 2 | on: 3 | pull_request: 4 | types: [opened, reopened] 5 | jobs: 6 | add-reviews: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: kentaro-m/auto-assign-action@v1.1.2 10 | with: 11 | repo-token: "${{ secrets.GITHUB_TOKEN }}" 12 | configuration-path: .github/reviewer_config.yml 13 | -------------------------------------------------------------------------------- /.github/workflows/greetings.yml: -------------------------------------------------------------------------------- 1 | name: Greetings 2 | 3 | on: 4 | issues: 5 | types: [opened] 6 | pull_request: 7 | types: [opened] 8 | 9 | jobs: 10 | greeting: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: Karthik-Nayak98/Greeting-action@main 14 | with: 15 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 16 | issue_message: 'Hello @${{github.actor}},
17 | Thank you for opening an issue. :partying_face:
18 | To get assigned to this particular issue please use /assign
19 | Check this guide before contributing.' 20 | PR_message: 21 | '

:partying_face: Congratulations :tada:

:pray: 22 | Thank you @${{github.actor}} for taking out your time and contributing to our project. Our team will now review this and if everything looks good it will be merged.' -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.env 2 | 3 | *.dist 4 | *.vscode/ -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | - Using welcoming and inclusive language 18 | - Being respectful of differing viewpoints and experiences 19 | - Gracefully accepting constructive criticism 20 | - Focusing on what is best for the community 21 | - Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | - The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | - Trolling, insulting/derogatory comments, and personal or political attacks 28 | - Public or private harassment 29 | - Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | - Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at team@tesseractcoding.tech. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | 2 | # action will be run in python3 container 3 | FROM python:3 4 | # copying requirements.txt and install the action dependencies 5 | COPY requirements.txt /requirements.txt 6 | RUN pip install -r /requirements.txt 7 | # main.py is the file that will contain the codes that we want to run for this action. 8 | COPY src/main.py /src/main.py 9 | # we will just run our main.py as our docker entrypoint by python main.py 10 | CMD ["python", "/src/main.py"] -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | The MIT License (MIT) 3 | 4 | Copyright (c) 2018 GitHub, Inc. and contributors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |


4 | 5 | # Rouge Spammers with a mission to disrupt the peace of the valley ? Fear not we will STOMP the Spammers 6 | ## New Update : adding 'on-review' tag on an issue will stop it from being closed by the Bot allowing contributors to create more than the limited count 7 | This tool was created to helps you to protect your project from being spammed. 8 |
You can customise the ``` maxIssue``` to set the maximum count of active issue a contributor can have.
9 | The project is currently a work in progress might have bugs if you do find bugs please report it [here](https://TesseractCoding/Issue_Watcher/issues)
10 | 11 | ![]() 12 | 13 | ### Example workflow 14 | 15 | ```yaml 16 | name: check 17 | 18 | on: 19 | issues: 20 | types: [opened] 21 | 22 | jobs: 23 | first-job: 24 | runs-on: ubuntu-latest 25 | steps: 26 | - name: Checkout code 27 | uses: actions/checkout@main 28 | - name: Action 29 | uses: TesseractCoding/Issue_Watcher@main 30 | with: 31 | token: ${{ secrets.GITHUB_TOKEN }} # default token in GitHub Workflow 32 | author: '${{github.actor}}' 33 | repo: {owner}/{repo} # your repo 34 | maxIssue: {any integer} #default is set as 2 35 | 36 | ``` 37 | ## Contributing Guidelines 38 | 39 | - **Plagiarism is strictly not allowed**. Any work that is found to be suspicious of plagiarized work will not be merged. 40 | - Issues will be assigned on a _first come, first serve_ basis. You just have to comment on the issue, asking to be assigned, and it will be done if found fit. 41 | - Preferably, you cannot work on any issue that is not assigned to you. 42 | - In case you want to submit an improvement , we prefer that you create an issue, describing in details your improvement. This will help others to analyze your contribution. You can use the [templates](.github/ISSUE_TEMPLATE/proposal.md) that we have provided :) 43 | - If you have anything else in mind, create an issue and please wait for it to be assigned to you. You can then start working on it and create a PR. 44 | - All PRs must be made from a Branch. Create a separate branch for every Issue you are working upon and once found fit, make a PR. 45 | - If you have no idea what are issues or PRs, please do refer to [this link](https://github.com/TesseractCoding/NeoAlgo/wiki/What-is-a-Pull-Request-and-how-to-do-it%3F) 46 | 47 | Make sure your code works before submitting it and always write test for every new function that you create or improve:D 48 | 49 | ## Our Contributors 50 | 51 | [CONTRIBUTORS.md]() 52 | 53 | ## Code of Conduct 54 | 55 | You can find our Code of Conduct [here](/CODE_OF_CONDUCT.md). 56 | 57 | # Note 58 | This project is a WIP. 59 | If you find a security threat or bug please feel free to open up an issue and we will get to it shortly 60 | 61 | ### Created by [Anush Krishna](https://github.com/anushkrishnav) 62 | 63 | # Uses 64 | 65 | ### [PyGithub](https://github.com/PyGithub/PyGithub) - Awesome package that made this action possible
66 | ### [actions/container-action](https://github.com/actions/container-action) - Container Action Template 67 | ### [jacobtomlinson/python-container-actionTemplate](https://github.com/jacobtomlinson/python-container-action) - amazing starter template 68 | 69 | # License 70 | MIT licensed. See the bundled [LICENSE](LICENSE) file for more details. 71 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | 2 | name: Issue-Watchers 3 | description: This action closes an issue based on the number of issues a person has 4 | inputs: 5 | token: # token variable available in workflow as env var named INPUT_TOKEN 6 | required: true 7 | description: Token of the user that creates the issue 8 | author: # available as INPUT_ASSIGNEES 9 | required: true 10 | description: Assignees of the issue 11 | default: '${{github.actor}}' 12 | repo: 13 | required: true 14 | description: repo url in the form owner/repo 15 | maxIssue: 16 | required : false 17 | description: set the maximum number of issues a contributor can open 18 | default: 2 19 | runs: 20 | using: docker # we are saying this action will run on docker 21 | image: 'Dockerfile' # we will use our own Dockerfile to build an image and run it. 22 | 23 | branding: #generates a logo for our action 24 | icon: monitor 25 | color: blue # background color of the logo of our action 26 | -------------------------------------------------------------------------------- /img/White and Green Gaming Badge Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anushkrishnav/Issue-Watcher/8ab95e5011fe66f470993f5976d91a6c7a1fc73e/img/White and Green Gaming Badge Logo.png -------------------------------------------------------------------------------- /img/sample.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anushkrishnav/Issue-Watcher/8ab95e5011fe66f470993f5976d91a6c7a1fc73e/img/sample.jpeg -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | certifi==2020.12.5 2 | chardet==4.0.0 3 | Deprecated==1.2.12 4 | idna==2.10 5 | PyGithub==1.54.1 6 | PyJWT==1.7.1 7 | python-dotenv==0.15.0 8 | requests==2.25.1 9 | urllib3==1.26.3 10 | wrapt==1.12.1 11 | -------------------------------------------------------------------------------- /src/main.py: -------------------------------------------------------------------------------- 1 | import os 2 | import requests 3 | import github 4 | from pprint import pprint 5 | # required to run the script locally 6 | from os.path import join, dirname 7 | from dotenv import load_dotenv 8 | dotenv_path = join(dirname(__file__), '../.env') 9 | load_dotenv(dotenv_path) 10 | 11 | 12 | def count_issues(author, token, repo): 13 | r''' 14 | A function to count the number of open Issues created by a contributor 15 | of the project. 16 | author : Github id of the contributor 17 | token : Github Token 18 | repo : Reository for which we are retriving the count 19 | ''' 20 | 21 | query_url = f"https://api.github.com/search/issues?q=is:issue+repo:{repo}+author:{author}+is:open" 22 | 23 | headers = {'Authorization': f'token {token}'} 24 | 25 | r = requests.get(query_url, headers=headers) 26 | raw = (r.json()) 27 | return raw['total_count'] 28 | 29 | 30 | def get_latest_issue(author, token, repo): 31 | r''' 32 | A function to get a contributor's latest Open Issue. 33 | author : Github id of the contributor 34 | token : Github Token 35 | repo : Reository for which we are retriving the count 36 | ''' 37 | query_url = f"https://api.github.com/search/issues?q=is:issue+repo:{repo}+author:{author}+is:open" 38 | 39 | headers = {'Authorization': f'token {token}'} 40 | 41 | r = requests.get(query_url, headers=headers) 42 | raw = (r.json()) 43 | k = raw['items'] 44 | k = k[0] 45 | label_count = len(k['labels']) 46 | if label_count != 0: 47 | for i in range(label_count): 48 | if 'on-review' in k['labels'][i]['name']: 49 | return None 50 | return k['number'] 51 | 52 | 53 | def close_issue(num, repo, maxi): 54 | r''' 55 | A function to close the issue number num 56 | and add a comment to the issue stating the reason. 57 | num : number of the issue that has to be closed 58 | repo : Reository for which we are retriving the count 59 | maxi : Maximium count of open Issue a contributor can have 60 | ''' 61 | issue = repo.get_issue(num) 62 | issue.create_comment('''## STOMP !!
![](https://pbs.twimg.com/media/EWQM1qRUEAAEVdh.jpg)
63 | ### Sorry but You cannot have more than ''' + str(maxi) + ''' issues open, kindly close or finish your current issues before you make a new one. 64 | ###
if you feel the issue is Important please tag a maintainers.
65 | ### This action is being deployed to prevent spamming of Issues,
If you are not spamming then You are doing great work Keep it up !!''') 66 | issue.edit(state='closed') 67 | return 68 | 69 | 70 | token = os.environ['INPUT_TOKEN'] 71 | author = os.environ['INPUT_AUTHOR'] 72 | repourl = os.environ['INPUT_REPO'] 73 | maxi = os.environ['INPUT_MAXISSUE'] 74 | 75 | if maxi is None : 76 | maxi = 2 77 | else: 78 | 79 | maxi = int(''.join(c for c in maxi if c.isdigit())) 80 | 81 | github = github.Github(token) 82 | repo = github.get_repo(repourl) 83 | 84 | count = count_issues(author=author, token=token, repo=repourl) 85 | 86 | numb = get_latest_issue(author=author, token=token, repo=repourl) 87 | if numb is not None: 88 | if count >= maxi+1: 89 | close_issue(numb, repo, maxi) 90 | --------------------------------------------------------------------------------