public function behave(TwitterBot $bot)
    {
        $sql = <<<'SQL'
SELECT
*
FROM spymaster_game
WHERE finished = FALSE
AND end_timestamp <= NOW()
SQL;
        $result = Di::getDefault()->getDb()->query($sql);
        while ($game = SpymasterGame::createFromQueryResult($result)) {
            $game->finish($bot);
        }
    }
示例#2
0
    public function setLastSeenDmId($dmId)
    {
        $db = Di::getDefault()->getDb();
        $sql = <<<'SQL'
UPDATE twitter_client
SET last_seen_dm_id = :last_seen_dm_id
WHERE username = :username
SQL;
        $params = ['last_seen_dm_id' => $dmId, 'username' => $this->getUsername()];
        $result = $db->query($sql, $params);
        $row = $result->fetch();
        return $row['last_seen_dm_id'];
    }
示例#3
0
    /**
     * 
     * @param string $tweetId
     * 
     * @return SpymasterGame
     */
    public static function getByTweetId($tweetId)
    {
        $sql = <<<'SQL'
SELECT
*
FROM spymaster_game
WHERE tweet_id = :tweet_id
SQL;
        $params = ['tweet_id' => $tweetId];
        $result = Di::getDefault()->getDb()->query($sql, $params);
        return self::createFromQueryResult($result);
    }