Comments (9)
I will need more info about your setup:
- .NET version, OS version, virtual machine?
- Which antivirus installed? or maybe other file protection/monitoring software? (try disabling it for testing purpose)
- Are you overriding "session_pathname" config? Handling multiple session files?
- Where is WTelegram.session file located? (local? network disk?)
- Are you using a FileSystemWatcher or other system that could keep an opened handle on the session file?
from wtelegramclient.
.Net 4.7, Windows 11 ( I'm still on the beta release, didn't update to the stable 😂 ), No a legit pc not virtual
No Antivirus is installed, Windows defender is disabled too
I copied the config string from github, the project is really simple and has only one session and one main thread running at a time
It's located locally ( no modifications were done to the storing system )
I don't think, No I've never used a file system watcher
I'll embed the project file to you in a second
from wtelegramclient.
The project checks the messages of +800 members of a telegram group, and tries to find inactive members
Configuration:
private string Config(string what)
{
switch (what)
{
case "api_id": return "HIDDEN";
case "api_hash": return "HIDDEN";
case "phone_number": return "HIDDEN";
case "verification_code": MessageBox.Show("Enter code"); return textBox1.Text;
case "first_name": return "Acid"; // if sign-up is required
case "last_name": return ""; // if sign-up is required
case "password": return ""; // if user has enabled 2FA
default: return null; // let WTelegramClient decide the default config
}
}
Executing the process:
new Thread(() =>
{
Executer();
}).Start();
Executer:
Crashing Codes:
partitipants = await telegramClient.Channels_GetParticipants(channelinput, null, offset, 50, 0);
And
messagebase = await telegramClient.Messages_Search(inputPeer, "", null, new DateTime(2018, 1, 1), DateTime.Now, 0, 0, 5, 0, 0, 0, participant.Value.ToInputPeer());
Adding the infinite loops and try catch solved my issue but the crashing still presists
private async void Executer()
{
InputPeerChannel inputPeer = new InputPeerChannel();
inputPeer.access_hash = accesshash;
inputPeer.channel_id = channelID;
InputChannel channelinput = new InputChannel();
channelinput.access_hash = accesshash;
channelinput.channel_id = channelID;
textBox2.Text = "UserID | FirstName | Username | Inactivity | Total Messages | Member For" + Environment.NewLine;
int offset = 0, checkedUsers = 0;
while (true)
{
try
{
Channels_ChannelParticipants partitipants = null;
while (true) // to solve the crashing
{
try
{
Thread.Sleep(500);
partitipants = await telegramClient.Channels_GetParticipants(channelinput, null, offset, 50, 0);
break;
}
catch
{
}
}
if (partitipants.users.Count < 1) // no members left to check
break;
foreach (var participant in partitipants.users) // members of the group
{
Messages_MessagesBase messagebase = null;
while (true) // to bypass the crashing, getting user messages
{
Thread.Sleep(300);
try
{
messagebase = await telegramClient.Messages_Search(inputPeer, "", null, new DateTime(2018, 1, 1), DateTime.Now, 0, 0, 5, 0, 0, 0, participant.Value.ToInputPeer());
break;
}
catch
{
}
}
if (messagebase.Count > 0)
{
var messageBase = messagebase.Messages[0]; // most recent message
if (GetTimeStamp(messageBase.Date) > ((24 * 60 * 60) * 7)) // 7 days ago
{
User fullUser = (User)participant.Value;
DateTime joinedOn;
ChannelParticipantBase partibase = partitipants.participants.FirstOrDefault(t => // find user join date
{
try
{
ChannelParticipant partiti = (ChannelParticipant)t; // might crash if participant is admin
if (partiti.user_id == participant.Value.ID)
{
return true;
}
}
catch
{
}
return false;
});
ChannelParticipant partici = null;
try
{
partici = (ChannelParticipant)partibase;
}
catch
{
}
if (partici != null) // found user's join date ( not admin and not self )
{
joinedOn = partici.date;
textBox2.Text += fullUser.id + " | " + fullUser.first_name + " | @" + fullUser.username + " | " + GetDays(messageBase.Date) + " Days | " + messagebase.Count + " | " + GetDays(joinedOn) + " Days" + Environment.NewLine;
}
else
{
textBox2.Text += fullUser.id + " | " + fullUser.first_name + " | @" + fullUser.username + " | " + GetDays(messageBase.Date) + " Days | " + messagebase.Count + " | Unknown" + Environment.NewLine;
}
}
offset++;
}
else // never sent a message in the group
{
long howManyDays = 0;
if (partitipants.participants.FirstOrDefault(t => // find join date
{
try
{
ChannelParticipant partiti = (ChannelParticipant)t; // might be admin or self, will crash
if (partiti.user_id == participant.Value.ID)
{
howManyDays = GetDays(partiti.date); // count days since user's join
if (howManyDays > 3)
{
return true;
}
}
}
catch
{
}
return false;
}) != null) // joined more than 3 days ago, no messages
{
User fullUser = (User)participant.Value;
textBox2.Text += fullUser.id + " | " + fullUser.first_name + " | @" + fullUser.username + " | Never | " + messagebase.Count + " | " + howManyDays + " Days" + Environment.NewLine;
}
offset++;
}
checkedUsers++;
label3.Text = checkedUsers.ToString();
}
}
catch(Exception e)
{
MessageBox.Show(e.Message);
}
}
MessageBox.Show("Finished");
}
from wtelegramclient.
ouch... mixing Thread stuff & Task stuff in a WinForms app... not good.
I will see if I can reproduce.
from wtelegramclient.
ouch... mixing Thread stuff & Task stuff in a WinForms app... not good. I will see if I can reproduce.
I only ran it on a different thread because that crash kept showing, Thought it might solve it but it didn't...
from wtelegramclient.
Well, running Executer on a separate thread wouldn't work anyway because you access GUI elements from that method.
I tested your code in a .NET 4.7.2 WinForms application (under W10) by calling Executer() directly after await _client.LoginUserIfNeeded()
and it worked fine here.
BTW, you reallly need to learn about the is
and as
C# operators.
As I haven't received other reports of issues with File.Replace throwing this exception with WTelegramClient, for now I consider it is something specific with your setup... so I will close this issue.
I will reopen it if I ever receive feedback from others about that issue, or new elements that helps me understand if that's something I can fix in WTelegramClient itself.
from wtelegramclient.
Well, running Executer on a separate thread wouldn't work anyway because you access GUI elements from that method.
I tested your code in a .NET 4.7.2 WinForms application (under W10) by calling Executer() directly after
await _client.LoginUserIfNeeded()
and it worked fine here.BTW, you reallly need to learn about the
is
andas
C# operators.As I haven't received other reports of issues with File.Replace throwing this exception with WTelegramClient, for now I consider it is something specific with your setup... so I will close this issue.
I will reopen it if I ever receive feedback from others about that issue, or new elements that helps me understand if that's something I can fix in WTelegramClient itself.
Yeh I code for fun, I don't really do serious projects, thanks though I really needed that is
operator.
I hope the issue is on my side, it's not a deal breaker anyway.
Thanks for your time and your great project.
from wtelegramclient.
My app have multiple threads and overrides "session_pathname" config. Faced same issue. After replacing File.Replace() with File.Delete(); File.Move(); no issues caught.
#12
from wtelegramclient.
merged Richi PR in 62dad83
from wtelegramclient.
Related Issues (20)
- Client.User field is not updated during the session, can be harmful HOT 2
- Logout Active Session : Account_GetAuthorizations return 0 hash for active session HOT 4
- Unable to cast object of type 'TL.UserEmpty' to type 'TL.User'. HOT 3
- Interrupted login (resumed/asynchronous) HOT 5
- The method address is different HOT 3
- Cannot find type for ctor #38116ee0 HOT 2
- Stack overflow on poison message HOT 5
- QR Support HOT 6
- Session serialization error HOT 2
- Getting Message History with min_id HOT 2
- Contact for specific questions ? HOT 1
- Issue using Stream for saving session HOT 5
- Some properties are only private HOT 1
- Object of type 'TL.PeerChannel' cannot be converted to type 'TL.MessageFwdHeader'. HOT 3
- I always get updateDeleteMessages. HOT 2
- An exception occured in the reactor: WTelegram.WTException: Cannot find type for ctor #whatever after upgrading to v4.x HOT 7
- contacts.getLocated HOT 1
- how to get data for miniapp? HOT 1
- voip support HOT 1
- fetching big files sent to bot & download them HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wtelegramclient.