-
Notifications
You must be signed in to change notification settings - Fork 0
/
Members Record.txt
207 lines (171 loc) · 9.06 KB
/
Members Record.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
// Add the inline mention to the message
tagMessage += $"[{user.FirstName}](tg://user?id={user.Id}) ";
Console.WriteLine(user.Id);
else if (message.Type == MessageType.Text && message.Text == "تگ" || message.Text == "Tag")
{
// Assume you have the last message id and the chat id
int lastMessageId = message.MessageId;
long chatId = message.Chat.Id;
// Create a HashSet to store the user ids
HashSet<long> userIds = new HashSet<long>();
// Create a List of User objects
List<Telegram.Bot.Types.ChatMember> users = new List<Telegram.Bot.Types.ChatMember>();
// Create a variable to store the number of requests per minute
int requests = 0;
// Get the number of members in the chat
int memberCount = await botClient.GetChatMembersCountAsync(chatId);
// Print the number of members to the console
Console.WriteLine($"The chat has {memberCount} members");
if (message.Chat.Id < 0)
{
// Get the list of admins in the chat
IReadOnlyList<Telegram.Bot.Types.ChatMember> admins = await botClient.GetChatAdministratorsAsync(chatId);
// Loop through the admins
foreach (Telegram.Bot.Types.ChatMember admin in admins)
{
if (!admin.User.IsBot)
{
// Get the user id of the admin
long adminId = admin.User.Id;
// Add the admin id to the HashSet
userIds.Add(adminId);
// Print the admin id to the console
Console.WriteLine($"The admin id is {adminId}");
}
}
}
int messageId = 1;
int nonBotUsers = memberCount;
Telegram.Bot.Types.Message newmessage = new Telegram.Bot.Types.Message { };
newmessage.Chat = message.Chat;
newmessage.MessageId = messageId--;
Console.WriteLine(newmessage.Chat.Title);
Console.WriteLine(newmessage.Text);
// Create a while loop to iterate over the message ids until all members are found or an invalid message id is reached
//while (userIds.Count < nonBotUsers && messageId > 0)
//{
// // Decrease the message id by 1
// newmessage.MessageId = lastMessageId--;
// messageId = newmessage.MessageId;
// // Check if the number of requests is less than 1000
// if (requests < 15000)
// {
// // Try to get the message from the chat
// try
// {
// // Check if the message is a text message
// if (newmessage.Text != null)
// {
// // Get the user id from the message sender
// long userId = newmessage.From.Id;
// if (!(newmessage.From.IsBot) && !userIds.Contains(userId))
// {
// // Add the user id to the HashSet
// userIds.Add(userId);
// }
// else
// {
// nonBotUsers = nonBotUsers--;
// Console.WriteLine($"{newmessage.From.Username} is a bot");
// }
// // Print some information to the console
// Console.WriteLine($"Found a text message from {userId} with id {messageId}");
// Console.WriteLine($"Message: {newmessage.Text}");
// }
// else
// {
// // Print a warning to the console
// Console.WriteLine($"The message with id {messageId} is not a text message");
// }
// // Increase the number of requests by 1
// requests++;
// }
// catch (Exception ex)
// {
// // Print an error to the console
// Console.WriteLine($"Failed to get the message with id {messageId}");
// Console.WriteLine($"Exception: {ex.Message}");
// // Break the loop if the message id is invalid or does not exist
// break;
// }
// }
// else
// {
// // Print a message to the console
// Console.WriteLine($"Reached the limit of 1000 requests . Waiting for 10 seconds...");
// // Wait for 10 seconds before sending more requests
// await Task.Delay(10000);
// // Reset the number of requests to 0
// requests = 0;
// }
//}
// Print the number of unique user ids found in the chat
Console.WriteLine($"Found {userIds.Count} unique user ids in the chat");
// Create a variable to store your message
string tagMessage = "Attention: ";
// Loop through the users list
foreach (long userId in userIds)
{
Telegram.Bot.Types.ChatMember user = new Telegram.Bot.Types.ChatMember();
user = await botClient.GetChatMemberAsync(chatId, userId);
users.Add(user);
}
// Send the message using bot client and Markdown mode
await botClient.SendTextMessageAsync(chatId, tagMessage, parseMode: Telegram.Bot.Types.Enums.ParseMode.Markdown);
//Write the user ids to a text file
using (StreamWriter writer = new StreamWriter($"{message.Chat.Title}'s user_ids.txt"))
{
foreach (Telegram.Bot.Types.ChatMember user in users)
{
writer.WriteLine(user.User.Id);
}
}
// Print a message to the console
Console.WriteLine($"Saved the user ids to user_ids.txt");
// Create a string builder to store the mentions
var sb = new StringBuilder();
// Loop through the members
foreach (Telegram.Bot.Types.ChatMember user in users)
{
// Mention them using tg://user?id=123456789
sb.Append($"[{user.User.FirstName}](tg://user?id={user.User.Id}) ");
}
// Reply to the message with "hello"
await botClient.SendTextMessageAsync(
chatId: message.Chat,
text: $"Hello {sb}",
replyToMessageId: message.MessageId,
parseMode: Telegram.Bot.Types.Enums.ParseMode.Markdown
);
}
var text = "Damn it!";
text = message.Text;
var api_url = $"https://api.api-ninjas.com/v1/profanityfilter?text={text}";
var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-Api-Key", "5S51EcmwdfYcvG9ivTCh9w==fOSEypC4YpqFRggE");
var response = await client.GetAsync(api_url);
Console.WriteLine();
if (response.IsSuccessStatusCode)
{
string edited = await response.Content.ReadAsStringAsync();
Console.WriteLine(await response.Content.ReadAsStringAsync());
await botClient.EditMessageTextAsync(message.Chat.Id, message.MessageId, "hi");
}
else
{
Console.WriteLine("Error: {0}", response.StatusCode);
}
var word = "code";
word = message.Text.ToLower();
var api_url = $"https://api.api-ninjas.com/v1/dictionary?word={word}";
var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-Api-Key", "5S51EcmwdfYcvG9ivTCh9w==fOSEypC4YpqFRggE");
var responsee = await client.GetAsync(api_url);
if (responsee.IsSuccessStatusCode)
{
Console.WriteLine(await responsee.Content.ReadAsStringAsync());
}
else
{
Console.WriteLine("Error: {0}", responsee.StatusCode);
}