Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'socket'
- class Scratch
- attr_reader :socket_json,
- :socket_plain
- def initialize
- @socket_json = UNIXSocket.open('/home/dev/users/taras/stuff/tg/telega_cli_json')
- @socket_plain = UNIXSocket.open('/home/dev/users/taras/stuff/tg/telega_cli_plain')
- end
- def execute(cid)
- txt_channel_info = 'channel_info %s' % cid
- txt_channel_get_admins = 'channel_get_admins %' % cid
- puts '# запрашиваем данные об админах'
- socket_json.puts(txt_channel_get_admins)
- _print_socket_response(socket_json)
- # {"result": "FAIL", "error_code": 71, "error": "RPC_CALL_FAIL 400: CHAT_ADMIN_REQUIRED"}
- puts '# узнаём описание канала'
- socket_plain.puts(txt_channel_info)
- _print_socket_response(socket_plain)
- puts '# узнаём другие метрики канала'
- socket_json.puts(txt_channel_info)
- _print_socket_response(socket_json)
- socket_json.close
- socket_plain.close
- end
- private
- def _print_socket_response(socket)
- socket.each_char do |c|
- break if c == "\n"
- break if c == "\r"
- break if c == "\n\r"
- print c
- end
- end
- end
- Scratch.new.execute('$05000000d042d440c1c2011001869c33')
Add Comment
Please, Sign In to add comment