Code Monkey home page Code Monkey logo

tlsharp's People

Contributors

aarani avatar ahmadalli avatar ahmadi173 avatar cheshirecaat avatar clonedeath avatar dependabot[bot] avatar dev-masih avatar devmikeua avatar eaba avatar gitter-badger avatar gmardok avatar grepsy avatar knocte avatar lonami avatar marshallmick007 avatar mkellerman avatar mojtabatajik avatar mykolasglinskis avatar proger4ever avatar ra0o0f avatar raznahan avatar salarcode avatar sochix avatar solarin avatar starli0n avatar steavy29 avatar timocov avatar unn4m3d avatar vladsnap avatar zerodwide avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tlsharp's Issues

SendCodeRequest Method Failed

Hi, Ilya. Thank you for the great work.
AuthUser test has failed because SendCodeRequest method thrown a exception in mscorlib.dll and i can't receive SMS code to my phone number. I try 0,1 and 5 value in sms_type parameter.

TestConnection and AutheficationWorks works fine.

Visual Studio 2015 Community, Win7 32-bit

Regards, Egor

How i can AuthUser for new Telegram Number

Hi
i have problem with AuthUser when my number is new Telegram Number and not registered on tegegram yet. in this cases i recive sms on my phone but error on MakeAuth func.
for telegram numbers i can recive code via sms and on actived telegram and no problem.
thank's

problem in tlsharp please help me

after I used AuthUser with defaultConnectionAddress = "91.108.56.165"
I get this error
" An exception of type 'System.InvalidOperationException' occurred in mscorlib.dll but was not handled in user code
Additional information: Your phone number registered to 1 dc. Please update settings. See https://github.com/sochix/TLSharp#i-get-an-error-migrate_x for details."
I go to link https://github.com/sochix/TLSharp#i-get-an-error-migrate_x and read I must chage server address I change it to defaultConnectionAddress = "149.154.167.51" then try again I get this error
" An exception of type 'System.IO.EndOfStreamException' occurred in mscorlib.dll but was not handled in user code
Additional information: Unable to read beyond the end of the stream. "
please any help and I hope give me complete work example
thanks

c# problem

hi.
in TLSharp.Core.Requests.AckRequest you in line 36 you wrote :
public override bool Confirmed => false;
i have VS 2013, why my VS doesn't recognize this?
please help, i can't build the project. :-(

Why i get rpc_error FLOOD_WAIT

Hi. i am doing a registeration check for my list of phone numbers. but after doing 9 or 10 of checks an rpc error for FLOOD_WAIT occur and in debug write that you must wait(for example 270 sec.) why this error occur? and how to pass from this error. please explain about it. Thanks.

Implementing Group Chat Functions. Contributors welcome!

Hi
Could you kindly add functions for working with chats?

Or if have'nt enough time, if you guide me I could help to develop and improve your library.
I'm a senior developer with 22 year of software development experience.
If you like my offer, we could talk here or in telegram. I will give you my phone number for telegram chat.

unregisteredNumber and another Numbers

Hi
can i ask u about these three phone numbers?
what about numberToAuthenticate, registeredNumber and unregisteredNumber?
i set them like this:


MyPhoneNumber means that number i registered it in Telegram Site for giving API Code.
is that alright?
what about unregisteredNumber?

thanks

Exception on ImportContact

Hi.
I successfully passed AuthUser Test. Problem was the server ip which is solved by setting server address to 149.154.167.91 .
Now when debugging ImportContact test i get following exception:

Test method TLSharp.Tests.NotificatioClientTests.ImportContact threw exception:

System.InvalidCastException: Unable to cast object of type 'TLSharp.Core.MTProto.UserSelfConstructor' to type 'TLSharp.Core.MTProto.UserContactConstructor'.

DoAuthentication step 2 on Xamarin Studio

Hi boys,
i'm trying to use TLSharp on Xamarin studio, but code crash calling client.Connect()... on step 2 of DoAuthentication Task.
System return this error code on step 2 of DoAuthentication task:
System.IO.EndOfStreamException: Failed to read past end of stream.
Have an ideas?
Thank you so much!!

please i need your help

please can you help me to define InputMedia
I need to send photo then I need to define message content as inputmedia can you help me in this
thanks

Authentication Workaround,working servers list, and other problems

Hi
1- Every time I run make project I have to run AuthUser test and get a code from telegram, otherwise none of methods work and they wait for unlimited time.
Is there any workaround for this?

2- I tested these servers:

Server 1: 149.154.175.50:443
Server 2: 149.154.167.51:443
Server 3: 149.154.175.100:443
Server 4: 149.154.167.91:443
Server 5: 91.108.56.165:443

and only server with address 149.154.167.91 works, other servers return exceptions when calling their methods.
The exception is:
Test method TLSharp.Tests.NotificatioClientTests.AuthUser threw exception:
System.IO.EndOfStreamException: Unable to read beyond the end of the stream.

More strange part is that they send code to me using sms, and then return above exception.

Is there any reason for this?

3- When i send someone a message, his contact name changes to "My Test Name" for me. What to do with this?

API_ID_INVALID on second run

Hi. This is the code i'm using.

public static void Send(string message)
var store = new FileSessionStore();
var client = new TelegramClient(store, "session");
var connected = await client.Connect();
if (!client.IsUserAuthorized())
{
var hash = await client.SendCodeRequest("+myponenumber");
var code = "33219"; // you can change code in debugger

var user = await client.MakeAuth("+myponenumber", hash, "33219");

}
var res = await client.ImportContact("@mychannel");

await client.SendMessage(res.Value, message);
}

When I run this function, I get this error:
[InvalidOperationException: API_ID_INVALID]
TLSharp.Core.Network.MtProtoSender.HandleRpcResult(UInt64 messageId, Int32 sequence, BinaryReader messageReader, MTProtoRequest request) +983
TLSharp.Core.Network.MtProtoSender.processMessage(UInt64 messageId, Int32 sequence, BinaryReader messageReader, MTProtoRequest request) +945
TLSharp.Core.Network.d__8.MoveNext() +627
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
System.Runtime.CompilerServices.TaskAwaiter1.GetResult() +28 TLSharp.Core.<SendCodeRequest>d__14.MoveNext() +538 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 System.Runtime.CompilerServices.TaskAwaiter1.GetResult() +28
M***************TelegramSender.cs:61

I have set the _apiId and _apiHash values in telegram client with the values I have in https://my.telegram.org/apps
The number I'm using in SendCodeRequest is my number (app owner).

A weird thing is: when I run this function for the first time, the response returned on client.Connect() is good. But for the second time, I get the same API_ID_INVALID exception. But it's catched in MtProtoSender.HandleContainer

Please help

Error on send message

when I call SendMessage method, get error : Unable to read beyond the end of the stream.
!?

Implementation of downloading a contact's photo

hi, before i point out the my problem, i appreciating developers for this nice and clean api code!

MY QUESTION 1:

what i have to set for offset and limit? i don't know photo size! to use it in offset!!!
i know i can use that for chunked download , part by part, but if i wont like to download chunked file
can i set 0, 0 for both?
i did that and i got this respone:

type =>> {(storage_fileJpeg)}
mtime =>> 1446716047
bytes =>> {byte[9484]}

MY QUESTION 2:

how i can see the photo from {byte[9484]}?

i used this code:

using (var ms = new MemoryStream(byteArrayIn))
{
return new Bitmap(ms);
}

and set that return for a PictureBox.Image

but it return exception with: Invalid Parameter!
(it says that the byte format is not correct for Bitmap).

  • hint:
    because i have not offset and limit, i changed some part of code in GetFileRequest:

    public override void OnResponse(BinaryReader reader)
    {
    var code = reader.ReadUInt32(); // upload.file#96a18d5

          type = TL.Parse<storage_FileType>(reader);
          mtime = reader.ReadInt32();
           bytes = reader.ReadBytes(int.Parse((reader.BaseStream.Length - reader.BaseStream.Position).ToString()));
    

    }

thanks in advance!

How to accept message?

I understand that this is not realized , but how do I implement the event to receive messages ?

dll not found

hi
very thanks for this app .i`m used it but when compile show error tlcore.dll not found
please help me

channels.createChannel

hi
How do I implement channels.createChannel?
Layer 41 is implemented. But I do not know flags: # will not implement any

Request an Example for using TLsharp

I studied issues but still have problems in using the TLSharp.

Please give the following code:
One Button(btnSend) and two TextBox(txtMessage,txtNumber) on a form, each time the button is clicked text in 'txtMessage' is send to the 'txtNumber'

thanks

Not getting _phoneCodeHash Value

I am using the following Code

private async void btrequestcode_Click(object sender, EventArgs e)
    {
        var store = new FileSessionStore();
        var client = new TelegramClient(store, "session");
        await client.Connect();
        var hash = await client.SendCodeRequest(tbmobile.Text);
        MessageBox.Show(hash);
    }

but i am unable to get the hash variable.

I am using 149.154.167.50 and also used other IPs : 91.108.56.165 , 149.154.167.90, 149.154.167.91

Please guide me , where i am wrong.

AuthUser Doesn't work

it connect ok, but when a trying to make AuthUser it gave this error "Your phone number registered to 1 dc. Please update settings. See https://github.com/sochix/TLSharp#i-get-an-error-migrate_x for details.". I use all these, but still doesn't work
i checked these server:
Server 1: 149.154.175.50:443
Server 2: 149.154.167.51:443
Server 3: 149.154.175.100:443
Server 4: 149.154.167.91:443
Server 5: 91.108.56.165:443
server 6:149.154.167.40:443
server 7:149.154.167.50:443

and set phone numbers in app.configs but doesn't work,
how can i create Session.dat file?

Unit tests return error

Hi. When i run unit tests i get this error:
TLSharp.Tests.NotificatioClientTests.AuthUser threw exception:

System.IO.EndOfStreamException: Unable to read beyond the end of the stream.

All test methos except that AuthenticationWorks and TestConnection return same error.

I did every thing including setting api id and hash, and setting server address.

problem with breakpoint

When I run the program, I have received a code from telegram, but the program does not reach the breakpoint and performances continues! Please help

doesn't create session.dat file

hi
i execute tutorial step by step, when i run testConnection test function
but doesn't create session.dat
actually i set breakpoint step by step, when reach Receieve function in tcpTransport.cs file suddenly exit and close program,
when run AuthUser function and set breakpoint on "var code = "123"" never reach this line and exit from program
why?
tnx

MIGRATE_X Error and none of the servers respond

I am receiving two types of errors when calling AuthUser test.
For a few IPs (e.g. 149.154.175.100) I receive the SMS but code faces with an exception:
EndOfStreamException: Unable to read beyond the end of the stream

which prevents code from normal execution and 'hash' variable being filled appropriately and ultimately test being failed.

When using other IPs (e.g. 149.154.175.50, 149.154.167.91, &...), I receive:
Your phone number registered to 3 dc. Please update settings.

I have no way of calling help.getConfig or getting updated list of DCs and I put break-point on any possible line to find the place DC IP might be returned, but found no clues.

Please guide me by resolving EndOfStreamException or updating me with a DC address which accepts requests from a phone number registered in DC 3.

Thanks

Exeption in Tl.cs

hello
works sent message but sometimes in line
if (!constructors.ContainsKey(dataCode))
{
throw new Exception(String.Format("invalid constructor code {0}", dataCode));
}
Exception thrown: 'System.Exception' in TLSharp.Core.dll ("invalid constructor code 1444835612")
why?

SendMessage Failed. (Assert.IsTrue failed)

i passed TestConnection and AuthUser successfully,
but in SendMessage Test i got this error:

Test Name: SendMessage
Test FullName: TLSharp.Tests.NotificatioClientTests.SendMessage
Test Source: F:\Telegram\003 - TLSharp-master\TLSharp-master\TLSharp.Tests\NotificatioClientTests.cs : line 101
Test Outcome: Failed
Test Duration: 0:00:02.85505

Result StackTrace:
at TLSharp.Tests.NotificatioClientTests.d__16.MoveNext() in F:\Telegram\003 - TLSharp-master\TLSharp-master\TLSharp.Tests\NotificatioClientTests.cs:line 108
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
Result Message: Assert.IsTrue failed.

any idea?

AuthUser Doesn't work

hi.
in following method : OnResponse in class : AuthSendCodeRequest
in following lines :

var sendCodeTimeout = reader.ReadInt32();
var isPassword = reader.ReadUInt32() == boolTrue;

it return an exception with following content :
unable to read beyond the end of stream.

in register form in telegram api, i get Public keys, should i put it some where?

and also im getting PHONE_NUMBER_UNOCCUPIED , but im registered in telegram

please help. im realy stucked on this

MIGRATE_X Error

I Got MIGRATE_X error for some numbers
i have tested all 5 servers and there was no luck !
where i can find suitable server address
do i have to test all servers ?

error in MakeAuth() method

hi.
im getting the following error in makeauth method:
PHONE_NUMBER_UNOCCUPIED
i receive code from telegram and send in parameter but i get error.
please help.
thanks

send a message to special number

Can you put real example. I want to send message to special number which I do not know the telegram's ID! I write this code but it does not work:
static void Main(string[] args)
{
try
{
Console.WriteLine("Start:");
Task.Run(() => Send("Hi"));
Task.Run(() => SendMessage());
Console.WriteLine("End");
Console.ReadLine();
}
catch (Exception ex)
{
}
}

    public static async Task AuthUser()
    {

        var store = new FileSessionStore();
        var client = new TLSharp.Core.TelegramClient(store, "session");

        await client.Connect();

        var hash = await client.SendCodeRequest("+phone");
        var code = "59149"; // you can change code in debugger

        var user = await client.MakeAuth("+phone", hash, code);

        Assert.IsNotNull(user);
    }

    public static async Task CheckPhones()
    {
        var store = new FileSessionStore();
        var client = new TLSharp.Core.TelegramClient(store, "session");
        await client.Connect();

        var phoneList = new string[]
        {
            "+phone",
            "+phone"
        };

        var rand = new Random();
        foreach (var phone in phoneList)
        {
            var result = await client.IsPhoneRegistered(phone);
            Thread.Sleep(rand.Next(9) * 1000);
            if (result)
                Console.WriteLine($"{phone} - OK");
        }
    }

    public static async Task ImportContact()
    {
        // User should be already authenticated!

        var store = new FileSessionStore();
        var client = new TLSharp.Core.TelegramClient(store, "session");

        await client.Connect();

        Assert.IsTrue(client.IsUserAuthorized());

        var res = await client.ImportContact("@IrisTed");

        Assert.IsNotNull(res);

    }

    public static async Task SendMessage()
    {
        // User should be already authenticated!

        var store = new FileSessionStore();
        var client = new TLSharp.Core.TelegramClient(store, "session");
        await client.Connect();

        Assert.IsTrue(client.IsUserAuthorized());

        var res = await client.ImportContact("+phone");

        Assert.IsNotNull(res);

        await client.SendMessage(res.Value, "Test message from TelegramClient");
    }

    public static async Task TestConnection()
    {
        var store = new FakeSessionStore();
        var client = new TLSharp.Core.TelegramClient(store, "");

        Assert.IsTrue(await client.Connect());
    }

    public static async Task AuthenticationWorks()
    {
        using (var transport = new TcpTransport())
        {
            var authKey = await Authenticator.DoAuthentication(transport);

            Assert.IsNotNull(authKey.AuthKey.Data);
        }
    }

    public static async Task Send(string message)
    {
        var store = new FileSessionStore();
        var client = new TLSharp.Core.TelegramClient(store, "session");
        var connected = await client.Connect();
        if (!client.IsUserAuthorized())
        {
            var hash = await client.SendCodeRequest("+phone");
            var code = "35828"; // you can change code in debugger

            var user = await client.MakeAuth("+phone", hash, code);
        }
        var res = await client.ImportContact("@IrisTed");

        await client.SendMessage(res.Value, message);
    }

Using tlsharp on web application

Hi
This wrapper work fine on win app.
Can i use this wrapper on web application or web service?
I tested, but can't work. stop on client.Connect() method!
Thanks

when i create account it blocked

hi
when I create account telegram using phone number I get it from textplus program
the account blocked from sending message
any help
thanks

Connection KeepAlive

Hi Again.
I'm developing a windows application which serves a WCF Service, which other apps could invoke it for telegram messaging (instead of sms notifications to my users).

After a while since application is idle, it seems that tcp connection get closed and I get errors when calling sendmessage method.
Do have any advice for this problem?

invalid packet length

the library works fine for me, i could make it work with layer40, except at TcpMessage.cs line 63, sometimes the packetLength is negative or more than packet size.

thanks for your great work

PHONE_CODE_EXPIRED

I always receive error PHONE_CODE_EXPIRED.
i receive two message with only one code from Telegram but this code not work :(
any idea for this bug? and why telegram send 2 message for one code?

SendMessage not working after layer 42 release

hi
tanks for great library
I have a problem with sendmessage after release layer version 42
I can send message before but now i can't
I saw sendmessage schema in layer 42 . some parameters added to method
I try to add this parameters but it doesn't work
please help me
tanks

auth.sendSms

Hi,what's create class to send sms to unregistered number because to register number with TLSharp.core.
TLSharp.core has auth.encoDe.

please can i send file?

please can I use your TLSHARP to send file now I can send text message can I send photo or any file if I can please give me any sample
thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.