summaryrefslogtreecommitdiff
path: root/protocols/Telegram/src/t_callback.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Telegram/src/t_callback.cpp')
-rw-r--r--protocols/Telegram/src/t_callback.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/protocols/Telegram/src/t_callback.cpp b/protocols/Telegram/src/t_callback.cpp
new file mode 100644
index 0000000000..97d7eb0d1a
--- /dev/null
+++ b/protocols/Telegram/src/t_callback.cpp
@@ -0,0 +1,27 @@
+#include "stdafx.h"
+
+static void update_message_handler(tgl_state *TLS, tgl_message *msg)
+{
+ ((MirTLS*)TLS)->m_proto->OnMessage(msg);
+}
+
+static void logprintf(const char *fmt, ...)
+{
+ CMStringA str("[Telegram]: ");
+ va_list args;
+ va_start(fmt, args);
+ str.AppendFormatV(fmt, args);
+ va_end(args);
+ CallService(MS_NETLIB_LOG, 0, (LPARAM)str.GetString());
+}
+
+void CTelegramProto::InitCallbacks()
+{
+ tgl_update_callback cb = { 0 };
+ cb.new_msg = update_message_handler;
+ cb.msg_receive = update_message_handler;
+ cb.logprintf = logprintf;
+
+ tgl_set_callback(TLS, &cb);
+
+} \ No newline at end of file