Add first draft of toot functionality
This commit is contained in:
parent
46fdcc85a0
commit
42fbd78b64
1
bot.py
1
bot.py
|
@ -54,6 +54,7 @@ class CosmicBot(teambot.Handler):
|
||||||
state["known"].extend(newpost(x) for x in newtrans)
|
state["known"].extend(newpost(x) for x in newtrans)
|
||||||
for trans in newtrans:
|
for trans in newtrans:
|
||||||
self.say(state["channel"],"Transmission received: {transmission.title} ({transmission.link})".format(transmission=trans))
|
self.say(state["channel"],"Transmission received: {transmission.title} ({transmission.link})".format(transmission=trans))
|
||||||
|
toot.toot("Transmission received: {transmission.title}\n\n{transmission.link}".format(transmission=trans))
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
return state
|
return state
|
||||||
def on_pubmsg(self,channel,nick,text):
|
def on_pubmsg(self,channel,nick,text):
|
||||||
|
|
|
@ -1,22 +1,45 @@
|
||||||
certifi==2020.4.5.1
|
appdirs>=1.4.3
|
||||||
chardet==3.0.4
|
blurhash>=1.1.4
|
||||||
feedparser==5.2.1
|
CacheControl>=0.12.6
|
||||||
idna==2.9
|
certifi>=2020.6.20
|
||||||
inflect==2.1.0
|
chardet>=3.0.4
|
||||||
irc==17.0
|
colorama>=0.4.3
|
||||||
jaraco.classes==1.5
|
contextlib2>=0.6.0
|
||||||
jaraco.collections==1.6.0
|
decorator>=4.4.2
|
||||||
jaraco.functools==1.20
|
distlib>=0.3.0
|
||||||
jaraco.itertools==3.0.0
|
distro>=1.4.0
|
||||||
jaraco.logging==1.5.2
|
feedparser>=5.2.1
|
||||||
jaraco.stream==1.2
|
html5lib>=1.0.1
|
||||||
jaraco.text==1.10.1
|
idna>=2.10
|
||||||
more-itertools==4.3.0
|
inflect>=4.1.0
|
||||||
pytz==2018.7
|
ipaddr>=2.2.0
|
||||||
requests==2.23.0
|
irc>=19.0.1
|
||||||
six==1.11.0
|
jaraco.classes>=3.1.0
|
||||||
teambot==0.2.0
|
jaraco.collections>=3.0.0
|
||||||
tempora==1.14
|
jaraco.functools>=3.0.1
|
||||||
titlecase==0.12.0
|
jaraco.itertools>=5.0.0
|
||||||
tracery==0.1.1
|
jaraco.logging>=3.0.0
|
||||||
urllib3==1.25.9
|
jaraco.stream>=3.0.0
|
||||||
|
jaraco.text>=3.2.0
|
||||||
|
lockfile>=0.12.2
|
||||||
|
Mastodon.py>=1.5.1
|
||||||
|
more-itertools>=8.5.0
|
||||||
|
msgpack>=0.6.2
|
||||||
|
packaging>=20.3
|
||||||
|
pep517>=0.8.2
|
||||||
|
progress>=1.5
|
||||||
|
pyparsing>=2.4.6
|
||||||
|
python-dateutil>=2.8.1
|
||||||
|
python-magic>=0.4.18
|
||||||
|
pytoml>=0.1.21
|
||||||
|
pytz>=2020.1
|
||||||
|
regex>=2020.7.14
|
||||||
|
requests>=2.24.0
|
||||||
|
retrying>=1.3.3
|
||||||
|
six>=1.14.0
|
||||||
|
teambot>=0.2.0
|
||||||
|
tempora>=4.0.0
|
||||||
|
titlecase>=1.1.1
|
||||||
|
tracery>=0.1.1
|
||||||
|
urllib3>=1.25.10
|
||||||
|
webencodings>=0.5.1
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
from mastodon import Mastodon
|
||||||
|
from os.path import exists
|
||||||
|
from os import chmod, stat
|
||||||
|
from stat import ST_MODE
|
||||||
|
|
||||||
|
def getmod(fn):
|
||||||
|
return stat(fn)[ST_MODE] & 0777
|
||||||
|
|
||||||
|
if not exists("usercred.secret"):
|
||||||
|
if not exists("clientcred.secret"):
|
||||||
|
Mastodon.create_app("cosmicbot toots",api_base_url="https://tilde.zone",to_file="clientcred.secret")
|
||||||
|
chmod("clientcred.secret",0600)
|
||||||
|
elif getmod("clientcred.secret")!=0600:
|
||||||
|
chmod("clientcred.secret",0600)
|
||||||
|
tmp = Mastodon(client_id="clientcred.secret",api_base_url="https://tilde.zone")
|
||||||
|
with open("details.secret") as f:
|
||||||
|
tmp.log_in(f.readline().strip(),f.readline.strip(),to_file="usercred.secret")
|
||||||
|
chmod("usercred.secret",0600)
|
||||||
|
elif getmod("usercred.secret")!=0600:
|
||||||
|
chmod("usercred.secret",0600)
|
||||||
|
|
||||||
|
m = Mastodon(access_token='usercred.secret',api_base_url="https://tilde.zone")
|
||||||
|
|
||||||
|
def toot(msg):
|
||||||
|
m.toot(msg)
|
Loading…
Reference in New Issue