diff --git a/src/qTbot/qTbot.qrc b/src/qTbot/qTbot.qrc
index 17fa82e..172a1cd 100644
--- a/src/qTbot/qTbot.qrc
+++ b/src/qTbot/qTbot.qrc
@@ -1,7 +1,4 @@
-
- src/qTbotModule/qmldir
- src/qTbotModule/qTbot.qml
-
+
diff --git a/src/qTbot/src/private/requests/telegramsendlocation.cpp b/src/qTbot/src/private/requests/telegramsendlocation.cpp
new file mode 100644
index 0000000..3d68780
--- /dev/null
+++ b/src/qTbot/src/private/requests/telegramsendlocation.cpp
@@ -0,0 +1,31 @@
+//#
+//# Copyright (C) 2023-2023 QuasarApp.
+//# Distributed under the GPLv3 software license, see the accompanying
+//# Everyone is permitted to copy and distribute verbatim copies
+//# of this license document, but changing it is not allowed.
+//#
+
+#include "telegramsendlocation.h"
+namespace qTbot {
+
+TelegramSendLocation::TelegramSendLocation(const QVariant &chatId,
+ const QString &text,
+ float latitude,
+ float longitude,
+ unsigned long long replyToMessageId
+ ):
+ TelegramSingleRquest("sendLocation") {
+
+ addArg("chat_id", chatId);
+ if (text.size())
+ addArg("caption", text);
+
+ addArg("latitude", latitude);
+ addArg("longitude", longitude);
+
+ if (replyToMessageId) {
+ addArg("reply_to_message_id", replyToMessageId);
+ }
+}
+
+}
diff --git a/src/qTbot/src/private/requests/telegramsendlocation.h b/src/qTbot/src/private/requests/telegramsendlocation.h
new file mode 100644
index 0000000..f1f5627
--- /dev/null
+++ b/src/qTbot/src/private/requests/telegramsendlocation.h
@@ -0,0 +1,27 @@
+//#
+//# Copyright (C) 2023-2023 QuasarApp.
+//# Distributed under the GPLv3 software license, see the accompanying
+//# Everyone is permitted to copy and distribute verbatim copies
+//# of this license document, but changing it is not allowed.
+//#
+
+#ifndef TELEGRAMSENDLOCATION_H
+#define TELEGRAMSENDLOCATION_H
+
+#include "requests/telegramsinglerquest.h"
+namespace qTbot {
+
+/**
+ * @brief The TelegramSendLocation class sents location data into chat
+ */
+class TelegramSendLocation: public TelegramSingleRquest
+{
+public:
+ TelegramSendLocation(const QVariant &chatId,
+ const QString &text,
+ float latitude,
+ float longitude,
+ unsigned long long replyToMessageId);
+};
+}
+#endif // TELEGRAMSENDLOCATION_H
diff --git a/src/qTbot/src/public/qTbot/itelegrambot.cpp b/src/qTbot/src/public/qTbot/itelegrambot.cpp
index 71bde41..0d594eb 100644
--- a/src/qTbot/src/public/qTbot/itelegrambot.cpp
+++ b/src/qTbot/src/public/qTbot/itelegrambot.cpp
@@ -19,6 +19,7 @@
#include
#include
#include
+#include
#include
#include
@@ -432,6 +433,23 @@ bool ITelegramBot::sendFileById(const QString &fileID, const QVariant &chatId) {
}
+bool ITelegramBot::sendLocation(const QVariant &chatId,
+ const QString &text,
+ float latitude,
+ float longitude,
+ unsigned long long replyToMessageId) {
+ if (!chatId.isValid() || chatId.isNull())
+ return false;
+
+ if (!(longitude && latitude)) {
+ return false;
+ }
+
+ auto&& request = QSharedPointer::create(chatId, text, latitude, longitude, replyToMessageId);
+
+ return bool(sendRequest(request));
+}
+
int ITelegramBot::getFileSizeByUniqueId(const QString &id) const {
if (auto && file = _filesMetaInfo.value(id)) {
return file->fileSize();
diff --git a/src/qTbot/src/public/qTbot/itelegrambot.h b/src/qTbot/src/public/qTbot/itelegrambot.h
index 3640196..2b6a808 100644
--- a/src/qTbot/src/public/qTbot/itelegrambot.h
+++ b/src/qTbot/src/public/qTbot/itelegrambot.h
@@ -261,6 +261,20 @@ class QTBOT_EXPORT ITelegramBot : public IBot
*/
bool sendFileById(const QString& fileID, const QVariant& chatId);
+ /**
+ * @brief sendLocation This method sents locatin to user.
+ * @param chatId This is distanation id chat.
+ * @param latitude
+ * @param longitude
+ * @param replyToMessageId The unique identifier of the message to reply to, skip if you want to sent new independet message.
+ * @return true if locations sent successful else false
+ */
+ bool sendLocation(const QVariant& chatId,
+ const QString& text,
+ float latitude,
+ float longitude,
+ unsigned long long replyToMessageId = 0);
+
// to do
// * forwardMessage implementations
diff --git a/src/qTbot/src/public/qTbot/messages/telegramlocation.cpp b/src/qTbot/src/public/qTbot/messages/telegramlocation.cpp
new file mode 100644
index 0000000..ba05eb1
--- /dev/null
+++ b/src/qTbot/src/public/qTbot/messages/telegramlocation.cpp
@@ -0,0 +1,31 @@
+//#
+//# Copyright (C) 2023-2023 QuasarApp.
+//# Distributed under the GPLv3 software license, see the accompanying
+//# Everyone is permitted to copy and distribute verbatim copies
+//# of this license document, but changing it is not allowed.
+//#
+
+#include "telegramlocation.h"
+
+namespace qTbot {
+
+TelegramLocation::TelegramLocation()
+{
+
+}
+
+TelegramLocation::TelegramLocation(const QJsonObject &jsonObject):
+ IJsonBasedObject(jsonObject) {
+
+}
+
+double TelegramLocation::latitude() const {
+ return rawJson()["latitude"].toDouble();
+
+}
+
+double TelegramLocation::longitude() const {
+ return rawJson()["latitude"].toDouble();
+
+}
+}
diff --git a/src/qTbot/src/public/qTbot/messages/telegramlocation.h b/src/qTbot/src/public/qTbot/messages/telegramlocation.h
new file mode 100644
index 0000000..a790b82
--- /dev/null
+++ b/src/qTbot/src/public/qTbot/messages/telegramlocation.h
@@ -0,0 +1,43 @@
+//#
+//# Copyright (C) 2023-2023 QuasarApp.
+//# Distributed under the GPLv3 software license, see the accompanying
+//# Everyone is permitted to copy and distribute verbatim copies
+//# of this license document, but changing it is not allowed.
+//#
+
+
+#ifndef TELEGRAMLOCATION_H
+#define TELEGRAMLOCATION_H
+
+#include
+
+namespace qTbot {
+
+/**
+ * @brief The TelegramLocation class just simple struct with latitude and longitude
+ */
+class TelegramLocation: public IJsonBasedObject
+{
+public:
+ TelegramLocation();
+
+ /**
+ * @brief Constructs a location object from a JSON object.
+ * @param jsonObject The JSON object containing photo data.
+ */
+ TelegramLocation(const QJsonObject &jsonObject);
+
+ /**
+ * @brief latitude is float value of latitude
+ * @return float value of latitude
+ */
+ double latitude() const;
+
+ /**
+ * @brief longitude is float value of longitude
+ * @return float value of longitude
+ */
+ double longitude() const;
+};
+}
+#endif // TELEGRAMLOCATION_H
diff --git a/src/qTbot/src/public/qTbot/messages/telegrammsg.cpp b/src/qTbot/src/public/qTbot/messages/telegrammsg.cpp
index 0624ba3..c1605f1 100644
--- a/src/qTbot/src/public/qTbot/messages/telegrammsg.cpp
+++ b/src/qTbot/src/public/qTbot/messages/telegrammsg.cpp
@@ -6,6 +6,7 @@
//#
#include "telegrammsg.h"
+#include "qTbot/messages/telegramlocation.h"
#include "qjsonarray.h"
namespace qTbot {
@@ -167,6 +168,10 @@ QSharedPointer TelegramMsg::contact() const {
return QSharedPointer::create(rawJson()[Contact].toObject());
}
+QSharedPointer TelegramMsg::location() const {
+ return QSharedPointer::create(rawJson()[Location].toObject());
+}
+
unsigned long long TelegramMsg::updateId() const {
return 0;
}
diff --git a/src/qTbot/src/public/qTbot/messages/telegrammsg.h b/src/qTbot/src/public/qTbot/messages/telegrammsg.h
index 9947e7b..9219331 100644
--- a/src/qTbot/src/public/qTbot/messages/telegrammsg.h
+++ b/src/qTbot/src/public/qTbot/messages/telegrammsg.h
@@ -12,6 +12,7 @@
#include "qTbot/messages/telegramcontact.h"
#include "telegramaudio.h"
#include "telegramdocument.h"
+#include "telegramlocation.h"
#include "qTbot/messages/telegramimage.h"
namespace qTbot {
@@ -66,6 +67,11 @@ class QTBOT_EXPORT TelegramMsg: public iMessage
*/
const Type Contact = "contact";
+ /**
+ * @brief Location This is type of location data.
+ */
+ const Type Location = "location";
+
/**
* @brief Audio This is type of Audio files.
*/
@@ -213,6 +219,12 @@ class QTBOT_EXPORT TelegramMsg: public iMessage
QSharedPointer contact() const;
unsigned long long updateId() const override;
+
+ /**
+ * @brief location returns location object of message.
+ * @return location object.
+ */
+ QSharedPointer location() const;
};
}
diff --git a/src/qTbot/src/qTbotModule/qTbot.qml b/src/qTbot/src/qTbotModule/qTbot.qml
deleted file mode 100644
index a66bed1..0000000
--- a/src/qTbot/src/qTbotModule/qTbot.qml
+++ /dev/null
@@ -1,12 +0,0 @@
-//#
-//# Copyright (C) 2021-2023 QuasarApp.
-//# Distributed under the lgplv3 software license, see the accompanying
-//# Everyone is permitted to copy and distribute verbatim copies
-//# of this license document, but changing it is not allowed.
-//#
-
-import QtQuick 2.15
-
-Item {
-
-}
diff --git a/src/qTbot/src/qTbotModule/qmldir b/src/qTbot/src/qTbotModule/qmldir
deleted file mode 100644
index 83f8a5c..0000000
--- a/src/qTbot/src/qTbotModule/qmldir
+++ /dev/null
@@ -1,3 +0,0 @@
-module qTbotModule
-qTbot 1.0 qTbot.qml
-