def create_wykop_api(): if os.path.isfile(KEYS_FILE_NAME): keys = read_keys_from_file() api = MultiKeyWykopAPI(keys, output='clear') else: key, secret, account_key = read_keys_from_envs() api = WykopAPI(key, secret, account_key=account_key, output='clear') api.authenticate() return api
def test_connection_with_login_and_password(self): login = os.environ.get('WYKOP_TAKTYK_BOT_LOGIN') password = os.environ.get('WYKOP_TAKTYK_BOT_PASSWORD') api = WykopAPI(ANDROID_APPKEY) api.authenticate(login=login, password=password) conversations = api.conversations_list() assert isinstance(conversations, list)
def create_base_client(): key = os.environ.get('WYKOP_TAKTYK_KEY') secret = os.environ.get('WYKOP_TAKTYK_SECRET') account_key = os.environ.get('WYKOP_TAKTYK_ACCOUNTKEY') return WykopAPI(key, secret, output='clear', account_key=account_key)
import datetime import os import re import time import logging from typing import NoReturn, Tuple from wykop import WykopAPI key = os.environ.get('WYKOP_TAKTYK_KEY') secret = os.environ.get('WYKOP_TAKTYK_SECRET') api = WykopAPI(key, secret, output='clear') def remove_tags(text) -> str: return re.sub(r'#(\w*[0-9a-zA-Z]+\w*[0-9a-zA-Z])', '', text) def remove_nicknames(text) -> str: return re.sub(r'@(\w*[0-9a-zA-Z]+\w*[0-9a-zA-Z]:)', '', text) def remove_empty_lines_and_format(text: str) -> str: return '\n'.join( [line.strip() for line in text.split("\n") if line.strip()]) def filter_to_short(text, min_words=5) -> str: return '\n'.join([ line for line in text.split('\n') if len(line.split(' ')) >= min_words
def get_key(self): self.wykop = WykopAPI(appkey=self.keys[self.key_index][0], secretkey=self.keys[self.key_index][1])