Skip to content

Commit

Permalink
Updated composer json
Browse files Browse the repository at this point in the history
  • Loading branch information
muhammedsaidckr committed Jun 24, 2024
1 parent fcd94db commit 6a27646
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 33 deletions.
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"license": "MIT",
"require": {
"flarum/core": "^1.2.0",
"blomstra/database-queue": "^1.0.0",
"google-gemini-php/client": "^1.0"
},
"authors": [
Expand Down
24 changes: 5 additions & 19 deletions src/Agent.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ class Agent

public function __construct(
public readonly User $user,
protected ?Client $client = null,
)
{
protected ?Client $client = null,
) {
}

// public function operational(): bool
Expand All @@ -41,31 +40,18 @@ public function repliesTo(Discussion $discussion): void

$respond = $response->text();

if (empty($respond)) return;
if (empty($respond)) {
return;
}

$userPrompt = $this->user->id;

// if (Str::startsWith($respond, 'FLAG: ')) {
// $flag = new Flag(
// Str::after($respond, 'FLAG: '),
// $discussion
// );
//
// $flag();
// } else {
// $reply = new Reply(
// reply: $respond,
// shouldMention: $this->canMention,
// inReplyTo: $discussion
// );

CommentPost::reply(
discussionId: $discussion->id,
content: $respond,
userId: $userPrompt,
ipAddress: '127.0.0.1'
)->save();
// }
}

}
2 changes: 0 additions & 2 deletions src/BindingsProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,5 @@ public function boot(Container $container)
{
Action::setEventDispatcher($this->container->make(Dispatcher::class));
Action::setAgent($this->container->make(Agent::class));

// Factory::setAgent($this->container->make(Agent::class));
}
}
1 change: 0 additions & 1 deletion src/ClientProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ protected function getAgent(SettingsRepositoryInterface $settings, ExtensionMana
client: $client,
);

// $agent->toggleMentioning($extensions->isEnabled('flarum-mentions'));

return $agent;
}
Expand Down
12 changes: 2 additions & 10 deletions src/Listener/ReplyToPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ class ReplyToPost
public function __construct(
protected Agent $agent,
protected Queue $queue
)
{
) {
}

/**
Expand All @@ -22,14 +21,7 @@ public function __construct(
*/
public function handle(Started $event): void
{
// if (!$this->agent->operational()
// || $this->agent->is($event->discussion->user)
// ) {
// $this
// return;
// }
// Add logic to handle the event here.
// See https://docs.flarum.org/extend/backend-events.html for more information.
$this->queue->push(new ReplyJob($event->discussion));
$this->queue->push(new ReplyJob($event->discussion), null, 'flarum');
}
}

0 comments on commit 6a27646

Please sign in to comment.