Skip to content

Commit

Permalink
Update MoonDoge.php
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinebaron authored Jun 19, 2021
1 parent 16a80ec commit f0ffe1f
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions MoonDoge.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ public function run(?string $screenName = ''){
protected function monitor(){

if($this->screenName!=false){
$idUser = $this->getTwitterIdFromScreenName($this->screenName);
$this->idUser = $this->getTwitterIdFromScreenName($this->screenName);
}else{
$idUser = 44196397; //elon musk id
$this->idUser = 44196397; //elon musk id
$screenName = 'Elonmusk';
}

Expand All @@ -91,18 +91,21 @@ protected function monitor(){
$this->connectToTwitterWebsocket();

// watch for new tweets
$this->twitterSocket->whenTweets($idUser, function(array $tweet) {
$this->twitterSocket->whenTweets($this->idUser, function(array $tweet) {

$this->output("New tweet : \"" . $this->formatTweet($tweet['text']) . "\" (tweet created at " . $tweet['created_at'] . ")");
$this->output("Check the tweet ...");
if($this->idUser == $tweet['user']['id']){

$this->output("New tweet : \"" . $this->formatTweet($tweet['text']) . "\" (tweet created at " . $tweet['created_at'] . ")");
$this->output("Check the tweet ...");

// if tweet contain doge ...
if($this->checkTweet($tweet)==true){
// if tweet contain doge ...
if($this->checkTweet($tweet)==true){

$this->dogeToTheMoon();
exit;
$this->dogeToTheMoon();
exit;
}
}

})->startListening();
}

Expand Down Expand Up @@ -230,7 +233,12 @@ protected function checkTweet($tweet):bool{

$this->output("Tweet is a reply ... wait for another tweet");
return false;


}elseif(substr($tweet['txt'], 0, 2) === 'RT'){

$this->output("Tweet is a RT ... wait for another tweet");
return false;

}else{ // not a reply, check if contains "doge" or "dogecoin"

$regex = "/(\s|^)(doge|dogecoin)(\?*|\!*)(\s|$)/i";
Expand Down

0 comments on commit f0ffe1f

Please sign in to comment.