All Projects → iamroshanpoudel → Botvid 19

iamroshanpoudel / Botvid 19

Licence: mit
Messenger Bot that scrapes for COVID-19 data and periodically updates subscribers via Facebook Messages. Created using Python/Flask, MYSQL, HTML, Heroku

Programming Languages

python
139335 projects - #7 most used programming language
python3
1442 projects

Projects that are alternatives of or similar to Botvid 19

Shorty
🔗 A URL shortening service built using Flask and MySQL
Stars: ✭ 78 (+129.41%)
Mutual labels:  mysql, flask, webapp
Laconia
🏺 ‎ A minimalist MVC framework.
Stars: ✭ 307 (+802.94%)
Mutual labels:  mysql, webapp
Kamifaka
一款基于VUE3.0的开源免费的卡密发卡系统,高效、稳定可靠。
Stars: ✭ 253 (+644.12%)
Mutual labels:  mysql, flask
Cancer Donation Portal Python Flask App
Flask App for Cancer Donation Portal using basic Python, SQLite3, HTML, CSS and Javascript
Stars: ✭ 32 (-5.88%)
Mutual labels:  flask, webapp
bots-zoo
No description or website provided.
Stars: ✭ 59 (+73.53%)
Mutual labels:  scraper, selenium
pluralsight scrapper
A course downloader/scrapper for https://www.pluralsight.com
Stars: ✭ 39 (+14.71%)
Mutual labels:  scraper, selenium
Enferno
A Python framework based on Flask microframework, with batteries included, and best practices in mind.
Stars: ✭ 385 (+1032.35%)
Mutual labels:  mysql, flask
messenger-bot
A Node bot server for the Facebook Messenger Platform
Stars: ✭ 23 (-32.35%)
Mutual labels:  messenger-bot, facebook-messenger-bot
Python Spider
豆瓣电影top250、斗鱼爬取json数据以及爬取美女图片、淘宝、有缘、CrawlSpider爬取红娘网相亲人的部分基本信息以及红娘网分布式爬取和存储redis、爬虫小demo、Selenium、爬取多点、django开发接口、爬取有缘网信息、模拟知乎登录、模拟github登录、模拟图虫网登录、爬取多点商城整站数据、爬取微信公众号历史文章、爬取微信群或者微信好友分享的文章、itchat监听指定微信公众号分享的文章
Stars: ✭ 615 (+1708.82%)
Mutual labels:  mysql, selenium
Price Monitor
京东商品价格监控:监控用户设定商品价格,降价邮件/微信提醒。技术:Python爬虫/IP代理池/JS接口爬取/Selenium页面爬取
Stars: ✭ 634 (+1764.71%)
Mutual labels:  mysql, selenium
Bowtie
Create a dashboard with python!
Stars: ✭ 724 (+2029.41%)
Mutual labels:  flask, webapp
messenger
💬 A PHP library for Facebook Messenger
Stars: ✭ 53 (+55.88%)
Mutual labels:  messenger-bot, facebook-messenger-bot
kick-off-web-scraping-python-selenium-beautifulsoup
A tutorial-based introduction to web scraping with Python.
Stars: ✭ 18 (-47.06%)
Mutual labels:  scraper, selenium
Instagram-Scraper-2021
Scrape Instagram content and stories anonymously, using a new technique based on the har file (No Token + No public API).
Stars: ✭ 57 (+67.65%)
Mutual labels:  scraper, selenium
Instagram-Comments-Scraper
Instagram comment scraper using python and selenium. Save the comments into excel.
Stars: ✭ 73 (+114.71%)
Mutual labels:  scraper, selenium
Microblog
A microblogging web application written in Python and Flask that I developed as part of my Flask Mega-Tutorial series.
Stars: ✭ 3,788 (+11041.18%)
Mutual labels:  flask, webapp
Keras Flask Deploy Webapp
😺 Pretty & simple image classifier app template. Deploy your own trained model or pre-trained model (VGG, ResNet, Densenet) to a web app using Flask in 10 minutes.
Stars: ✭ 856 (+2417.65%)
Mutual labels:  flask, webapp
InstagramLocationScraper
No description or website provided.
Stars: ✭ 13 (-61.76%)
Mutual labels:  scraper, selenium
yt-videos-list
Create and **automatically** update a list of all videos on a YouTube channel (in txt/csv/md form) via YouTube bot with end-to-end web scraping - no API tokens required. Multi-threaded support for YouTube videos list updates.
Stars: ✭ 64 (+88.24%)
Mutual labels:  scraper, selenium
Mormot
Synopse mORMot ORM/SOA/MVC framework
Stars: ✭ 607 (+1685.29%)
Mutual labels:  mysql, webapp

BOTVID-19

Note:

Initially, there were two repositories for this messenger bot: BOTVID-19 (private repo) & BOTVID-20 (public repo). Based on the feedback received from u/warpedspoon, both of these repositories have been merged to a single repository: BOTVID-19 (public repo). This repository is linked to the live version of the bot, and thus, any changes to the files here will be reflected in the bot.

System Architecture and working

The bot has several components:

  1. Heroku with automatic deployment from Github enabled
  2. MYSQL server using ClearDB MY SQL addon for Heroku
  3. Facebook Messenger page Botvid-19 on Messenger
  4. Website to scrape for data WorldOMeters

Each of these components interact with each other for the bot to function properly.

What this bot solves? / Motivation

I found myself checking this website frequently to get updates about what was the current situation in each state. Visiting this website took some time as I had to open my browser, type in the URL, and go to specific country. I wondered if there was a way to automate things so that I could save myself from visiting the website above. This gave birth to the idea of a messenger bot.

How users interact with the bot

  • The user visits the messenger page for this bot. Click here
  • The user sends 'update' to the bot via messenger
  • The bot fetches scraped data from its MYSQL database and responds back to the user
  • The bot also handles basic user inputs like 'hi' or 'hello'
  • The bot cannot handle non-text messages like emojis or pictures and thus, responds accordingly
  • The bot also has message subscription feature built in. Users can send 'subscribe' and 'unsubscribe' to subscribe/unsubscribe for periodic updates from the bot. This feature, though implemented, is currently broken due to the limitations imposed by facebook on who the bot can send message to.
  • The bot prevents subsribed users from subscribing again or unsubscribed users from unsubscribing.

Admin commands for the bot

To make it easier for the admins to check how many users are using the subsciption feature, some commands are built to work within messenger. This saves the admins from having to check the MYSQL database.

  • 'sudo status' responds back with some greeting if the bot is working. To check whether the bot is working or not, users may send anything to the bot. However, 'sudo status' is a more formal way for admins to check whether the bot is working or not.
  • 'sudo gtu' responds back with total number of users who have subscribed to the bot. 'subscribe' will increment and 'unsubscribe' will decrement the total user number which is the return value of 'sudo gtu'
  • 'sudo gu' responds back with user ids of users subscribed to the bot. This will help in troubleshooting some database errors
  • 'sudo _' sudo followed by any random text will generate 'unrecognized admin command' response.

How everything works under the hood

  • The code for the bot resides in this Github repo
  • The App is deployed in Heroku, and any changes to the code will trigger a new build of the app in Heroku, which will be automatically deployed
  • botvid.py contains the flask app. It is the core of this app. It handles:
    1. webhooks for checking if the message was sent from specified messenger page
    2. HTML handling for index, and privacy-policy page
    3. subscription, messages sending and receiving
  • authenticate.py contains sensitive info. about database credentials, Facebook tokens, and Admin user ids. authenticate.py is used everytime there is need for some authentication
  • scrapy.py scrapes for data from the specified website, calls other .py files to update data in database
  • state_database.py contains methods to interact with state table in the database. The methods include adding new state, updating state cases, updating state deaths, fetching state cases, etc.
  • user_database.py contains methods to interact with user table in the database. The methods include adding new user, removing a user, counting total users, getting a list of users, etc.
  • MYSQL database contains two tables:
    1. user table: Stores user ids only
    2. state table: stores state name, state abbreviation, previous cases, current cases, previous deaths, and current deaths
  • script.py is set to be run every 10 minutes using Heroku scheduler. This will call scrape.py to update the database contents, and users subscribed to the bot will also be sent an update message. (* The latter part of this feature is currently broken due to Facebook restrictions)
  • console.py: lets admins interact with the database using terminal. console.py uses args to call different methods from different .py files:
    1. python3 console.py 'help' -> prints available commands
    2. python3 console.py 'get_users()' -> prints a list of users from the database
    3. python3 console.py 'get_total_users()' -> prints the total number of subscribers in the database
    4. python3 console.py 'get_update_data()' -> prints what users get when they send 'update'
    5. python3 console.py 'get_all_state_data()' -> prints everything stored in the state table in MYSQL database
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].