Skip to content

Commit 1ce75b5

Browse files
author
windka
committed
fixed #7
1 parent 31c8e17 commit 1ce75b5

File tree

4 files changed

+70
-15
lines changed

4 files changed

+70
-15
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
# [0.1.5] - 2024-01-14
5+
### added devicemodel, systemversion appversion as optional parameters - [#7](https://github.com/windkh/node-red-node-telegrambot/issues/7)
6+
47
# [0.1.4] - 2023-10-15
58
### added further filters - [#3](https://github.com/windkh/node-red-node-telegrambot/issues/3)
69
### added client api - [#5](https://github.com/windkh/node-red-node-telegrambot/issues/5)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-red-node-telegrambot",
3-
"version": "0.1.4",
3+
"version": "0.1.5",
44
"description": "Telegram userbot nodes for Node-RED",
55
"dependencies": {
66
"telegram": "^2.18.38"

telegrambot/telegrambot.html

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212

1313
useproxy: { value: false, required: false },
1414
usewss: { value: false, required: false },
15+
devicemodel: { value: "", required: false },
16+
systemversion: { value: "", required: false },
17+
appversion: { value: "", required: false },
18+
1519
host: { value: "", required: false },
1620
sockstype: { value: "5", required: false },
1721
port: { value: 6667, required: false, validate:function(v) { return ((v === "") || (RED.validators.number(v) && (v >= 0) && (v <= 2147483))) }},
@@ -34,8 +38,8 @@
3438
},
3539
oneditprepare: function() {
3640
// polling or webhook
37-
var updateLoginMode = function() {
38-
var mode = $("#node-config-input-loginmode").val();
41+
let updateLoginMode = function() {
42+
let mode = $("#node-config-input-loginmode").val();
3943
if (mode == "user") {
4044
$("#phonenumber").show();
4145
$("#password").show();
@@ -51,8 +55,8 @@
5155

5256

5357
// proxy on / off
54-
var useproxy = function() {
55-
var mode = $("#node-config-input-useproxy").prop('checked');
58+
let useproxy = function() {
59+
let mode = $("#node-config-input-useproxy").prop('checked');
5660
if (mode === false) {
5761
$("#useproxy").hide();
5862
} else {
@@ -63,15 +67,18 @@
6367
$("#node-config-input-useproxy").change(useproxy);
6468

6569

66-
var login = function() {
70+
let login = function() {
6771
let apiId = $("#node-config-input-apiid").val();
6872
let apiHash = $("#node-config-input-apihash").val();
6973
let phoneNumber = $("#node-config-input-phonenumber").val();
7074
let password = $("#node-config-input-password").val();
7175
let botToken = $("#node-config-input-bottoken").val();
7276
let loginMode = $("#node-config-input-loginmode").val();
73-
let useProxy = $("#node-config-input-useproxy").val();
74-
let useWSS = $("#node-config-input-usewss").val();
77+
let useProxy = $("#node-config-input-useproxy").prop('checked');
78+
let useWSS = $("#node-config-input-usewss").prop('checked');
79+
let devicemodel = $("#node-config-input-devicemodel").val();
80+
let systemversion = $("#node-config-input-systemversion").val();
81+
let appversion = $("#node-config-input-appversion").val();
7582
let proxy;
7683

7784
if (useProxy) {
@@ -82,7 +89,7 @@
8289
username: $("#node-config-input-username").val(),
8390
password: $("#node-config-input-password").val(),
8491
secret: $("#node-config-input-secret").val(),
85-
MTProxy: $("#node-config-input-mtproxy").val(),
92+
MTProxy: $("#node-config-input-mtproxy").prop('checked'),
8693
timeout: Number($("#node-config-input-timeout").val()),
8794
};
8895
}
@@ -97,14 +104,16 @@
97104
loginMode : loginMode,
98105
proxy : proxy,
99106
useWSS : useWSS,
107+
devicemodel : devicemodel,
108+
systemversion : systemversion,
109+
appversion : appversion,
100110
}
101111

102112
$("#loginbuttontip").text("Login started: enter code in field below.");
103113
$("#node-config-input-phonecode").val('');
104114
$("#node-config-input-session").val('');
105115
$.getJSON('node-red-node-telegrambot-login', parameters, function(data) {
106116
if(data.session){
107-
debugger
108117
$("#node-config-input-session").val(data.session);
109118
$("#loginbuttontip").text("Click Login button to request code for login: code will be sent via your phone.");
110119
$("#node-config-input-phonecode").val('');
@@ -119,7 +128,7 @@
119128
}
120129
}
121130

122-
var setPhoneCode = function() {
131+
let setPhoneCode = function() {
123132
let phoneCode = $("#node-config-input-phonecode").val();
124133
if(phoneCode != ''){
125134
$("#loginbuttontip").text("Signing in using phone code ....");
@@ -132,7 +141,7 @@
132141
}
133142
}
134143

135-
var setPassword = function() {
144+
let setPassword = function() {
136145
let password = $("#node-config-input-password").val();
137146
if(password != ''){
138147
$("#loginbuttontip").text("Signing in using password ....");
@@ -145,7 +154,7 @@
145154
}
146155
}
147156

148-
var showLoginButton = function() {
157+
let showLoginButton = function() {
149158
let session = $("#node-config-input-session").val();
150159
if(session === ''){
151160
$("#loginpanel").show();
@@ -208,7 +217,21 @@
208217
<input type="text" id="node-config-input-apihash" placeholder="(Enter the hash here)">
209218
</div>
210219
<div class="form-tips" style="width: auto"><b>Tip:</b> If you don't have an application ID yet, you can create a new one here: <a href="https://my.telegram.org/auth">Telegram</a>.</div>
211-
</div>
220+
221+
<!-- optional client configuration parameters -->
222+
<div class="form-row">
223+
<label for="node-config-input-devicemodel"><i class="fa fa-caret-right"></i> Device Model</label>
224+
<input type="text" id="node-config-input-devicemodel" placeholder="(Optional: device model)">
225+
</div>
226+
<div class="form-row">
227+
<label for="node-config-input-systemversion"><i class="fa fa-caret-right"></i> System Version</label>
228+
<input type="text" id="node-config-input-systemversion" placeholder="(Optional: system version)">
229+
</div>
230+
<div class="form-row">
231+
<label for="node-config-input-appversion"><i class="fa fa-caret-right"></i> App Version</label>
232+
<input type="text" id="node-config-input-appversion" placeholder="(Optional: app version)">
233+
</div>
234+
</div>
212235

213236
<div class="form-row">
214237
<div class="form-row">
@@ -239,7 +262,7 @@
239262
<hr align="middle"/>
240263
</div>
241264

242-
<hr align="middle"/>
265+
<hr align="middle"/>
243266

244267
<div class="form-row">
245268
<label for="node-config-input-useproxy"><i class="fa fa-lock"></i> Use Proxy</label>

telegrambot/telegrambot.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ module.exports = function (RED) {
4545
let loginMode = parameters.loginMode;
4646
let proxy = parameters.proxy;
4747
let useWSS = parameters.useWSS;
48+
let deviceModel = parameters.devicemodel || "";
49+
let systemVersion = parameters.systemversion || "";
50+
let appVersion = parameters.appversion || "";
4851

4952
if (password === undefined || password === '') {
5053
password = async () => await getPassword;
@@ -59,6 +62,17 @@ module.exports = function (RED) {
5962
useWSS: useWSS,
6063
};
6164

65+
// optional login parameters.
66+
if (deviceModel !== "") {
67+
clientParams.deviceModel = deviceModel;
68+
}
69+
if (systemVersion !== "") {
70+
clientParams.systemVersion = systemVersion;
71+
}
72+
if (appVersion !== "") {
73+
clientParams.appVersion = appVersion;
74+
}
75+
6276
const client = new TelegramClient(stringSession, apiId, apiHash, clientParams);
6377

6478
client.setLogLevel('warn');
@@ -176,6 +190,9 @@ module.exports = function (RED) {
176190
this.useProxy = n.useproxy || false;
177191
this.useWSS = n.usewss || false;
178192
this.proxy;
193+
let deviceModel = n.devicemodel || "";
194+
let systemVersion = n.systemversion || "";
195+
let appVersion = n.appversion || "";
179196

180197
if (this.useProxy) {
181198
this.proxy = {
@@ -219,6 +236,18 @@ module.exports = function (RED) {
219236
proxy: proxy,
220237
useWSS: useWSS,
221238
};
239+
240+
// optional login parameters.
241+
if (deviceModel !== "") {
242+
clientParams.deviceModel = deviceModel;
243+
}
244+
if (systemVersion !== "") {
245+
clientParams.systemVersion = systemVersion;
246+
}
247+
if (appVersion !== "") {
248+
clientParams.appVersion = appVersion;
249+
}
250+
222251
client = new TelegramClient(stringSession, ID, apiHash, clientParams);
223252

224253
client.setLogLevel(logLevel);

0 commit comments

Comments
 (0)