{"id":27334873,"url":"https://github.com/dmuth/twitter-account-metrics-bot","last_synced_at":"2025-04-12T14:46:33.084Z","repository":{"id":50191300,"uuid":"191464257","full_name":"dmuth/twitter-account-metrics-bot","owner":"dmuth","description":"App to pull down tweet activity from specific accounts and send to Telegram via a bot","archived":false,"fork":false,"pushed_at":"2022-12-08T05:15:20.000Z","size":180,"stargazers_count":1,"open_issues_count":5,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-05-02T06:07:44.971Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dmuth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-11T23:30:49.000Z","updated_at":"2022-07-23T08:41:49.000Z","dependencies_parsed_at":"2023-01-24T12:15:36.337Z","dependency_job_id":null,"html_url":"https://github.com/dmuth/twitter-account-metrics-bot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmuth%2Ftwitter-account-metrics-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmuth%2Ftwitter-account-metrics-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmuth%2Ftwitter-account-metrics-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmuth%2Ftwitter-account-metrics-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dmuth","download_url":"https://codeload.github.com/dmuth/twitter-account-metrics-bot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248585247,"owners_count":21128973,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-04-12T14:46:32.325Z","updated_at":"2025-04-12T14:46:33.078Z","avatar_url":"https://github.com/dmuth.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Twitter Account Metrics Bot\n\nAn app to get metrics from Twitter accounts and report them to Telegram via a bot.\n\n\u003cimg src=\"./img/statistics.png\" width=\"150\" align=\"right\" /\u003e\n\nThis is useful for monitoring activity on organization social media accounts.\n\n\n## Requirements\n\n- Docker\n- Go to \u003ca href=\"https://developer.twitter.com/\"\u003ehttps://developer.twitter.com/\u003c/a\u003e and create an App.  Note your Consumer API Key and Secret Key.\n\n\n## Screenshots\n\n\u003ca href=\"./img/askamex-tweets-7-days.png\"\u003e\u003cimg src=\"./img/askamex-tweets-7-days.png\" alt=\"AskAmex Tweets for 7 days\" width=\"250\"/\u003e\u003c/a\u003e \u003ca href=\"./img/askamex-tweets-3-days.png\"\u003e\u003cimg src=\"./img/askamex-tweets-3-days.png\" alt=\"AskAmex Tweets for 3 days\" width=\"250\"/\u003e\u003c/a\u003e \u003ca href=\"./img/askamex-tweets-6-hours.png\"\u003e\u003cimg src=\"./img/askamex-tweets-6-hours.png\" alt=\"AskAmex Tweets for 6 hours\" width=\"250\"/\u003e\u003c/a\u003e\n\n\n## Setup\n\n- Clone this repo to your machine\n- Run `./bin/run.sh 0-get-credentials` to configure the app.  You'll need your Twiter API data, and (optionally) AWS and Telegram credentials as well.\n   - AWS credentials can be obtained from the AWS console and is beyond the scope of this document.\n   - Telegram credentials can be obtained from \u003ca href=\"https://telegram.me/BotFather\"\u003emessaging BotFather\u003c/a\u003e and following the instructions.\n- Manual usage:\n   - Run `./bin/run.sh 1-fetch-tweets` to fetch tweets and store them to `tweets.db`, which is a SQLite database.\n   - Run `./bin/run.sh 1-export-to-json` to export all tweets to `tweets.json`.\n   - Run `./bin/run.sh 2-telegram-bot` to start reporting tweet stats to Telegram\n   - Run `./bin/run.sh 2-backup-tweets` to start a script that periodically backs up the `tweets.db` file to AWS S3.\n- Normal usage:\n   - Run `docker-compose up -d` and tweets will start being downloaded with stats being written to the Telegram Channel of your user.  \n\n\n## Development\n\n- To work on a script interactively:\n   - `./bin/dev.sh` - This will launch the container with an interactive shell.\n   - Scripts live in `/mnt/bin/` on this container.\n- To download the latest backup: `./bin/aws/download-latest-backup`\n\n\n# FAQ\n\n## How do I get Telegram Group/Chat IDs?\n\nFrom \u003ca href=\"https://stackoverflow.com/a/45577773/196073\"\u003ehttps://stackoverflow.com/a/45577773/196073\u003c/a\u003e:\n- Go to your group in \u003ca href=\"https://web.telegram.org/\"\u003ethe web interface\u003c/a\u003e and grab the link. e.g. https://web.telegram.org/#/im?p=g154513121\n- Copy That number after g and put a (-) Before That. e.g. -154513121\n- Send Your Message to group. e.g. `bot.send_message(-154513121, \"Hi\")`\n\n\n## Architecture: Why A Single Docker Container?\n\nIn a past version of this app, I used to have 5 different development and run scripts spread across 4 different Docker containers, and the end result is that the `bin/` directory got  *really* unruly, holding 30 files in total, many of them very nearly identical to multiple other files.\n\nI made the conscious decision to merge 4 slightly different Dockerfiles together into a single Dockerfile.  While the single image is a bit on the large side (347 MB), I reduced the total number of files in `bin/` from 30 down to 13 *and* made my overall development and usage process simpler than it was before.  In fact, with the exception of this particular section, this entire README got _shorter_ sa a result.  I think I made a good decision here. :-)\n\n\n# Credits\n\n- \u003ca href=\"https://twython.readthedocs.io/en/latest/\"\u003eTwython\u003c/a\u003e - The Twitter client for Python, this made using Twitter's API a breeze.\n- \u003ca href=\"https://www.sqlite.org/index.html\"\u003eSQLite\u003c/a\u003e - Used for data storage.\n- \u003ca href=\"https://www.sqlalchemy.org/\"\u003eSQLAlchemy\u003c/a\u003e - This is my first project with SQLAlchemy, and it made tasks such as database schema maintenance and interacting with the database way easier to do!\n- \u003ca href=\"https://github.com/python-telegram-bot/python-telegram-bot\"\u003epython-telegram-bot\u003c/a\u003e - I use this module for connecting to Telegram, and it too makes my life much easier.\n- Icons made by \u003ca href=\"https://www.freepik.com/\" title=\"Freepik\"\u003eFreepik\u003c/a\u003e from \u003ca href=\"https://www.flaticon.com/\" title=\"Flaticon\"\u003ewww.flaticon.com\u003c/a\u003e is licensed by \u003ca href=\"http://creativecommons.org/licenses/by/3.0/\"  title=\"Creative Commons BY 3.0\" target=\"_blank\"\u003eCC 3.0 BY\u003c/a\u003e\n\n# Author\n\nMyself, Douglas Muth.  Ways you can get in touch with me:\n- \u003ca href=\"http://www.dmuth.org/\"\u003eMy website\u003c/a\u003e\n- \u003ca href=\"http://twitter.com/dmuth\"\u003eTwitter\u003c/a\u003e\n- \u003ca href=\"http://facebook.com/dmuth\"\u003eFacebook\u003c/a\u003e\n- ...or just file a bug on this repo!\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmuth%2Ftwitter-account-metrics-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdmuth%2Ftwitter-account-metrics-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmuth%2Ftwitter-account-metrics-bot/lists"}