Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Noctus contribute2 #9

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.vscode
*/__pycache__
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM python:3.8-bullseye

# Set the working directory to /app
WORKDIR /code

# Copy the requirements file and install the dependencies
COPY ./requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

# Copy the source code into the container
COPY ./src ./src

# Expose port 80 to the outside world
EXPOSE 80

# Start the Flask application
# development mode
CMD ["gunicorn", "-b", "0.0.0.0:80", "--log-level", "debug", "--reload", "src.app:app"]
# production mode
# CMD ["gunicorn", "-b", "0.0.0.0:80","src.app:app"]
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,17 @@ B0Bot lives inside a Flask API and periodically it will retweet certain Twitter

# Developer Road Map

- [ ] Setup initial Flask API
- [ ] Setup initial Flask API
- Set up a Twitter developer account and create a new Twitter app to access the Twitter API.
- Create a new Flask API project, initialize it with a basic project structure, and install the necessary dependencies (e.g., Tweepy, Flask, etc.)
- [ ] Adding functionality to the Flask API
- Create a new Python script to handle the Twitter API authentication and the bot's logic. This script should use the Tweepy library to interact with the Twitter API, and it should contain the following features:
- Periodically retweet certain Twitter followers.
- Respond to user mentions and provide the latest news with the given keywords.
- [ ] Deploy the Flask API to Vercel
- Create a new Vercel project and deploy the Flask API to Vercel.
- Set up a periodic job to run the Flask API periodically.
- [ ] Creating a monitoring dashboard
- Create a new Better Uptime project and set up a monitoring dashboard to monitor the periodic job.
- Add a new webhook to the Better Uptime project to send a notification to the Bug Zero Twitter account if the periodic job fails.

10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
services:
app:
build: .
container_name: B0Bot-App
command: gunicorn -b 0.0.0.0:80 --log-level debug --reload "src.app:app" # developement
# command: gunicorn -b 0.0.0.0:80 --reload "src.app:app" # production
ports:
- 80:80
volumes:
- .:/code
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Flask==2.2.3
Werkzeug==2.2.3
gunicorn==20.1.0
11 changes: 11 additions & 0 deletions src/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from flask import Flask

def create_app():
app = Flask(__name__)

# set configuration variables here, e.g.


# register blueprints and other components here, e.g.

return app
26 changes: 26 additions & 0 deletions src/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from flask import Flask, jsonify
from src import create_app

app = create_app()

@app.route('/')
def home():
# send json response
return jsonify( {
'org': 'BugZero',
'project': 'B0Bot'
})

@app.route('/search/<query>')
def search(query):
# Code to search Twitter API for latest news on query
news = "here is the news on " + query
return jsonify( {
'news': news
})


if __name__ == '__main__':
app.run(debug=True)
else:
gunicorn_app = app