Skip to content

Commit

Permalink
fix filters
Browse files Browse the repository at this point in the history
  • Loading branch information
nerzh committed Jun 3, 2021
1 parent cd69e63 commit 8180b2d
Show file tree
Hide file tree
Showing 27 changed files with 40 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Sources/telegram-vapor-bot-lib/Bot/Filters/AllFilter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ public class AllFilter: TGFilter {
}

public extension TGFilter {
static var all = AllFilter()
static var all: AllFilter { AllFilter() }
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ public class AudioFilter: TGFilter {
}

public extension TGFilter {
static var audio = AudioFilter()
static var audio: AudioFilter { AudioFilter() }
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class CaptionEntityFilter: TGFilter {
}

public extension TGFilter {
static func captionEntity(type: TGMessageEntityType) -> TGFilter {
static func captionEntity(type: TGMessageEntityType) -> CaptionEntityFilter {
return CaptionEntityFilter(type: type)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class ChatFilter: TGFilter {
}

public extension TGFilter {
static func chat(chatId: Int64, username: String? = nil) -> TGFilter {
static func chat(chatId: Int64, username: String? = nil) -> ChatFilter {
return ChatFilter(chatId: chatId, username: username)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ public class CommandFilter: TGFilter {
for name in names {
if message.contains(command: name) {
trigger = true
break
}
}

return entity.contains(where: { $0.type == .botCommand }) && trigger
} else {
return entity.contains(where: { $0.type == .botCommand })
Expand All @@ -35,5 +37,5 @@ public class CommandFilter: TGFilter {
}

public extension TGFilter {
static var command = CommandFilter()
static var command: CommandFilter { CommandFilter() }
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ public class ContactFilter: TGFilter {
}

public extension TGFilter {
static var contact = ContactFilter()
static var contact: ContactFilter { ContactFilter() }
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ public class DocumentFilter: TGFilter {
}

public extension TGFilter {
static var document = DocumentFilter()
static var document: DocumentFilter { DocumentFilter() }
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class EntityFilter: TGFilter {
}

public extension TGFilter {
static func entity(types: [TGMessageEntityType]) -> TGFilter {
static func entity(types: [TGMessageEntityType]) -> EntityFilter {
return EntityFilter(types: types)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ public class ForwarderFilter: TGFilter {
}

public extension TGFilter {
static var forwarded = ForwarderFilter()
static var forwarded: ForwarderFilter { ForwarderFilter() }
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ public class GameFilter: TGFilter {
}

public extension TGFilter {
static var game = GameFilter()
static var game: GameFilter { GameFilter() }
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ public class GroupFilter: TGFilter {
}

public extension TGFilter {
static var group = GroupFilter()
static var group: GroupFilter { GroupFilter() }
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ public class InvoiceFilter: TGFilter {
}

public extension TGFilter {
static var invoice = InvoiceFilter()
static var invoice: InvoiceFilter { InvoiceFilter() }
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class LanguageFilter: TGFilter {
}

public extension TGFilter {
static func language(_ lang: String) -> TGFilter {
static func language(_ lang: String) -> LanguageFilter {
return LanguageFilter(lang: lang)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ public class LocationFilter: TGFilter {
}

public extension TGFilter {
static var location = LocationFilter()
static var location: LocationFilter { LocationFilter() }
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ public class PhotoFilter: TGFilter {
}

public extension TGFilter {
static var photo = PhotoFilter()
static var photo: PhotoFilter { PhotoFilter() }
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ public class PrivateFilter: TGFilter {
}

public extension TGFilter {
static var `private` = PrivateFilter()
static var `private`: PrivateFilter { PrivateFilter() }
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class RegexpFilter: TGFilter {
}

public extension TGFilter {
static func regexp(pattern: String, options: NSRegularExpression.Options = []) -> TGFilter {
static func regexp(pattern: String, options: NSRegularExpression.Options = []) -> RegexpFilter {
return RegexpFilter(pattern: pattern, options: options)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ public class ReplyFilter: TGFilter {
}

public extension TGFilter {
static var reply = ReplyFilter()
static var reply: ReplyFilter { ReplyFilter() }
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,28 @@ import Foundation
*/
public struct StatusUpdateFilters {
/// Messages that contain Message.groupChatCreated, Message.supergroupChatCreated or Message.channelChatCreated
public static var chatCreated: TGFilter { return ChatCreatedFilter() }
public static var chatCreated: ChatCreatedFilter { return ChatCreatedFilter() }

/// Messages that contain Message.deleteChatPhoto
public static var deleteChatPhoto: TGFilter { return DeleteChatPhotoFilter() }
public static var deleteChatPhoto: DeleteChatPhotoFilter { return DeleteChatPhotoFilter() }

/// Messages that contain Message.leftChatMember
public static var leftChatMember: TGFilter { return LeftChatMemberFilter() }
public static var leftChatMember: LeftChatMemberFilter { return LeftChatMemberFilter() }

/// Messages that contain Message.migrateFromChatId
public static var migrate: TGFilter { return MigrateFilter() }
public static var migrate: MigrateFilter { return MigrateFilter() }

/// Messages that contain Message.newChatMembers
public static var newChatMembers: TGFilter { return NewChatMembersFilter() }
public static var newChatMembers: NewChatMembersFilter { return NewChatMembersFilter() }

/// Messages that contain Message.newChatPhoto
public static var newChatPhoto: TGFilter { return NewChatPhotoFilter() }
public static var newChatPhoto: NewChatPhotoFilter { return NewChatPhotoFilter() }

/// Messages that contain Message.newChatTitle
public static var newChatTitle: TGFilter { return NewChatTitleFilter() }
public static var newChatTitle: NewChatTitleFilter { return NewChatTitleFilter() }

/// Messages that contain Message.pinnedMessage
public static var pinnedMessage: TGFilter { return PinnedMessageFilter() }
public static var pinnedMessage: PinnedMessageFilter { return PinnedMessageFilter() }
}

/// Messages that contain Message.groupChatCreated, Message.supergroupChatCreated or Message.channelChatCreated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ public class StickerFilter: TGFilter {
}

public extension TGFilter {
static var sticker = StickerFilter()
static var sticker: StickerFilter { StickerFilter() }
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ public class SuccesfulPaymentFilter: TGFilter {
}

public extension TGFilter {
static var successfulPayment = SuccesfulPaymentFilter()
static var successfulPayment: SuccesfulPaymentFilter { SuccesfulPaymentFilter() }
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ public class TextFilter: TGFilter {
}

public extension TGFilter {
static var text = TextFilter()
static var text: TextFilter { TextFilter() }
}
10 changes: 5 additions & 5 deletions Sources/telegram-vapor-bot-lib/Bot/Filters/UserFilter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,23 @@ public class UserFilter: TGFilter {
}

public extension TGFilter {
static func user(userId: Int64) -> TGFilter {
static func user(userId: Int64) -> UserFilter {
return UserFilter(userId: userId)
}

static func user(username: String) -> TGFilter {
static func user(username: String) -> UserFilter {
return UserFilter(username: username)
}

static func user(userIds: [Int64]) -> TGFilter {
static func user(userIds: [Int64]) -> UserFilter {
return UserFilter(userIds: userIds)
}

static func user(usernames: [String]) -> TGFilter {
static func user(usernames: [String]) -> UserFilter {
return UserFilter(usernames: usernames)
}

static func user(userIds: [Int64], usernames: [String]) -> TGFilter {
static func user(userIds: [Int64], usernames: [String]) -> UserFilter {
return UserFilter(userIds: userIds, usernames: usernames)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ public class VenueFilter: TGFilter {
}

public extension TGFilter {
static var venue = VenueFilter()
static var venue: VenueFilter { VenueFilter() }
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ public class VideoFilter: TGFilter {
}

public extension TGFilter {
static var video = VideoFilter()
static var video: VideoFilter { VideoFilter() }
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ public class VideoNoteFilter: TGFilter {
}

public extension TGFilter {
static var videoNote = VideoNoteFilter()
static var videoNote: VideoNoteFilter { VideoNoteFilter() }
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ public class VoiceFilter: TGFilter {
}

public extension TGFilter {
static var voice = VoiceFilter()
static var voice: VoiceFilter { VoiceFilter() }
}

0 comments on commit 8180b2d

Please sign in to comment.