├── .gitignore
├── .idea
├── .gitignore
├── inspectionProfiles
│ ├── Project_Default.xml
│ └── profiles_settings.xml
├── misc.xml
├── modules.xml
├── vcs.xml
└── yearproggresspython.iml
├── README.md
└── main.py
/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by .ignore support plugin (hsz.mobi)
2 | ### Python templategut
3 | # Byte-compiled / optimized / DLL files
4 | __pycache__/
5 | *.py[cod]
6 | *$py.class
7 |
8 | # C extensions
9 | *.so
10 |
11 | # Distribution / packaging
12 | .Python
13 | build/
14 | develop-eggs/
15 | dist/
16 | downloads/
17 | eggs/
18 | .eggs/
19 | lib/
20 | lib64/
21 | parts/
22 | sdist/
23 | var/
24 | wheels/
25 | share/python-wheels/
26 | *.egg-info/
27 | .installed.cfg
28 | *.egg
29 | MANIFEST
30 |
31 | # PyInstaller
32 | # Usually these files are written by a python script from a template
33 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
34 | *.manifest
35 | *.spec
36 |
37 | # Installer logs
38 | pip-log.txt
39 | pip-delete-this-directory.txt
40 |
41 | # Unit test / coverage reports
42 | htmlcov/
43 | .tox/
44 | .nox/
45 | .coverage
46 | .coverage.*
47 | .cache
48 | nosetests.xml
49 | coverage.xml
50 | *.cover
51 | *.py,cover
52 | .hypothesis/
53 | .pytest_cache/
54 | cover/
55 |
56 | # Translations
57 | *.mo
58 | *.pot
59 |
60 | # Django stuff:
61 | *.log
62 | local_settings.py
63 | db.sqlite3
64 | db.sqlite3-journal
65 |
66 | # Flask stuff:
67 | instance/
68 | .webassets-cache
69 |
70 | # Scrapy stuff:
71 | .scrapy
72 |
73 | # Sphinx documentation
74 | docs/_build/
75 |
76 | # PyBuilder
77 | .pybuilder/
78 | target/
79 |
80 | # Jupyter Notebook
81 | .ipynb_checkpoints
82 |
83 | # IPython
84 | profile_default/
85 | ipython_config.py
86 |
87 | # pyenv
88 | # For a library or package, you might want to ignore these files since the code is
89 | # intended to run in multiple environments; otherwise, check them in:
90 | # .python-version
91 |
92 | # pipenv
93 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
94 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
95 | # having no cross-platform support, pipenv may install dependencies that don't work, or not
96 | # install all needed dependencies.
97 | #Pipfile.lock
98 |
99 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow
100 | __pypackages__/
101 |
102 | # Celery stuff
103 | celerybeat-schedule
104 | celerybeat.pid
105 |
106 | # SageMath parsed files
107 | *.sage.py
108 |
109 | # Environments
110 | .env
111 | .venv
112 | env/
113 | venv/
114 | ENV/
115 | env.bak/
116 | venv.bak/
117 |
118 | # Spyder project settings
119 | .spyderproject
120 | .spyproject
121 |
122 | # Rope project settings
123 | .ropeproject
124 |
125 | # mkdocs documentation
126 | /site
127 |
128 | # mypy
129 | .mypy_cache/
130 | .dmypy.json
131 | dmypy.json
132 |
133 | # Pyre type checker
134 | .pyre/
135 |
136 | # pytype static type analyzer
137 | .pytype/
138 |
139 | # Cython debug symbols
140 | cython_debug/
141 |
142 | ### macOS template
143 | # General
144 | .DS_Store
145 | .AppleDouble
146 | .LSOverride
147 |
148 | # Icon must end with two \r
149 | Icon
150 |
151 | # Thumbnails
152 | ._*
153 |
154 | # Files that might appear in the root of a volume
155 | .DocumentRevisions-V100
156 | .fseventsd
157 | .Spotlight-V100
158 | .TemporaryItems
159 | .Trashes
160 | .VolumeIcon.icns
161 | .com.apple.timemachine.donotpresent
162 |
163 | # Directories potentially created on remote AFP share
164 | .AppleDB
165 | .AppleDesktop
166 | Network Trash Folder
167 | Temporary Items
168 | .apdisk
169 |
170 | ### JetBrains template
171 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
172 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
173 |
174 | # User-specific stuff
175 | .idea/**/workspace.xml
176 | .idea/**/tasks.xml
177 | .idea/**/usage.statistics.xml
178 | .idea/**/dictionaries
179 | .idea/**/shelf
180 |
181 | # Generated files
182 | .idea/**/contentModel.xml
183 |
184 | # Sensitive or high-churn files
185 | .idea/**/dataSources/
186 | .idea/**/dataSources.ids
187 | .idea/**/dataSources.local.xml
188 | .idea/**/sqlDataSources.xml
189 | .idea/**/dynamic.xml
190 | .idea/**/uiDesigner.xml
191 | .idea/**/dbnavigator.xml
192 |
193 | # Gradle
194 | .idea/**/gradle.xml
195 | .idea/**/libraries
196 |
197 | # Gradle and Maven with auto-import
198 | # When using Gradle or Maven with auto-import, you should exclude module files,
199 | # since they will be recreated, and may cause churn. Uncomment if using
200 | # auto-import.
201 | # .idea/artifacts
202 | # .idea/compiler.xml
203 | # .idea/jarRepositories.xml
204 | # .idea/modules.xml
205 | # .idea/*.iml
206 | # .idea/modules
207 | # *.iml
208 | # *.ipr
209 |
210 | # CMake
211 | cmake-build-*/
212 |
213 | # Mongo Explorer plugin
214 | .idea/**/mongoSettings.xml
215 |
216 | # File-based project format
217 | *.iws
218 |
219 | # IntelliJ
220 | out/
221 |
222 | # mpeltonen/sbt-idea plugin
223 | .idea_modules/
224 |
225 | # JIRA plugin
226 | atlassian-ide-plugin.xml
227 |
228 | # Cursive Clojure plugin
229 | .idea/replstate.xml
230 |
231 | # Crashlytics plugin (for Android Studio and IntelliJ)
232 | com_crashlytics_export_strings.xml
233 | crashlytics.properties
234 | crashlytics-build.properties
235 | fabric.properties
236 |
237 | # Editor-based Rest Client
238 | .idea/httpRequests
239 |
240 | # Android studio 3.1+ serialized cache file
241 | .idea/caches/build_file_checksums.ser
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Datasource local storage ignored files
5 | /dataSources/
6 | /dataSources.local.xml
7 | # Editor-based HTTP Client requests
8 | /httpRequests/
9 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/yearproggresspython.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Track year progress bot
2 | [](https://forthebadge.com)
3 | [](https://forthebadge.com)
4 | [](https://forthebadge.com)
5 | [](https://forthebadge.com)
6 | [](https://forthebadge.com)
7 | [](https://forthebadge.com)
8 | [](https://forthebadge.com)
9 |
10 | ## Setup
11 | ```bash
12 | git clone https://github.com/willdoescode/twittertrackyearprogress.git
13 | ```
14 | ```bash
15 | cd yearproggresspython
16 | ```
17 | if you dont have virtualenv installed
18 | ```bash
19 | pip3 install --user virtualenv
20 | ```
21 | ```bash
22 | virtualenv venv
23 | ```
24 | ```bash
25 | pip3 install tweepy python-dotenv
26 | ```
27 | ```bash
28 | touch logs.log
29 | ```
30 | ```bash
31 | python3 main.py
32 | ```
33 | ## If you have any errors send your logs.log file to me
--------------------------------------------------------------------------------
/main.py:
--------------------------------------------------------------------------------
1 | import tweepy
2 | import os
3 | import dotenv
4 | import datetime
5 | import calendar
6 | import math
7 | import logging
8 | import time
9 | dotenv.load_dotenv()
10 |
11 | api_key = os.getenv('API_KEY')
12 | api_secret = os.getenv('API_SECRET')
13 | access_token = os.getenv('ACCESS_TOKEN')
14 | access_secret = os.getenv('ACCESS_SECRET')
15 |
16 | auth = tweepy.OAuthHandler(api_key, api_secret)
17 | auth.set_access_token(access_token, access_secret)
18 |
19 | api = tweepy.API(auth)
20 | logging.basicConfig(filename='./logs.log', level=logging.DEBUG)
21 |
22 |
23 | def get_percent():
24 | total_days = 0
25 | cursor = 1
26 | while cursor < datetime.datetime.now().month:
27 | total_days += calendar.monthrange(datetime.datetime.now().year, cursor)[1]
28 | cursor += 1
29 | total_days += datetime.datetime.now().day
30 | return math.floor(round(100 * total_days / 365, 1))
31 |
32 |
33 | def generate_progress(percent):
34 | progress = []
35 | for i in range(math.floor(percent / 5)):
36 | progress.append('▓')
37 | for i in range(20 - len(progress)):
38 | progress.append('░')
39 | progress = ''.join(progress)
40 | return progress
41 |
42 |
43 | def tweet_it():
44 | api.update_status(
45 | f'We are {get_percent()}% through the year!\n{generate_progress(get_percent())}'
46 | )
47 |
48 |
49 | if __name__ == '__main__':
50 | while True:
51 | tweet_it()
52 | time.sleep(86490)
--------------------------------------------------------------------------------