6 changed files with 156 additions and 0 deletions
@ -0,0 +1,17 @@
|
||||
install: |
||||
python setup.py install
|
||||
|
||||
clean: |
||||
python setup.py clean
|
||||
rm -rvf build *.egg-info dist
|
||||
|
||||
reinstall: |
||||
$(MAKE) clean
|
||||
$(MAKE) install
|
||||
|
||||
format: |
||||
black -v -l 80 pseudbot/*
|
||||
black -v -l 80 scripts/*
|
||||
|
||||
# Uncomment below if we ever include code examples:
|
||||
##black -v -l 80 examples/*.py
|
@ -0,0 +1,7 @@
|
||||
import typing |
||||
|
||||
from .bot import main as real_main |
||||
|
||||
|
||||
def main(args: [str], name: str) -> int: |
||||
return real_main(args=args, name=name) |
@ -0,0 +1,68 @@
|
||||
import argparse |
||||
import inspect |
||||
import json as j |
||||
import tweepy as t |
||||
import typing |
||||
|
||||
|
||||
def parse_args(args: [str], name: str): |
||||
parser = argparse.ArgumentParser(prog=name) |
||||
|
||||
parser.add_argument( |
||||
"-a", |
||||
"--action", |
||||
type=str, |
||||
default="timeline", |
||||
help="Method to call", |
||||
) |
||||
parser.add_argument( |
||||
"cfg_json", |
||||
type=argparse.FileType("r"), |
||||
help="JSON file with Twitter secrets", |
||||
) |
||||
|
||||
return parser.parse_args(args=args) |
||||
|
||||
|
||||
class PseudBot: |
||||
def __init__(self, tcfg: dict): |
||||
tauth = t.OAuthHandler(tcfg["consumer"], tcfg["consumer_secret"]) |
||||
tauth.set_access_token(tcfg["tok"], tcfg["tok_secret"]) |
||||
self.tapi = t.API(tauth) |
||||
|
||||
def jdump(self, itms, echo: bool = False): |
||||
dfname = str(inspect.stack()[1][3]) + ".dump.json" |
||||
df = open(dfname, mode="w") |
||||
|
||||
pretty = j.dumps(itms, sort_keys=True, indent=2) |
||||
if echo is True: |
||||
print(pretty) |
||||
df.write(pretty) |
||||
|
||||
df.close() |
||||
|
||||
def timeline(self): |
||||
home_tl = self.tapi.home_timeline() |
||||
jsons = [] |
||||
for tweet in home_tl: |
||||
jsons.append(tweet._json) |
||||
|
||||
self.jdump(jsons, echo=True) |
||||
|
||||
def hello(self): |
||||
self.jdump( |
||||
self.tapi.update_status( |
||||
"pseudbot is still under construction..." |
||||
)._json |
||||
) |
||||
|
||||
|
||||
def callm(pb: PseudBot, methname: str): |
||||
return getattr(pb, methname)() |
||||
|
||||
|
||||
def main(args: [str], name: str) -> int: |
||||
opts = parse_args(args=args, name=name) |
||||
|
||||
pb = PseudBot(j.loads(opts.cfg_json.read())) |
||||
callm(pb, opts.action) |
@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env python3 |
||||
from pseudbot import main |
||||
from sys import argv as ARGV |
||||
|
||||
if __name__ == "__main__": |
||||
name = ARGV.pop(0) |
||||
welcome = ( |
||||
"" |
||||
+ " ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡤⠶⢶⣶⣦⣄⡀⠀⠀\n" |
||||
+ " ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣾⣿⡄⠒⠪⢝⠻⣿⣿⣦⡀\n" |
||||
+ " ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣴⣿⡿⢉⡀⠀⠈⠐⠄⢿⣿⣿⣷\n" |
||||
+ " ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⡇⠀*⠈⡄⠤⢀⠈⣾⣿⣿⣿\n" |
||||
+ " ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡾⣿⣟⣕⡤⡠⠘⠀*⠀⢱⣿⣿⣿⣿\n" |
||||
+ " ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣾⣾⣿⣞⣄⠮⠔⠈⡢⠄⣠⣾⣿⣿⣿⣿\n" |
||||
+ " ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⢿⣿⢽⡻⣿⣿⣿⣽⣵⣾⡽⣿⣿⣿⣿⣿⡏\n" |
||||
+ " ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣗⣿⡟⠈⠉⠚⢽⣻⢷⡝⣿⡿⣿⣿⣿⣿⡿⠀\n" |
||||
+ " ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⣿⣿⠇⠀⠀⠀⠀⠀⢩⣯⣭⣾⣿⣿⣿⣿⠁⠀\n" |
||||
+ " ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⣿⣿⣿⠃⠀⠀⠀⠀⠀⣰⣿⣿⣿⣿⣿⣿⣿⠃⠀⠀\n" |
||||
+ " ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣴⣿⣿⡿⠃⠀⠀⠀⠀⣠⣼⣿⣿⣿⣿⣿⣿⣿⠃⠀⠀⠀\n" |
||||
+ " ⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⢞⣿⣿⡿⠁⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⠃⠀⠀⠀⠀\n" |
||||
+ " ⠀⠀⠀⠀⠀⠀⠀⠀⣰⣿⣾⣿⠏⠀⠀⠀⠀⣾⣿⣿⣿⣿⣿⣿⡟⣿⣿⠏⠀⠀⠀⠀⠀\n" |
||||
+ " ⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⠃⠀⠀⠀⠀⣸⣿⣿⣿⣿⣿⣟⣷⣾⣿⠏⠀⠀⠀⠀⠀⠀\n" |
||||
+ " ⠀⠀⠀⠀⢀⣾⣿⣿⣿⣿⠃⠀⠀⠀⢀⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⠋⠀⠀⠀⠀⠀⠀⠀\n" |
||||
+ " ⠀⠀⠀⡰⢿⣿⣿⣯⡶⠁⠀⠀⢀⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⠀⠀⠀⠀⠀⠀⠀⠀\n" |
||||
+ " ⠀⢀⣼⣟⣿⣿⡿⠃⠀⠀⢀⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀\n" |
||||
+ " ⢀⣾⣿⣿⡯⣿⠀⠀⢠⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n" |
||||
+ " ⣾⣿⣿⣿⣿⣿⣶⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n" |
||||
+ " ⠿⣿⡿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢿⡿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n" |
||||
+ " ⠀⠛⠀⠈⠀⠻⣿⣿⣿⣿⣿⣟⣛⣿⣿⡭⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n" |
||||
+ " ⠢⡀⠀⠀⠀⠀⠻⣿⣿⣿⣿⣿⣭⠟⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n" |
||||
+ " ⠀⠈⠐⠤⢀⡀⠀⢀⣙⣿⠿⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n" |
||||
+ "\n" |
||||
+ "___\n" |
||||
+ " | _.._ _ _ ._ _._ _ _..__|_\n" |
||||
+ "_|_ (_|| | | \/(/_|\/ _>| | |(_|| |_\n" |
||||
+ " /\n" |
||||
) |
||||
print(welcome) |
||||
|
||||
exit(main(args=ARGV, name=name)) |
@ -0,0 +1,23 @@
|
||||
from setuptools import setup |
||||
|
||||
try: |
||||
from pip import main as pipmain |
||||
except ImportError: |
||||
from pip._internal import main as pipmain |
||||
|
||||
# install_requires sucks, I don't know why and I really |
||||
# don't care, so I do this: |
||||
pipmain(["install", "-r", "requirements.txt"]) |
||||
|
||||
scripts = ["scripts/pseudbot"] |
||||
|
||||
setup( |
||||
name="pseudbot", |
||||
version="0.1", |
||||
author="Andrew Rogers", |
||||
description="Rick and Morty copypasta bot", |
||||
author_email="tuxlovesyou@gmail.com", |
||||
packages=["pseudbot"], |
||||
include_package_data=True, |
||||
scripts=scripts, |
||||
) |
Loading…
Reference in new issue