Last active
September 10, 2019 11:05
-
-
Save bowlercaptain/755d92de7639e45fdde350e7685389ca to your computer and use it in GitHub Desktop.
boopstodon
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
#! /usr/bin/env python3 | |
import os | |
from time import sleep | |
smolbeep = 35 | |
freq = 440 | |
errfreq = 220 | |
farnsadd = 400 | |
letterdict = { | |
"a":".-", | |
"b":"-...", | |
"c":"-.-.", | |
"d":"-..", | |
"e":".", | |
"f":"..-.", | |
"g":"--.", | |
"h":"....", | |
"i":"..", | |
"j":".---", | |
"k":"-.-", | |
"l":".-..", | |
"m":"--", | |
"n":"-.", | |
"o":"---", | |
"p":".--.", | |
"q":"--.-", | |
"r":".-.", | |
"s":"...", | |
"t":"-", | |
"u":"..-", | |
"v":"...-", | |
"w":".--", | |
"x":"-..-", | |
"y":"-.--", | |
"z":"--..", | |
"0":"-----", | |
"1":".----", | |
"2":"..---", | |
"3":"...--", | |
"4":"....-", | |
"5":".....", | |
"6":"-....", | |
"7":"--...", | |
"8":"---..", | |
"9":"----.", | |
".":".-.-.-", | |
",":"--..--", | |
"?":"..--..", | |
" ":" " | |
} | |
def beep(letter): | |
if letter in letterdict: | |
morse = letterdict[letter] | |
for symb in morse: | |
if symb == ".": | |
os.popen("beep -f "+str(freq)+" -l " + str(smolbeep)) | |
sleep(smolbeep/1000*2) | |
elif symb == "-": | |
os.popen("beep -f "+str(freq)+" -l " + str(smolbeep * 3)) | |
sleep(smolbeep/1000*4) | |
elif symb == " ": | |
sleep(smolbeep/1000*7) | |
else: | |
os.popen("beep -f "+str(errfreq)+" -l "+str(smolbeep)) | |
sleep(smolbeep/1000*2) | |
else: | |
os.popen("beep -f "+str(errfreq)+" -l "+str(smolbeep * 3)) | |
sleep(smolbeep/1000*4) | |
sleep(smolbeep/1000*2+farnsadd/1000) | |
def beepline(line): | |
for c in line.lower(): | |
beep(c) | |
if __name__ == "__main__": | |
while(True): | |
line = input() | |
beepline(line) | |
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
#!/usr/bin/env python3 | |
from mastodon import Mastodon, StreamListener as MastoStreamListener | |
import os.path | |
import beeper | |
import re | |
instanceBaseURL = "https://cybre.space" | |
if ( not os.path.isfile("boopstodon_clientcred.secret")): | |
Mastodon.create_app( | |
'boopstodon', | |
api_base_url = instanceBaseURL, | |
to_file = 'boopstodon_clientcred.secret' | |
) | |
if ( not os.path.isfile("boopstodon_usercred.secret")): | |
mastodon = Mastodon( | |
client_id = 'boopstodon_clientcred.secret', | |
api_base_url = instanceBaseURL | |
) | |
mastodon.log_in( | |
input('electronic... mail: '), | |
input('passworc: '), | |
to_file='boopstodon_usercred.secret' | |
) | |
else: | |
mastodon = Mastodon( | |
client_id = 'boopstodon_clientcred.secret', | |
access_token = 'boopstodon_usercred.secret', | |
api_base_url = instanceBaseURL | |
) | |
def striptags(line): | |
return re.sub('<[^<]+?>', '', line) | |
#mastodon.debug_requests=True | |
myInfo = mastodon.account_verify_credentials() | |
accountNum = myInfo["id"] | |
class StreamListener(MastoStreamListener): | |
def on_update(self,status): | |
# print(status['reblog']) | |
# if((not status['reblog']) and status['visibility']=='public'): | |
if(not status['reblog']): | |
print(status['account']['username']) | |
beeper.beepline(status['account']['username']) | |
print(striptags(status['content'])) | |
beeper.beepline(striptags(status['content'])) | |
# else: | |
# print("(nonpublic toot) "+status['visibility']) | |
#print("ret2go") | |
mastodon.stream_user(StreamListener()) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment