Skip to content

Instantly share code, notes, and snippets.

@YuzuRyo61
Created February 11, 2018 05:27
Show Gist options
  • Save YuzuRyo61/51b171348dc59a868ec00b4f1ce4ef1d to your computer and use it in GitHub Desktop.
Save YuzuRyo61/51b171348dc59a868ec00b4f1ce4ef1d to your computer and use it in GitHub Desktop.
動作しないPythonのトゥートスクリプト。中途半端すぎるので動きません。助けて。
import os,sys, traceback, warnings, re
from mastodon import Mastodon
class Toot():
def __init__(self):
with open("instance.txt") as a:
self.address = a.readlines()
toot = ""
self.tootl = ""
mastodon = Mastodon(
client_id = "key.txt",
access_token = "userkey.txt",
api_base_url = str(self.address[0])
)
def select(self):
pass
def input(self):
self.non_bmp_map = dict.fromkeys(range(0x10000, sys.maxunicode + 1), 0x0000)
try:
print("Ctrl-C to exit\n' . ' to toot")
while True:
self.toot = ""
self.tootl = ""
while self.tootl != " . ":
tootl = ""
tootl = tootl.translate(self.non_bmp_map)
tootl = input(u"> ")
print(tootl)
if self.tootl != " . ":
toot = toot + tootl + "\n"
print(toot)
if self.toot != "":
mastodon.toot(str(toot))
print("OK")
else:
print("You can't toot no character.")
print(self.toot)
except KeyboardInterrupt:
pass
except:
print("FATAL: \n" + traceback.format_exc())
if __name__ == '__main__':
main = Toot()
main.select()
main.input()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment