"sharedInbox": "https://{}/inbox".format(request.host)
},
"followers": "https://{}/followers".format(request.host),
+ "following": "https://{}/following".format(request.host),
"inbox": "https://{}/inbox".format(request.host),
"name": "Viera",
"type": "Application",
}
headers['signature'] = sign_headers(headers, PRIVKEY, our_key_id)
+ logging.debug('%r', headers)
+ logging.debug('%r >> %r', actor['inbox'], message)
+
async with aiohttp.ClientSession() as session:
async with session.post(actor['inbox'], data=data, headers=headers) as resp:
pass
async def follow_remote_actor(actor_uri):
+ logging.info('following: %r', actor_uri)
+
actor = await fetch_actor(actor_uri)
message = {
"@context": "https://www.w3.org/ns/activitystreams",
"type": "Follow",
"to": [actor['id']],
- "object": [actor['id']],
+ "object": actor['id'],
"id": "https://{}/activities/{}".format(AP_CONFIG['host'], uuid.uuid4()),
"actor": "https://{}/actor".format(AP_CONFIG['host'])
}
async def handle_create(actor, data, request):
# for now, we only care about Notes
- if data['object']['type'] != Note:
+ if data['object']['type'] != 'Note':
return
# strip the HTML if present
# fetch our IRC bot
bot = get_irc_bot()
- bot.relay_message(actor, data['object'], content)
+ bot.relay_message(actor, data['object'], ' '.join(content))
async def handle_follow(actor, data, request):
from blinker import signal
from . import CONFIG
+from .actor import follow_remote_actor
from .irc_envelope import RFC1459Message
from .authreqs import new_auth_req, set_irc_bot, check_auth, fetch_auth, drop_auth
return
self.say(chan, '\x02{0}\x02: \x02{1}\x02'.format(nickname, data), verb='PRIVMSG')
+ def follow(self, nickname, actor_uri):
+ asyncio.ensure_future(follow_remote_actor(actor_uri))
+ self.say(nickname, 'Following \x02{}\x02'.format(actor_uri))
+
def set_pending_action(self, nickname, action):
if nickname not in self.pending_actions:
self.pending_actions[nickname] = action
self.say(nickname, "The association of \x02{0}\x02 with \x02{1}\x02 has been dropped.".format(account, data))
elif 'whois' in action:
self.whois(nickname, action['whois'], account)
+ elif 'follow' in action:
+ logging.info('allowed follow: %r', action['follow'])
+ self.follow(nickname, action['follow'])
def handle_auth_req(self, req):
self.say(req.irc_nickname, "The actor \x02{0}\x02 is now linked to the IRC account \x02{1}\x02.".format(req.actor, req.irc_account))
elif message.params[1] in ('voice', 'invite', 'drop'):
self.set_pending_action(source_nick, message.params[1])
self.fetch_account_whox(message)
+ elif message.params[1][0:6] == 'follow':
+ chunks = message.params[1].split()
+ logging.info('considering whether to follow: %r', chunks[1])
+
+ self.set_pending_action(source_nick, {'follow': chunks[1]})
+ self.fetch_account_whox(message)
def handle_public_message(self, message):
if not message.params[1].startswith(IRC_CONFIG['nickname']):