29 lines
815 B
Swift
29 lines
815 B
Swift
import CoreLocation
|
|
import Foundation
|
|
|
|
extension String {
|
|
var firstLetter: String {
|
|
String(prefix(1)).uppercased()
|
|
}
|
|
|
|
var makeReply: String {
|
|
let allLines = components(separatedBy: .newlines)
|
|
let nonBlankLines = allLines.filter { !$0.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty }
|
|
var result = nonBlankLines.joined(separator: "\n")
|
|
result = "> \(result)"
|
|
return result
|
|
}
|
|
|
|
var isLocation: Bool {
|
|
hasPrefix("geo:")
|
|
}
|
|
|
|
var getLatLon: CLLocationCoordinate2D {
|
|
let geo = components(separatedBy: ":")[1]
|
|
let parts = geo.components(separatedBy: ",")
|
|
let lat = Double(parts[0]) ?? 0.0
|
|
let lon = Double(parts[1]) ?? 0.0
|
|
return CLLocationCoordinate2D(latitude: lat, longitude: lon)
|
|
}
|
|
}
|