File: sender.rb

package info (click to toggle)
mikutter 3.8.6%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 10,544 kB
  • sloc: ruby: 20,548; sh: 99; makefile: 19
file content (24 lines) | stat: -rw-r--r-- 492 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# -*- coding: utf-8 -*-

module Plugin::DirectMessage
  class Sender
    def self.slug
      :twitter_directmessage_posting
    end

    def post(to:, message:, **kwrest, &block)
      current_world.send_direct_message(text: message, user: to, &block)
    end

    def postable?(user)
      user.class.slug == :twitter_user and current_world.class.slug == :twitter
    end

    private
    def current_world
      world, = Plugin.filtering(:world_current, nil)
      world
    end
  end

end