|
@@ -117,13 +117,15 @@ class ChatGPTBotView: UIViewController, UIGestureRecognizerDelegate {
|
|
|
super.viewDidLoad()
|
|
|
navigationController?.navigationBar.topItem?.title = "GPT SmartBot"
|
|
|
|
|
|
+ buttonSendChat.setImage(resizeImage(image: self.traitCollection.userInterfaceStyle == .dark ? UIImage(named: "Send-(White)", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!.withTintColor(.blackDarkMode) : UIImage(named: "Send-(White)", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!, targetSize: CGSize(width: 30, height: 30)).withRenderingMode(.alwaysOriginal), for: .normal)
|
|
|
buttonSendChat.circle()
|
|
|
buttonSendChat.addTarget(self, action: #selector(sendTapped), for: .touchUpInside)
|
|
|
- buttonSendChat.backgroundColor = .mainColor
|
|
|
+ buttonSendChat.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .white : .mainColor
|
|
|
textFieldSend.layer.cornerRadius = textFieldSend.maxCornerRadius()
|
|
|
textFieldSend.layer.borderWidth = 1.0
|
|
|
textFieldSend.text = "Send message".localized()
|
|
|
textFieldSend.textColor = UIColor.lightGray
|
|
|
+ textFieldSend.tintColor = self.traitCollection.userInterfaceStyle == .dark ? .white : .black
|
|
|
textFieldSend.textContainerInset = UIEdgeInsets(top: 12, left: 20, bottom: 11, right: 40)
|
|
|
textFieldSend.layer.borderColor = UIColor.lightGray.withAlphaComponent(0.5).cgColor
|
|
|
textFieldSend.font = UIFont.systemFont(ofSize: 12)
|
|
@@ -172,7 +174,7 @@ class ChatGPTBotView: UIViewController, UIGestureRecognizerDelegate {
|
|
|
// }
|
|
|
}
|
|
|
|
|
|
- private func sendChat(message_scope_id:String = "31", status:String = "2", message_text:String = "", credential:String = "0", attachment_flag: String = "0", ex_blog_id: String = "", message_large_text: String = "", ex_format: String = "", image_id: String = "", audio_id: String = "", video_id: String = "", file_id: String = "", thumb_id: String = "", reff_id: String = "", read_receipts: String = "4", chat_id: String = "", is_call_center: String = "0", call_center_id: String = "", viewController: UIViewController) {
|
|
|
+ private func sendChat(message_scope_id:String = "31", status:String = "4", message_text:String = "", credential:String = "0", attachment_flag: String = "0", ex_blog_id: String = "", message_large_text: String = "", ex_format: String = "", image_id: String = "", audio_id: String = "", video_id: String = "", file_id: String = "", thumb_id: String = "", reff_id: String = "", read_receipts: String = "4", chat_id: String = "", is_call_center: String = "0", call_center_id: String = "", viewController: UIViewController) {
|
|
|
if viewController is ChatGPTBotView {
|
|
|
if ((textFieldSend.text!.trimmingCharacters(in: .whitespacesAndNewlines) == "Send message".localized() && textFieldSend.textColor == UIColor.lightGray && attachment_flag != "11") || textFieldSend.text!.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty ) {
|
|
|
dismissKeyboard()
|
|
@@ -195,7 +197,7 @@ class ChatGPTBotView: UIViewController, UIGestureRecognizerDelegate {
|
|
|
var opposite_pin = idMe ?? ""
|
|
|
sendTyping(l_pin: l_pin, isTyping: true)
|
|
|
let message = CoreMessage_TMessageBank.sendMessage(l_pin: l_pin, message_scope_id: message_scope_id, status: status, message_text: message_text, credential: credential, attachment_flag: attachment_flag, ex_blog_id: ex_blog_id, message_large_text: message_large_text, ex_format: ex_format, image_id: image_id, audio_id: audio_id, video_id: video_id, file_id: file_id, thumb_id: thumb_id, reff_id: reff_id, read_receipts: read_receipts, chat_id: chat_id, is_call_center: is_call_center, call_center_id: call_center_id, opposite_pin: opposite_pin)
|
|
|
- Nexilis.addQueueMessage(message: message)
|
|
|
+ Nexilis.saveMessage(message: message)
|
|
|
let messageId = String(message.mBodies[CoreMessage_TMessageKey.MESSAGE_ID]!)
|
|
|
var row: [String: Any?] = [:]
|
|
|
row["message_id"] = messageId
|
|
@@ -230,7 +232,7 @@ class ChatGPTBotView: UIViewController, UIGestureRecognizerDelegate {
|
|
|
gptRow["content"] = row["message_text"] as! String
|
|
|
chatGPTMessages.append(gptRow)
|
|
|
let jsonBody = Payload(use_video: "0", payload: chatGPTMessages)
|
|
|
- request(data: jsonBody)
|
|
|
+ request(mesage: row["message_text"] as! String)
|
|
|
tableChatView.insertRows(at: [IndexPath(row: dataMessages.filter({ $0["chat_date"] as! String == dataDates[dataDates.count - 1]}).count - 1, section: dataDates.count - 1)], with: .none)
|
|
|
if textFieldSend.text!.trimmingCharacters(in: .whitespacesAndNewlines) != "Send message".localized() && textFieldSend.textColor != UIColor.lightGray && constraintViewTextField.constant == 0 {
|
|
|
textFieldSend.text = "Send message".localized()
|
|
@@ -268,167 +270,187 @@ class ChatGPTBotView: UIViewController, UIGestureRecognizerDelegate {
|
|
|
// }
|
|
|
}
|
|
|
|
|
|
- private func request(data: Payload) {
|
|
|
- AF.request(CHATGPT_URL, method: .post, parameters: data, encoder: JSONParameterEncoder.default)
|
|
|
- .responseJSON{ response in
|
|
|
- if let result = response.value as? [String: Any], let message = result["message"] as? [String: String] {
|
|
|
- self.chatGPTMessages.append(message)
|
|
|
- guard let me = UserDefaults.standard.string(forKey: "me") else {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- var user_id:String? = ""
|
|
|
- let message_id = me + CoreMessage_TMessageUtil.getTID()
|
|
|
- let server_date = String(Date().currentTimeMillis())
|
|
|
-
|
|
|
- Database.shared.database?.inTransaction({ (fmdb, rollback) in
|
|
|
- if let cursor = Database.shared.getRecords(fmdb: fmdb, query: "select user_id from BUDDY where f_pin = '\(me)'"), cursor.next() {
|
|
|
- user_id = cursor.string(forColumnIndex: 0)
|
|
|
- cursor.close()
|
|
|
- }
|
|
|
- })
|
|
|
- Database.shared.database?.inTransaction({ (fmdb, rollback) in
|
|
|
- do {
|
|
|
- _ = try Database.shared.insertRecord(fmdb: fmdb, table: "MESSAGE", cvalues: [
|
|
|
- "message_id" : message_id ,
|
|
|
- "f_pin" : "-997",
|
|
|
- "f_display_name" : "GPT SmartBot",
|
|
|
- "l_pin" : me,
|
|
|
- "l_user_id" : String(user_id!),
|
|
|
- "message_scope_id" : "31",
|
|
|
- "server_date" : server_date,
|
|
|
- "status" : "3",
|
|
|
- "message_text" : message["content"],
|
|
|
- "audio_id" : "",
|
|
|
- "video_id" : "",
|
|
|
- "image_id" : "",
|
|
|
- "file_id" : "",
|
|
|
- "thumb_id" : "",
|
|
|
- "opposite_pin" : "",
|
|
|
- "format" : "",
|
|
|
- "blog_id" : "",
|
|
|
- "read_receipts" : "0",
|
|
|
- "chat_id" : "",
|
|
|
- "account_type" : "1",
|
|
|
- "credential" :"",
|
|
|
- "reff_id" : "",
|
|
|
- "message_large_text" : "",
|
|
|
- "attachment_flag" : "0",
|
|
|
- "local_timestamp" : String(Date().currentTimeMillis())
|
|
|
- ], replace: true)
|
|
|
- } catch {
|
|
|
- rollback.pointee = true
|
|
|
- //print(error)
|
|
|
- }
|
|
|
- })
|
|
|
- let pin = "-997"
|
|
|
- var counter : Int? = nil
|
|
|
- Database.shared.database?.inTransaction({ (fmdb, rollback) in
|
|
|
- if let cursor = Database.shared.getRecords(fmdb: fmdb, query: "select counter from MESSAGE_SUMMARY where l_pin = '\(pin)'"), cursor.next() {
|
|
|
- counter = Int(cursor.int(forColumnIndex: 0))
|
|
|
- counter! += 1
|
|
|
- cursor.close()
|
|
|
- //print("select db message summary")
|
|
|
- }
|
|
|
- })
|
|
|
- if counter == nil {
|
|
|
- counter = 1
|
|
|
- //print("set counter message summary")
|
|
|
- }
|
|
|
- Database.shared.database?.inTransaction({ (fmdb, rollback) in
|
|
|
- do {
|
|
|
- _ = try Database.shared.insertRecord(fmdb: fmdb, table: "MESSAGE_SUMMARY", cvalues: [
|
|
|
- "l_pin" : pin,
|
|
|
- "message_id" : message_id,
|
|
|
- "counter" : counter!
|
|
|
- ], replace: true)
|
|
|
- } catch {
|
|
|
- rollback.pointee = true
|
|
|
- //print(error)
|
|
|
- }
|
|
|
- })
|
|
|
- //print("insert db message summary \(message_id)")
|
|
|
- var row: [String: Any?] = [:]
|
|
|
- row["message_id"] = message_id
|
|
|
- row["f_pin"] = "-997"
|
|
|
- row["l_pin"] = me
|
|
|
- row["message_scope_id"] = "31"
|
|
|
- row["server_date"] = server_date
|
|
|
- row["status"] = "3"
|
|
|
- row["message_text"] = message["content"]
|
|
|
- row["audio_id"] = ""
|
|
|
- row["video_id"] = ""
|
|
|
- row["image_id"] = ""
|
|
|
- row["thumb_id"] = ""
|
|
|
- row["read_receipts"] = "0"
|
|
|
- row["credential"] = ""
|
|
|
- row["file_id"] = ""
|
|
|
- row["reff_id"] = ""
|
|
|
- row["progress"] = 100.0
|
|
|
- row["attachment_flag"] = "0"
|
|
|
- row["lock"] = ""
|
|
|
- row["is_stared"] = "0"
|
|
|
- row["isSelected"] = false
|
|
|
- if !self.dataDates.contains("Today".localized()) {
|
|
|
- self.dataDates.append("Today".localized())
|
|
|
- self.tableChatView.insertSections(IndexSet(integer: self.dataDates.count - 1), with: .none)
|
|
|
- }
|
|
|
- row["chat_date"] = "Today".localized()
|
|
|
- row["blog_id"] = "0"
|
|
|
- self.counter += 1
|
|
|
- self.dataMessages.append(row)
|
|
|
- self.tableChatView.insertRows(at: [IndexPath(row: self.dataMessages.filter({ $0["chat_date"] as! String == self.dataDates[self.dataDates.count - 1]}).count - 1, section: self.dataDates.count - 1)], with: .none)
|
|
|
- if self.currentIndexpath?.row == (self.dataMessages.count - 2) {
|
|
|
- if (self.viewIfLoaded?.window != nil) {
|
|
|
- self.sendReadMessageStatus(chat_id: "", f_pin: row["f_pin"] as! String, message_scope_id: row["message_scope_id"] as! String, message_id: message_id)
|
|
|
- }
|
|
|
- self.tableChatView.scrollToBottom()
|
|
|
- if ( self.currentIndexpath!.section <= self.dataDates.count - 1 && self.currentIndexpath!.row <= self.dataMessages.filter({ $0["chat_date"] as! String == self.dataDates[self.dataDates.count - 1]}).count - 1) {
|
|
|
- self.counter = 0
|
|
|
- self.updateCounter(counter: self.counter)
|
|
|
- }
|
|
|
- let lastMarkerCounter = self.markerCounter
|
|
|
- if self.markerCounter != nil {
|
|
|
- self.markerCounter = nil
|
|
|
- }
|
|
|
- self.tableChatView.beginUpdates()
|
|
|
- let indexMessage = self.dataMessages.firstIndex(where: { $0["message_id"] as? String == lastMarkerCounter })
|
|
|
- if indexMessage != nil {
|
|
|
- let section = self.dataDates.firstIndex(of: self.dataMessages[indexMessage!]["chat_date"] as! String)
|
|
|
- let row = self.dataMessages.filter({ $0["chat_date"] as! String == self.dataMessages[indexMessage!]["chat_date"] as! String}).firstIndex(where: { $0["message_id"] as? String == self.dataMessages[indexMessage!]["message_id"] as? String })
|
|
|
- if row != nil && section != nil {
|
|
|
- self.tableChatView.reloadRows(at: [IndexPath(row: row!, section: section!)], with: .none)
|
|
|
- }
|
|
|
- }
|
|
|
- self.tableChatView.endUpdates()
|
|
|
- }
|
|
|
- else if self.currentIndexpath == nil {
|
|
|
- self.counter = 0
|
|
|
- self.updateCounter(counter: self.counter)
|
|
|
- if (self.viewIfLoaded?.window != nil) {
|
|
|
- self.sendReadMessageStatus(chat_id: "", f_pin: row["f_pin"] as! String, message_scope_id: row["message_scope_id"] as! String, message_id: message_id)
|
|
|
- }
|
|
|
- }
|
|
|
- else if self.counter != 0 {
|
|
|
- if !self.indicatorCounterBSTB.isDescendant(of: self.view) && self.buttonScrollToBottom.isDescendant(of: self.view) {
|
|
|
- self.markerCounter = row["message_id"] as? String
|
|
|
- self.addCounterAtButttonScrollToBottom()
|
|
|
- self.tableChatView.beginUpdates()
|
|
|
- let indexMessage = self.dataMessages.firstIndex(where: { $0["message_id"] as? String == self.markerCounter })
|
|
|
- if indexMessage != nil {
|
|
|
- let section = self.dataDates.firstIndex(of: self.dataMessages[indexMessage!]["chat_date"] as! String)
|
|
|
- let row = self.dataMessages.filter({ $0["chat_date"] as! String == self.dataMessages[indexMessage!]["chat_date"] as! String}).firstIndex(where: { $0["message_id"] as? String == self.dataMessages[indexMessage!]["message_id"] as? String })
|
|
|
- if row != nil && section != nil {
|
|
|
- self.tableChatView.reloadRows(at: [IndexPath(row: row!, section: section!)], with: .none)
|
|
|
+ private func request(mesage: String) {
|
|
|
+ DispatchQueue.global().async {
|
|
|
+ do {
|
|
|
+ if let response = Nexilis.writeSync(message: CoreMessage_TMessageBank.requestGPTBot(message: mesage)) {
|
|
|
+ if response.isOk() {
|
|
|
+ let data = response.getBody(key: CoreMessage_TMessageKey.DATA)
|
|
|
+ if let json = try! JSONSerialization.jsonObject(with: data.data(using: String.Encoding.utf8)!, options: []) as? [String: Any?] {
|
|
|
+ print("HMM \(json)")
|
|
|
+ DispatchQueue.main.async {
|
|
|
+ var gptRow : [String: String] = [:]
|
|
|
+ gptRow["role"] = json["role"] as? String
|
|
|
+ gptRow["content"] = json["content"] as? String
|
|
|
+ self.chatGPTMessages.append(gptRow)
|
|
|
+ guard let me = UserDefaults.standard.string(forKey: "me") else {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var user_id:String? = ""
|
|
|
+ let message_id = me + CoreMessage_TMessageUtil.getTID()
|
|
|
+ let server_date = String(Date().currentTimeMillis())
|
|
|
+
|
|
|
+ Database.shared.database?.inTransaction({ (fmdb, rollback) in
|
|
|
+ if let cursor = Database.shared.getRecords(fmdb: fmdb, query: "select user_id from BUDDY where f_pin = '\(me)'"), cursor.next() {
|
|
|
+ user_id = cursor.string(forColumnIndex: 0)
|
|
|
+ cursor.close()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ Database.shared.database?.inTransaction({ (fmdb, rollback) in
|
|
|
+ do {
|
|
|
+ _ = try Database.shared.insertRecord(fmdb: fmdb, table: "MESSAGE", cvalues: [
|
|
|
+ "message_id" : message_id ,
|
|
|
+ "f_pin" : "-997",
|
|
|
+ "f_display_name" : "GPT SmartBot",
|
|
|
+ "l_pin" : me,
|
|
|
+ "l_user_id" : String(user_id!),
|
|
|
+ "message_scope_id" : "31",
|
|
|
+ "server_date" : server_date,
|
|
|
+ "status" : "3",
|
|
|
+ "message_text" : gptRow["content"],
|
|
|
+ "audio_id" : "",
|
|
|
+ "video_id" : "",
|
|
|
+ "image_id" : "",
|
|
|
+ "file_id" : "",
|
|
|
+ "thumb_id" : "",
|
|
|
+ "opposite_pin" : "",
|
|
|
+ "format" : "",
|
|
|
+ "blog_id" : "",
|
|
|
+ "read_receipts" : "0",
|
|
|
+ "chat_id" : "",
|
|
|
+ "account_type" : "1",
|
|
|
+ "credential" :"",
|
|
|
+ "reff_id" : "",
|
|
|
+ "message_large_text" : "",
|
|
|
+ "attachment_flag" : "0",
|
|
|
+ "local_timestamp" : String(Date().currentTimeMillis())
|
|
|
+ ], replace: true)
|
|
|
+ } catch {
|
|
|
+ rollback.pointee = true
|
|
|
+ //print(error)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ let pin = "-997"
|
|
|
+ var counter : Int? = nil
|
|
|
+ Database.shared.database?.inTransaction({ (fmdb, rollback) in
|
|
|
+ if let cursor = Database.shared.getRecords(fmdb: fmdb, query: "select counter from MESSAGE_SUMMARY where l_pin = '\(pin)'"), cursor.next() {
|
|
|
+ counter = Int(cursor.int(forColumnIndex: 0))
|
|
|
+ counter! += 1
|
|
|
+ cursor.close()
|
|
|
+ //print("select db message summary")
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if counter == nil {
|
|
|
+ counter = 1
|
|
|
+ //print("set counter message summary")
|
|
|
+ }
|
|
|
+ Database.shared.database?.inTransaction({ (fmdb, rollback) in
|
|
|
+ do {
|
|
|
+ _ = try Database.shared.insertRecord(fmdb: fmdb, table: "MESSAGE_SUMMARY", cvalues: [
|
|
|
+ "l_pin" : pin,
|
|
|
+ "message_id" : message_id,
|
|
|
+ "counter" : counter!
|
|
|
+ ], replace: true)
|
|
|
+ } catch {
|
|
|
+ rollback.pointee = true
|
|
|
+ //print(error)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ //print("insert db message summary \(message_id)")
|
|
|
+ var row: [String: Any?] = [:]
|
|
|
+ row["message_id"] = message_id
|
|
|
+ row["f_pin"] = "-997"
|
|
|
+ row["l_pin"] = me
|
|
|
+ row["message_scope_id"] = "31"
|
|
|
+ row["server_date"] = server_date
|
|
|
+ row["status"] = "3"
|
|
|
+ row["message_text"] = gptRow["content"]
|
|
|
+ row["audio_id"] = ""
|
|
|
+ row["video_id"] = ""
|
|
|
+ row["image_id"] = ""
|
|
|
+ row["thumb_id"] = ""
|
|
|
+ row["read_receipts"] = "0"
|
|
|
+ row["credential"] = ""
|
|
|
+ row["file_id"] = ""
|
|
|
+ row["reff_id"] = ""
|
|
|
+ row["progress"] = 100.0
|
|
|
+ row["attachment_flag"] = "0"
|
|
|
+ row["lock"] = ""
|
|
|
+ row["is_stared"] = "0"
|
|
|
+ row["isSelected"] = false
|
|
|
+ if !self.dataDates.contains("Today".localized()) {
|
|
|
+ self.dataDates.append("Today".localized())
|
|
|
+ self.tableChatView.insertSections(IndexSet(integer: self.dataDates.count - 1), with: .none)
|
|
|
+ }
|
|
|
+ row["chat_date"] = "Today".localized()
|
|
|
+ row["blog_id"] = "0"
|
|
|
+ self.counter += 1
|
|
|
+ self.dataMessages.append(row)
|
|
|
+ self.tableChatView.insertRows(at: [IndexPath(row: self.dataMessages.filter({ $0["chat_date"] as! String == self.dataDates[self.dataDates.count - 1]}).count - 1, section: self.dataDates.count - 1)], with: .none)
|
|
|
+ if self.currentIndexpath?.row == (self.dataMessages.count - 2) {
|
|
|
+ if (self.viewIfLoaded?.window != nil) {
|
|
|
+ self.sendReadMessageStatus(chat_id: "", f_pin: row["f_pin"] as! String, message_scope_id: row["message_scope_id"] as! String, message_id: message_id)
|
|
|
+ }
|
|
|
+ self.tableChatView.scrollToBottom()
|
|
|
+ if ( self.currentIndexpath!.section <= self.dataDates.count - 1 && self.currentIndexpath!.row <= self.dataMessages.filter({ $0["chat_date"] as! String == self.dataDates[self.dataDates.count - 1]}).count - 1) {
|
|
|
+ self.counter = 0
|
|
|
+ self.updateCounter(counter: self.counter)
|
|
|
+ }
|
|
|
+ let lastMarkerCounter = self.markerCounter
|
|
|
+ if self.markerCounter != nil {
|
|
|
+ self.markerCounter = nil
|
|
|
+ }
|
|
|
+ self.tableChatView.beginUpdates()
|
|
|
+ let indexMessage = self.dataMessages.firstIndex(where: { $0["message_id"] as? String == lastMarkerCounter })
|
|
|
+ if indexMessage != nil {
|
|
|
+ let section = self.dataDates.firstIndex(of: self.dataMessages[indexMessage!]["chat_date"] as! String)
|
|
|
+ let row = self.dataMessages.filter({ $0["chat_date"] as! String == self.dataMessages[indexMessage!]["chat_date"] as! String}).firstIndex(where: { $0["message_id"] as? String == self.dataMessages[indexMessage!]["message_id"] as? String })
|
|
|
+ if row != nil && section != nil {
|
|
|
+ self.tableChatView.reloadRows(at: [IndexPath(row: row!, section: section!)], with: .none)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ self.tableChatView.endUpdates()
|
|
|
+ }
|
|
|
+ else if self.currentIndexpath == nil {
|
|
|
+ self.counter = 0
|
|
|
+ self.updateCounter(counter: self.counter)
|
|
|
+ if (self.viewIfLoaded?.window != nil) {
|
|
|
+ self.sendReadMessageStatus(chat_id: "", f_pin: row["f_pin"] as! String, message_scope_id: row["message_scope_id"] as! String, message_id: message_id)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if self.counter != 0 {
|
|
|
+ if !self.indicatorCounterBSTB.isDescendant(of: self.view) && self.buttonScrollToBottom.isDescendant(of: self.view) {
|
|
|
+ self.markerCounter = row["message_id"] as? String
|
|
|
+ self.addCounterAtButttonScrollToBottom()
|
|
|
+ self.tableChatView.beginUpdates()
|
|
|
+ let indexMessage = self.dataMessages.firstIndex(where: { $0["message_id"] as? String == self.markerCounter })
|
|
|
+ if indexMessage != nil {
|
|
|
+ let section = self.dataDates.firstIndex(of: self.dataMessages[indexMessage!]["chat_date"] as! String)
|
|
|
+ let row = self.dataMessages.filter({ $0["chat_date"] as! String == self.dataMessages[indexMessage!]["chat_date"] as! String}).firstIndex(where: { $0["message_id"] as? String == self.dataMessages[indexMessage!]["message_id"] as? String })
|
|
|
+ if row != nil && section != nil {
|
|
|
+ self.tableChatView.reloadRows(at: [IndexPath(row: row!, section: section!)], with: .none)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ self.tableChatView.endUpdates()
|
|
|
+ } else if self.indicatorCounterBSTB.isDescendant(of: self.view) {
|
|
|
+ self.labelCounter.text = "\(self.counter)"
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- self.tableChatView.endUpdates()
|
|
|
- } else if self.indicatorCounterBSTB.isDescendant(of: self.view) {
|
|
|
- self.labelCounter.text = "\(self.counter)"
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ } catch {
|
|
|
+ print("Error encoding data: \(error.localizedDescription)")
|
|
|
}
|
|
|
+ }
|
|
|
+// AF.request(CHATGPT_URL, method: .post, parameters: data, encoder: JSONParameterEncoder.default)
|
|
|
+// .responseJSON{ response in
|
|
|
+// if let result = response.value as? [String: Any], let message = result["message"] as? [String: String] {
|
|
|
+//
|
|
|
+// }
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
func loadData(){
|
|
@@ -2327,7 +2349,7 @@ extension ChatGPTBotView: UITextViewDelegate {
|
|
|
public func textViewDidBeginEditing(_ textView: UITextView) {
|
|
|
if textView.textColor == UIColor.lightGray {
|
|
|
textView.text = nil
|
|
|
- textView.textColor = UIColor.black
|
|
|
+ textView.textColor = self.traitCollection.userInterfaceStyle == .dark ? .white : UIColor.black
|
|
|
}
|
|
|
}
|
|
|
|