Skip to content

Commit 5184fbd

Browse files
committed
Only enable FFI tdlib for development
1 parent f57e48b commit 5184fbd

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

lib/tasks/telegram_data_collector.rake

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,23 @@ require "json"
44
# Minimal TDLib FFI wrapper, tdlib-ruby is conflict with
55
# telegram-bot-ruby as they depends on dry-core
66
module TDJson
7-
extend FFI::Library
8-
lib_name = "tdjson"
9-
if FFI::Platform.windows?
10-
ffi_lib File.join(ENV.fetch("TDLIB_PATH"), "#{lib_name}.dll")
11-
elsif FFI::Platform.mac?
12-
ffi_lib File.join(ENV.fetch("TDLIB_PATH"), "lib#{lib_name}.dylib")
13-
else
14-
ffi_lib File.join(ENV.fetch("TDLIB_PATH"), "lib#{lib_name}.so")
15-
end
7+
if Rails.env.development?
8+
extend FFI::Library
9+
lib_name = "tdjson"
10+
if FFI::Platform.windows?
11+
ffi_lib File.join(ENV.fetch("TDLIB_PATH"), "#{lib_name}.dll")
12+
elsif FFI::Platform.mac?
13+
ffi_lib File.join(ENV.fetch("TDLIB_PATH"), "lib#{lib_name}.dylib")
14+
else
15+
ffi_lib File.join(ENV.fetch("TDLIB_PATH"), "lib#{lib_name}.so")
16+
end
1617

17-
attach_function :td_json_client_create, [], :pointer
18-
attach_function :td_json_client_send, [ :pointer, :string ], :void
19-
attach_function :td_json_client_receive, [ :pointer, :double ], :string
20-
attach_function :td_json_client_execute, [ :pointer, :string ], :string
21-
attach_function :td_json_client_destroy, [ :pointer ], :void
18+
attach_function :td_json_client_create, [], :pointer
19+
attach_function :td_json_client_send, [ :pointer, :string ], :void
20+
attach_function :td_json_client_receive, [ :pointer, :double ], :string
21+
attach_function :td_json_client_execute, [ :pointer, :string ], :string
22+
attach_function :td_json_client_destroy, [ :pointer ], :void
23+
end
2224
end
2325

2426
class TDClient

0 commit comments

Comments
 (0)