Skip to content

Commit

Permalink
Added missing Handlers,
Browse files Browse the repository at this point in the history
moved Handlers into sub namespaces for better categorization,
Added a enum for ParseMode
  • Loading branch information
TiiFuchs committed May 28, 2024
1 parent 8fedb4a commit 24172a6
Show file tree
Hide file tree
Showing 51 changed files with 409 additions and 160 deletions.
17 changes: 17 additions & 0 deletions src/Handlers/BusinessConnection/BusinessConnection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Telepath\Handlers\BusinessConnection;

use Attribute;
use Telepath\Bot;
use Telepath\Handlers\Handler;
use Telepath\Telegram\Update;

#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
class BusinessConnection extends Handler
{
public function responsible(Bot $bot, Update $update): bool
{
return $update->business_connection !== null;
}
}
17 changes: 17 additions & 0 deletions src/Handlers/BusinessConnection/BusinessMessage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Telepath\Handlers\BusinessConnection;

use Attribute;
use Telepath\Bot;
use Telepath\Handlers\Handler;
use Telepath\Telegram\Update;

#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
class BusinessMessage extends Handler
{
public function responsible(Bot $bot, Update $update): bool
{
return $update->business_message !== null;
}
}
17 changes: 17 additions & 0 deletions src/Handlers/BusinessConnection/DeletedBusinessMessages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Telepath\Handlers\BusinessConnection;

use Attribute;
use Telepath\Bot;
use Telepath\Handlers\Handler;
use Telepath\Telegram\Update;

#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
class DeletedBusinessMessages extends Handler
{
public function responsible(Bot $bot, Update $update): bool
{
return $update->deleted_business_messages !== null;
}
}
18 changes: 18 additions & 0 deletions src/Handlers/BusinessConnection/EditedBusinessMessage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Telepath\Handlers\BusinessConnection;

use Attribute;
use Telepath\Bot;
use Telepath\Handlers\Handler;
use Telepath\Telegram\Update;

#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]

class EditedBusinessMessage extends Handler
{
public function responsible(Bot $bot, Update $update): bool
{
return $update->edited_business_message !== null;
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
<?php

namespace Telepath\Handlers;
namespace Telepath\Handlers\CallbackQuery;

use Attribute;
use Telepath\Telegram\Update;
use Telepath\Bot;
use Telepath\Handlers\Handler;
use Telepath\Telegram\Update;

#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
class CallbackQuery extends Handler
{

public function responsible(Bot $bot, Update $update): bool
{
return $update->callback_query !== null;
}

}
}
10 changes: 4 additions & 6 deletions src/Handlers/CallbackQuery/CallbackQueryData.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,20 @@
namespace Telepath\Handlers\CallbackQuery;

use Attribute;
use Telepath\Handlers\CallbackQuery;
use Telepath\Bot;
use Telepath\MatchMaker\MatchMaker;
use Telepath\Telegram\Update;
use Telepath\Bot;

#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
class CallbackQueryData extends CallbackQuery
{

public function __construct(
protected ?string $exact = null,
protected ?string $prefix = null,
protected ?string $regex = null,
protected ?string $suffix = null,
) {}
) {
}

public function responsible(Bot $bot, Update $update): bool
{
Expand All @@ -38,5 +37,4 @@ public function responsible(Bot $bot, Update $update): bool
->suffix($this->suffix)
->result();
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
namespace Telepath\Handlers;

use Attribute;
use Telepath\Telegram\Update;
use Telepath\Bot;
use Telepath\Telegram\Update;

#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
class ChannelPost extends Handler
{

public function responsible(Bot $bot, Update $update): bool
{
return $update->channel_post !== null;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
namespace Telepath\Handlers;

use Attribute;
use Telepath\Telegram\Update;
use Telepath\Bot;
use Telepath\Telegram\Update;

#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
class EditedChannelPost extends Handler
{

public function responsible(Bot $bot, Update $update): bool
{
return $update->edited_channel_post !== null;
}

}
}
16 changes: 16 additions & 0 deletions src/Handlers/ChatBoost/ChatBoost.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Telepath\Handlers\ChatBoost;

use Telepath\Bot;
use Telepath\Handlers\Handler;
use Telepath\Telegram\Update;

#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
class ChatBoost extends Handler
{
public function responsible(Bot $bot, Update $update): bool
{
return $update->chat_boost !== null;
}
}
16 changes: 16 additions & 0 deletions src/Handlers/ChatBoost/RemovedChatBoost.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Telepath\Handlers\ChatBoost;

use Telepath\Bot;
use Telepath\Handlers\Handler;
use Telepath\Telegram\Update;

#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
class RemovedChatBoost extends Handler
{
public function responsible(Bot $bot, Update $update): bool
{
return $update->removed_chat_boost !== null;
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
<?php

namespace Telepath\Handlers;
namespace Telepath\Handlers\ChatMember;

use Attribute;
use Telepath\Telegram\Update;
use Telepath\Bot;
use Telepath\Handlers\Handler;
use Telepath\Telegram\Update;

#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
class ChatJoinRequest extends Handler
{

public function responsible(Bot $bot, Update $update): bool
{
return $update->chat_join_request !== null;
}

}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
<?php

namespace Telepath\Handlers;
namespace Telepath\Handlers\ChatMember;

use Attribute;
use Telepath\Telegram\Update;
use Telepath\Bot;
use Telepath\Handlers\Handler;
use Telepath\Telegram\Update;

#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
class ChatMember extends Handler
{

public function responsible(Bot $bot, Update $update): bool
{
return $update->chat_member !== null;
}

}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
<?php

namespace Telepath\Handlers;
namespace Telepath\Handlers\ChatMember;

use Attribute;
use Telepath\Telegram\Update;
use Telepath\Bot;
use Telepath\Handlers\Handler;
use Telepath\Telegram\Update;

#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
class MyChatMember extends Handler
{

public function responsible(Bot $bot, Update $update): bool
{
return $update->my_chat_member !== null;
}

}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
<?php

namespace Telepath\Handlers;
namespace Telepath\Handlers\Checkout;

use Attribute;
use Telepath\Telegram\Update;
use Telepath\Bot;
use Telepath\Handlers\Handler;
use Telepath\Telegram\Update;

#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
class PreCheckoutQuery extends Handler
{

public function responsible(Bot $bot, Update $update): bool
{
return $update->pre_checkout_query !== null;
}

}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
<?php

namespace Telepath\Handlers;
namespace Telepath\Handlers\Checkout;

use Attribute;
use Telepath\Telegram\Update;
use Telepath\Bot;
use Telepath\Handlers\Handler;
use Telepath\Telegram\Update;

#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
class ShippingQuery extends Handler
{

public function responsible(Bot $bot, Update $update): bool
{
return $update->shipping_query !== null;
}

}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
<?php

namespace Telepath\Handlers;
namespace Telepath\Handlers\InlineQuery;

use Attribute;
use Telepath\Telegram\Update;
use Telepath\Bot;
use Telepath\Handlers\Handler;
use Telepath\Telegram\Update;

#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
class ChosenInlineResult extends Handler
{

public function responsible(Bot $bot, Update $update): bool
{
return $update->chosen_inline_result !== null;
}

}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
<?php

namespace Telepath\Handlers;
namespace Telepath\Handlers\InlineQuery;

use Attribute;
use Telepath\Telegram\Update;
use Telepath\Bot;
use Telepath\Handlers\Handler;
use Telepath\Telegram\Update;

#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
class InlineQuery extends Handler
{

public function responsible(Bot $bot, Update $update): bool
{
return $update->inline_query !== null;
}

}
}
Loading

0 comments on commit 24172a6

Please sign in to comment.