Created
December 28, 2013 18:29
-
-
Save noisy/8162495 to your computer and use it in GitHub Desktop.
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
# -*- coding: utf-8 -*- | |
import wykop | |
import re | |
from datetime import datetime, timedelta | |
import time | |
def main(): | |
cointags = ['bitcoin', 'junkcoin', 'zerocoin', 'worldcoin', 'kryptowaluty', 'digitalcoin', 'earthcoin', 'emunie', 'argentum', 'zetacoin', 'grandcoin', 'netcoin', 'mastercoin', 'elacoin', 'memorycoin', 'datacoin', 'peercoin', 'feathercoin', 'btc', 'cryptogenic', 'ripple', 'bbqcoin', 'catcoin', 'goldcoin', 'i0coin', 'ezcoin', 'infinitecoin', 'novacoin', 'ixcoin', 'casinocoin', 'phoenixcoin', 'stablecoin', 'joulecoin', 'freicoin', 'fastcoin', 'bytecoin', 'sexcoin', 'deutsche emark', 'bitcurex', 'primecoin', 'hobonickels', 'unobtanium', 'mining', 'diamond', 'terracoin', 'protoshares', 'anoncoin', 'devcoin', 'namecoin', 'yacoin', 'quark', 'noirbits', 'bitcoinowyjanusz', 'spots', 'lottocoin', 'globalcoin', 'cryptsy', 'craftcoin', 'orbitcoin', 'copperlark', 'tickets', 'nxt', 'dogecoinmarket', 'litecoin', 'mincoin', 'gamecoin', 'tagcoin', 'florincoin', 'franko', 'altcoin', 'betacoin', 'tigercoin', 'ltc', 'dogecoinpool', 'philosopher stones', 'dogecoin', 'luckycoin', 'bitbar', 'lennycoin', 'megacoin'] | |
msg = u"@%(author)s: Szanujmy się! Wszystkie wpisy z tagów związanych z kryptowalutami powinny być także opatrzone jednym wspolnym tagiem - #kryptowaluty. Dzięki temu wszyscy inni pozostali użytkownicy wykopu będą mogli ignorować wszystkie inne #sramcoin.y które się dopiero pojawią za pomocą jednego tagu, #kryptowaluty właśnie!" | |
APPKEY="" | |
SECRETKEY="" | |
LOGIN = 'bitcoinbot' | |
ACCOUNTKEY="" | |
api = wykop.WykopAPI(APPKEY, SECRETKEY) | |
api.authenticate(LOGIN, ACCOUNTKEY) | |
cointags = list(set(cointags)) | |
while True: | |
entries = api.search_entries(""); | |
entries = [ entry for entry in entries if datetime.strptime(entry['date'], '%Y-%m-%d %H:%M:%S') > (datetime.now() - timedelta(minutes=1)) and entry['type'] == 'entry'] | |
for entry in entries: | |
tags = re.findall("\#[a-z]+", entry['body']) | |
tags = [t.replace("#","") for t in tags] | |
if any(coin in tags for coin in cointags) and "kryptowaluty" not in tags and all(comment["author"] != LOGIN for comment in entry["comments"]): | |
api.add_entry_comment(entry['id'], msg%entry, None) | |
print entry["body"] | |
print msg | |
time.sleep(5) | |
print "ok!" | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment