Ejemplo n.º 1
0
        /// <summary>
        /// asynchronously run a tdapi.Function
        /// </summary>
        /// <param name="func">function you want to run asynchronously</param>
        /// <param name="expectedtype">the type which you expect your function response receives</param>
        /// <returns>A Responseobject contains your task information</returns>
        public async Task <Responseobject> ExecuteCommandAsync(tdapi.Function func, tdapi.BaseObject expectedtype = null)
        {
            Responseobject res = new Responseobject();
            Dictionary <string, Action <tdapi.BaseObject, Reshandler> > customcommands = new Dictionary <string, Action <tdapi.BaseObject, Reshandler> >();

            customcommands.Add("Custom", (a, b) =>
            {
                b.responseobject = a;
                if (expectedtype is null)
                {
                    b.response = enums.Response.Success;
                }
                else
                {
                    if (a.GetType() == expectedtype.GetType())
                    {
                        b.response = enums.Response.Success;
                    }
                    else
                    {
                        b.response = enums.Response.Failed;
                    }
                }
            });
            Reshandler handler = new Reshandler(this)
            {
                command = "Custom",
            };

            ReadCommands(handler, customcommands);
            client.Send(func, handler);
            res = await handler.getresponse();

            return(res);
        }
Ejemplo n.º 2
0
 void Td.ClientResultHandler.OnResult(TdApi.BaseObject @object)
 {
     if (@object is TdApi.UpdateAuthorizationState)
     {
         OnAuthorizationStateUpdated((@object as TdApi.UpdateAuthorizationState).AuthorizationState);
     }
     else
     {
         //  Print("Unsupported update: " + @object);
         if (@object is TdApi.UpdateChatLastMessage)
         {
             ///RDV - -1001408447562
             ///HIDE -1001352498778
             ///my -1001260330650
             TdApi.Message lastMessage = (@object as TdApi.UpdateChatLastMessage).LastMessage;
             if (lastMessage != null && appConfig.chatIds.Contains(lastMessage.ChatId))
             {
                 var saveMessage = new SaveMessage();
                 saveMessage.messageID = lastMessage.Id;
                 if (db.SaveMessage.Find(lastMessage.Id) == null)
                 {
                     db.SaveMessage.Add(saveMessage);
                     db.SaveChanges();
                     sendMessage(lastMessage);
                     //    Print(lastMessage.ToString());
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
 public void OnResult(TdApi.BaseObject obj)
 {
     _cnt--;
     if (_cnt == 0)
     {
         _page.Print("DONE");
     }
 }
Ejemplo n.º 4
0
 void Td.ClientResultHandler.OnResult(TdApi.BaseObject @object)
 {
     if (@object is TdApi.UpdateAuthorizationState)
     {
         OnAuthorizationStateUpdated((@object as TdApi.UpdateAuthorizationState).AuthorizationState);
     }
     else
     {
         // Print("Unsupported update: " + @object);
     }
 }
Ejemplo n.º 5
0
 void Td.ClientResultHandler.OnResult(TdApi.BaseObject @object)
 {
     if (@object is TdApi.Error)
     {
         Print("Receive an error:" + _newLine + @object);
         OnAuthorizationStateUpdated(null); // repeat last action
     }
     else
     {
         // result is already received through UpdateAuthorizationState, nothing to do
     }
 }
Ejemplo n.º 6
0
 void Td.ClientResultHandler.OnResult(TdApi.BaseObject @object)
 {
     if (@object is TdApi.UpdateAuthorizationState)
     {
         //OnAuthorizationStateUpdated((@object as TdApi.UpdateAuthorizationState).AuthorizationState);
         Console.WriteLine("Missing 2");
     }
     else
     {
         // Print("Unsupported update: " + @object);
     }
 }
Ejemplo n.º 7
0
 public void OnResult(tdapi.BaseObject @object)
 {
     if (commands.ContainsKey(command))
     {
         commands[command].Invoke(@object, this);
     }
     else
     {
         if (core.mainresponsehandlers.ContainsKey(@object.GetType()))
         {
             Action <TDLibCoreEventArgs> handler = core.mainresponsehandlers[@object.GetType()];
             if (handler != null)
             {
                 handler(new TDLibCoreEventArgs()
                 {
                     core             = core,
                     additionalobject = @object
                 });
             }
         }
     }
 }
Ejemplo n.º 8
0
 void Td.ClientResultHandler.OnResult(TdApi.BaseObject @object)
 {
     Print(@object.ToString());
 }
Ejemplo n.º 9
0
            void Td.ClientResultHandler.OnResult(TdApi.BaseObject @object)
            {
                Print(@object.ToString());

                //   sendMessage(GetChatId("350715255"), @object.ToString());
            }
Ejemplo n.º 10
0
        public void OnResult(TdApi.BaseObject obj)
        {
            var str = obj.ToString();

            _page.Print(str);
        }
Ejemplo n.º 11
0
 void Td.ClientResultHandler.OnResult(TdApi.BaseObject @object)
 {
     //Print(@object.ToString());
     Console.WriteLine("Missing 1" + @object.ToString());
 }
Ejemplo n.º 12
0
 public void OnResult(TdApi.BaseObject @object)
 {
     flag       = false;
     baseObject = @object;
     flag       = true;
 }