Basic SSH daemon.
[akkoma] / lib / pleroma / bbs / bbs.ex
1 defmodule Pleroma.BBS do
2 def start_daemon do
3 :ok = :ssh.start()
4
5 options = [
6 system_dir: 'ssh_keys',
7 auth_method_kb_interactive_data: fn (_, user, _) -> {
8 'Welcome to Pleroma BBS',
9 'Hello #{user}',
10 'Password: ',
11 false }
12 end,
13 auth_methods: 'keyboard-interactive,password',
14 pwdfun: fn(user, password) -> true end,
15 shell: &start_prompt/1
16 ]
17 :ssh.daemon(13121, options)
18 end
19
20 def start_prompt(user) do
21 spawn(__MODULE__, :prompt, [user])
22 end
23
24 def prompt(user) do
25 IO.puts("Hey #{user}.\n")
26 IO.puts("Here's your timeline:\n")
27
28 user = Pleroma.User.get_cached_by_nickname(to_string(user))
29 Pleroma.Web.TwitterAPI.TwitterAPI.fetch_friend_statuses(user)
30 |> Enum.each(fn (status) ->
31 IO.puts("#{status["user"]["name"]} (#{status["user"]["screen_name"]}): #{status["text"]}")
32 end)
33 end
34 end