Skip to content

Commit

Permalink
upgrade text filter
Browse files Browse the repository at this point in the history
  • Loading branch information
nerzh committed Jun 15, 2021
1 parent cb87e6d commit f65ae64
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Sources/telegram-vapor-bot/Bot/Filters/TextFilter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,21 @@ import Foundation
public class TextFilter: TGFilter {

public var name: String = "text"
private var value: String? = nil

override
public func filter(message: TGMessage) -> Bool {
guard let text = message.text else { return false }
if let value = value {
return text == value
}
return !text.isEmpty
}

public func value(_ value: String) -> Self {
self.value = value
return self
}
}

public extension TGFilter {
Expand Down

0 comments on commit f65ae64

Please sign in to comment.