Skip to content

Commit 197f9be

Browse files
committed
first commit
0 parents  commit 197f9be

9 files changed

+525
-0
lines changed

.gitignore

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
5+
# C extensions
6+
*.so
7+
8+
# Distribution / packaging
9+
.Python
10+
env/
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
lib/
17+
lib64/
18+
parts/
19+
sdist/
20+
var/
21+
*.egg-info/
22+
.installed.cfg
23+
*.egg
24+
25+
# PyInstaller
26+
# Usually these files are written by a python script from a template
27+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
28+
*.manifest
29+
*.spec
30+
31+
# Installer logs
32+
pip-log.txt
33+
pip-delete-this-directory.txt
34+
35+
# Unit test / coverage reports
36+
htmlcov/
37+
.tox/
38+
.coverage
39+
.cache
40+
nosetests.xml
41+
coverage.xml
42+
.mypy_cache
43+
44+
# Translations
45+
*.mo
46+
*.pot
47+
48+
# Django stuff:
49+
*.log
50+
51+
# Sphinx documentation
52+
docs/_build/
53+
54+
# PyBuilder
55+
target/
56+
57+
# virtualenv
58+
bin/
59+
include/
60+
local/
61+
share/
62+
lib64
63+
pyvenv.cfg
64+
pip-selfcheck.json
65+
66+
67+
# settings
68+
settings.yml
69+
.htaccess
70+
71+
# RopeOpenProject
72+
.ropeproject/
73+
74+
# data
75+
*sqlite*

FavwatchLogModel.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ts=4 sw=4 sts=4 ff=unix ft=python expandtab
3+
4+
import datetime
5+
from peewee import *
6+
7+
favwatch_log = Proxy()
8+
9+
10+
class BaseModel(Model):
11+
class Meta:
12+
database = favwatch_log
13+
14+
15+
class FavLog(BaseModel):
16+
fav_by_screen_name = TextField()
17+
fav_rough_seen = DateTimeField(default=datetime.datetime.now)
18+
19+
screen_name = TextField(null=True)
20+
name = TextField(null=True)
21+
id_str = TextField(null=False, index=True)
22+
text = TextField(null=True)
23+
fav_created_at = DateTimeField(default=datetime.datetime.now)
24+
25+
class Meta:
26+
db_table = 'log'
27+
indexes = (
28+
(('screen_name', 'id_str'), False),
29+
)

Makefile

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.PHONY: test clean setup deploy status lint
2+
3+
run:
4+
./bin/python favwatch.py
5+
6+
test:
7+
rm -f tmp.sqlite
8+
./bin/python tests.py
9+
10+
clean:
11+
find . -name "*.py[co]" -delete
12+
rm -rf *sqlite* __pycache__ .mypy_cache
13+
14+
setup:
15+
python3 -m venv .
16+
./bin/pip install -r requirements.txt
17+
18+
update_packages:
19+
./bin/pip install -r requirements.txt
20+
21+
lint:
22+
./bin/flake8 favwatch.py
23+
./bin/mypy favwatch.py

README.rst

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
=================
2+
TwitterFavWatcher
3+
=================
4+
5+
6+
Overview
7+
========
8+
9+
this is a bot that quickly detect the Favoritting of someone's Twitter account, and post it to the chat.
10+
11+
12+
Description
13+
===========
14+
15+
how to work
16+
-----------
17+
18+
1. Get someone's twitter favoritting via Twitter REST API
19+
2. Take diff previous one
20+
3. Post new one to Slack or Lingr via bot API
21+
22+
23+
Requirements
24+
============
25+
26+
- Your Twitter account (dev.twitter.com)
27+
- Notitication destination:: Slack or Lingr
28+
- Python 3
29+
30+
- venv
31+
- peewee
32+
- tweepy
33+
34+
35+
how to setup
36+
============
37+
38+
1. clone this repo to some directory
39+
2. % cp settings.yml.skel settings.yml
40+
3. CREATE YOUR TWITTER APP
41+
4. setup your Webhook to your Slack
42+
5. setup your Lingr bot (optional)
43+
6. edit settings.yml and those apikeys
44+
7. % make setup
45+
8. % make run
46+
47+
48+
Author
49+
======
50+
51+
Akira KUMAGAI <[email protected]>
52+
53+
54+
License
55+
=======
56+
57+
MIT
58+
59+
60+

0 commit comments

Comments
 (0)