This repository has been archived by the owner on Jun 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0.7.0 / 2017-06-22 ================== * Using VPS & Telegram bot * Update requests from 2.17.3 to 2.18.1 (#96) * Home page renders with or without releases * Scheduled daily dependency update on tuesday (#95)
- Loading branch information
Showing
41 changed files
with
611 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
bunqweb.com { | ||
proxy / localhost:8000 | ||
} | ||
|
||
www.bunqweb.com { | ||
proxy / localhost:8000 | ||
} |
20 changes: 20 additions & 0 deletions
20
Manager/migrations/0012_historicalcatagories_history_change_reason.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.11.2 on 2017-06-13 13:55 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('Manager', '0011_historicalcatagories'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='historicalcatagories', | ||
name='history_change_reason', | ||
field=models.CharField(max_length=100, null=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class BunqBotConfig(AppConfig): | ||
name = 'bunq_bot' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from bunq_bot.automatic_messages.updates_.news_updates import NewsUpdates | ||
from bunq_bot.automatic_messages.updates_.together_updates import \ | ||
TogetherUpdates | ||
|
||
|
||
class Updates(): | ||
def __init__(self, bot): | ||
self.bot = bot | ||
|
||
def send_updates(self): | ||
NewsUpdates(self._bot).send_updates() | ||
TogetherUpdates(self._bot).send_updates() | ||
# self.send_updates() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import feedparser | ||
import telegram | ||
from trender import TRender | ||
from html.parser import HTMLParser | ||
from bunq_bot.models import BunqNews, ChatInfo | ||
|
||
|
||
class NewsUpdates(): | ||
|
||
_url = 'https://www.bunq.com/en/news/feed.rss' | ||
_feed = feedparser.parse(_url) | ||
|
||
def __init__(self, bot): | ||
self._bot = bot | ||
|
||
def send_updates(self): | ||
titles = list(BunqNews.objects.all().values_list('title', | ||
flat=True)) | ||
for item in self._feed['items']: | ||
if not item['title'] in titles: | ||
self._send_upadte(item) | ||
self._save_in_database(item) | ||
|
||
def _save_in_database(self, item): | ||
c = BunqNews(title=item['title'], author=item['author']) | ||
c.save() | ||
|
||
def _send_upadte(self, item): | ||
chat_ids = list(ChatInfo.objects.all().values_list('chat_id', | ||
flat=True)) | ||
|
||
for chat_id in chat_ids: | ||
self._bot.send_message( | ||
chat_id=chat_id, | ||
text=self._text(item), | ||
parse_mode=telegram.ParseMode.MARKDOWN | ||
) | ||
|
||
def _text(self, item): | ||
s = MLStripper() | ||
s.feed(item['summary']) | ||
item['summary'] = s.get_data() | ||
|
||
with open('bunq_bot/responses/automatic_messages/news_feed.md', | ||
'r') as f: | ||
return TRender(f.read()).render({'item': item}) | ||
|
||
|
||
class MLStripper(HTMLParser): | ||
def __init__(self): | ||
super().__init__() | ||
self.reset() | ||
self.fed = [] | ||
|
||
def handle_data(self, d): | ||
self.fed.append(d) | ||
|
||
def get_data(self): | ||
return ''.join(self.fed) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import feedparser | ||
import telegram | ||
from trender import TRender | ||
from html.parser import HTMLParser | ||
from bunq_bot.models import BunqTogether, ChatInfo | ||
|
||
|
||
class TogetherUpdates(): | ||
|
||
_url = 'https://together.bunq.com/rss' | ||
_feed = feedparser.parse(_url) | ||
|
||
def __init__(self, bot): | ||
self._bot = bot | ||
|
||
def send_updates(self): | ||
titles = list(BunqTogether.objects.all().values_list('title', | ||
flat=True)) | ||
for item in self._feed['items']: | ||
if not item['title'] in titles: | ||
try: | ||
self._send_upadte(item) | ||
except telegram.error.BadRequest: | ||
self._send_upadte(item, False) | ||
finally: | ||
self._save_in_database(item['title']) | ||
|
||
def _save_in_database(self, title): | ||
c = BunqTogether(title=title) | ||
c.save() | ||
|
||
def _send_upadte(self, item, summary=True): | ||
chat_ids = list(ChatInfo.objects.all().values_list('chat_id', | ||
flat=True)) | ||
|
||
for chat_id in chat_ids: | ||
self._bot.send_message( | ||
chat_id=chat_id, | ||
text=self._text(item, summary), | ||
parse_mode=telegram.ParseMode.MARKDOWN | ||
) | ||
|
||
def _text(self, item, summary=True): | ||
s = MLStripper() | ||
s.feed(item['summary']) | ||
item['summary'] = s.get_data() | ||
|
||
with open('bunq_bot/responses/automatic_messages/together_feed.md', | ||
'r') as f: | ||
return TRender(f.read()).render({'item': item, | ||
'summary': summary}) | ||
|
||
|
||
class MLStripper(HTMLParser): | ||
def __init__(self): | ||
super().__init__() | ||
self.reset() | ||
self.fed = [] | ||
|
||
def handle_data(self, d): | ||
self.fed.append(d) | ||
|
||
def get_data(self): | ||
return ''.join(self.fed) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
def help(): | ||
with open('bunq_bot/responses/commands/help.md', 'r') as f: | ||
return f.read() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import feedparser | ||
from trender import TRender | ||
# from pprint import pprint | ||
from html.parser import HTMLParser | ||
|
||
|
||
def news(): | ||
url = 'https://www.bunq.com/en/news/feed.rss' | ||
feed = feedparser.parse(url) | ||
|
||
data = [] | ||
for item in feed['items']: | ||
s = MLStripper() | ||
s.feed(item['summary']) | ||
obj = { | ||
'title': item['title'], | ||
'date': item['published'], | ||
'summary': s.get_data(), | ||
'link': item['link'], | ||
'author': item['author'] | ||
} | ||
data.append(obj) | ||
with open('bunq_bot/responses/commands/news.md', 'r') as f: | ||
return TRender(f.read()).render({'data': data[:5]}) | ||
|
||
|
||
class MLStripper(HTMLParser): | ||
def __init__(self): | ||
super().__init__() | ||
self.reset() | ||
self.fed = [] | ||
|
||
def handle_data(self, d): | ||
self.fed.append(d) | ||
|
||
def get_data(self): | ||
return ''.join(self.fed) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
def start(): | ||
with open('bunq_bot/responses/commands/start.md') as f: | ||
return f.read() |
Oops, something went wrong.