Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

Commit

Permalink
Fixed little bug & Added new feature 'Reply & Quote Reply'
Browse files Browse the repository at this point in the history
  • Loading branch information
zckyachmd committed Feb 4, 2022
1 parent e44b650 commit 33fa6ec
Show file tree
Hide file tree
Showing 27 changed files with 235 additions and 863 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
- [x] Auto Follow
- [x] Auto Retweet
- [x] Auto Like
- [x] Mass Report
- [x] Auto Report
- [x] Auto Reply & Quotes Reply

## Download

Expand Down
4 changes: 2 additions & 2 deletions application/config/constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@
#--------------------------------------------------------------------
# Twitter API
#--------------------------------------------------------------------
define('CONSUMER_KEY', '######################');
define('CONSUMER_SECRET', '###################');
define('CONSUMER_KEY', '##########################################');
define('CONSUMER_SECRET', '#######################################');

#--------------------------------------------------------------------
# DATABASE
Expand Down
87 changes: 80 additions & 7 deletions application/controllers/Home.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ public function follow()
}
}

$this->session->set_flashdata('result', "$this->i users success follow @$username!");
if ($this->i > 0) {
$this->session->set_flashdata('result', $this->i . " users success follow @$username!");
} else {
$this->session->set_flashdata('result', "No users success follow @$username!");
}
} else {

foreach ($getBot as $bot) {
Expand All @@ -52,7 +56,11 @@ public function follow()
}
}

$this->session->set_flashdata('result', "$this->i users success unfollow @$username!");
if ($this->i > 0) {
$this->session->set_flashdata('result', $this->i . " users success unfollow @$username!");
} else {
$this->session->set_flashdata('result', "No user unfollow @$username!");
}
}
}

Expand All @@ -78,7 +86,7 @@ public function report()
}
}

$this->session->set_flashdata('result', "$this->i users success report @$username!");
$this->session->set_flashdata('result', $this->i . " users success report @$username!");
}
}

Expand All @@ -104,7 +112,11 @@ public function retweet()
}
}

$this->session->set_flashdata('result', "$total users success retweet @$id!");
if ($this->i > 0) {
$this->session->set_flashdata('result', $this->i . " users success retweet @$id!");
} else {
$this->session->set_flashdata('result', "No users success retweet @$id!");
}
} else {
foreach ($getBot as $bot) {
$connect_bot = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $bot->oauth_token, $bot->oauth_token_secret);
Expand All @@ -115,7 +127,11 @@ public function retweet()
}
}

$this->session->set_flashdata('result', "$this->i users success unretweet @$id!");
if ($this->i > 0) {
$this->session->set_flashdata('result', $this->i . " users success unretweet @$id!");
} else {
$this->session->set_flashdata('result', "No users success unretweet @$id!");
}
}
}

Expand All @@ -141,7 +157,11 @@ public function favorite()
}
}

$this->session->set_flashdata('result', "$total users success favorite @$id!");
if ($this->i > 0) {
$this->session->set_flashdata('result', $this->i . "users success favorite @$id!");
} else {
$this->session->set_flashdata('result', "No users success favorite @$id!");
}
} else {
foreach ($getBot as $bot) {
$connect_bot = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $bot->oauth_token, $bot->oauth_token_secret);
Expand All @@ -152,7 +172,60 @@ public function favorite()
}
}

$this->session->set_flashdata('result', "$this->i users success unfavorite @$id!");
if ($this->i > 0) {
$this->session->set_flashdata('result', $this->i . " users success unfavorite @$id!");
} else {
$this->session->set_flashdata('result', "No users success unfavorite @$id!");
}
}
}

redirect(base_url('/'));
}

public function reply()
{
$id = $this->input->post('id', true);
$total = $this->input->post('total', true);
$reply = preg_split("/\r\n|\n|\r/", $this->input->post('reply', true));
$quotes = $this->input->post('quotes', true);

if ($id && $total && $reply) {
$username = null;
$idTweet = null;
$url = null;
$getBot = $this->db->get('users', $total)->result();

foreach ($getBot as $bot) {
$connect_bot = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $bot->oauth_token, $bot->oauth_token_secret);

if (empty($idTweet)) {
$getTweet = $connect_bot->get('statuses/show', ['id' => $id]);

if ($connect_bot->getLastHttpCode() == 200) {
$username = $getTweet->user->screen_name;
$idTweet = $getTweet->id;
$url = 'twitter.com/' . $username . '/status/' . $idTweet;
} else {
break;
}
}

if (!empty($quotes)) {
$connect_bot->post('statuses/update', ['status' => $reply[$this->i] . " " . $url]);
} else {
$connect_bot->post('statuses/update', ['status' => "@$username " . $reply[$this->i], 'in_reply_to_status_id' => $idTweet]);
}

if ($connect_bot->getLastHttpCode() == 200) {
$this->i++;
}
}

if ($this->i > 0) {
$this->session->set_flashdata('result', $this->i . " users success reply $id!");
} else {
$this->session->set_flashdata('result', "Failed to reply $id!");
}
}

Expand Down
45 changes: 38 additions & 7 deletions application/views/home.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<?php endif; ?>
<div class="row justify-content-center mb-4">
<div class="col-md-5 mx-4">
<div class="card">
<div class="card bg-dark text-light">
<div class="card-header">
<i class="fa fa-users" aria-hidden="true"></i> Follow
</div>
Expand Down Expand Up @@ -77,7 +77,7 @@
echo form_dropdown('follow', $options, '', ['class' => 'form-control', 'required' => true]);
?>
</div>
<?= form_submit('submit', 'Submit', ['class' => 'btn btn-dark']); ?>
<?= form_submit('submit', 'Submit', ['class' => 'btn btn-light']); ?>
<?= form_close(); ?>
</div>
</div>
Expand Down Expand Up @@ -107,8 +107,7 @@
<?php
$options = [
'' => 'Choose an action',
'add' => 'Added Report',
// 'reduce' => 'Reduce Report'
'add' => 'Spam Report'
];

echo form_dropdown('report', $options, '', ['class' => 'form-control', 'required' => true]);
Expand All @@ -122,7 +121,7 @@
</div>
<div class="row justify-content-center">
<div class="col-md-5 mx-4 mb-5">
<div class="card bg-dark text-light">
<div class="card">
<div class="card-header">
<i class="fa fa-retweet" aria-hidden="true"></i> Retweet
</div>
Expand Down Expand Up @@ -150,7 +149,7 @@
echo form_dropdown('retweet', $options, '', ['class' => 'form-control', 'required' => true]);
?>
</div>
<?= form_submit('submit', 'Submit', ['class' => 'btn btn-light']); ?>
<?= form_submit('submit', 'Submit', ['class' => 'btn btn-dark']); ?>
<?= form_close(); ?>
</div>
</div>
Expand Down Expand Up @@ -190,10 +189,42 @@
</div>
</div>
</div>
<div class="row justify-content-center">
<div class="col-md-11 mb-5">
<div class="card bg-dark text-light">
<div class="card-header">
<i class="fa fa-reply" aria-hidden="true"></i> Reply
</div>
<div class="card-body">
<?= form_open(base_url('home/reply'), "method='post'"); ?>
<div class="form-group">
<label for="id">ID Tweet</label>
<div class="input-group">
<?= form_input(['class' => 'form-control', 'type' => 'text', 'name' => 'id', 'id' => 'id', 'placeholder' => '1351107657210462208', 'required' => true]); ?>
</div>
</div>
<div class="form-group">
<label for="total">Total</label>
<?= form_input(['class' => 'form-control', 'type' => 'number', 'name' => 'total', 'id' => 'total', 'placeholder' => '100', 'required' => true]); ?>
</div>
<div class="form-group">
<label for="reply">Reply</label>
<?= form_textarea(['class' => 'form-control', 'name' => 'reply', 'id' => 'reply', 'rows' => 5, 'placeholder' => "Reply 1\nReply 2\nReply 3", 'required' => true]); ?>
</div>
<div class="form-group">
<?= form_checkbox('quotes', '1', FALSE, ['id' => 'quotes']); ?>
<label for="quotes"> Quotes Reply</label>
</div>
<?= form_submit('submit', 'Submit', ['class' => 'btn btn-light']); ?>
<?= form_close(); ?>
</div>
</div>
</div>
</div>
</div>
<footer class="footer fixed-bottom bg-dark">
<div class="container text-center">
<span class="text-white">Copyright 2020 <i class="far fa-copyright"></i> Made with <i class="fas fa-heart"></i> by <a href=" https://www.zacky.id" target="_blank" class="text-decoration-none text-white">Zacky Achmad</a></span>
<span class="text-white">Copyright <?= date('Y'); ?> <i class="far fa-copyright"></i> Made with <i class="fas fa-heart"></i> by <a href=" https://www.zacky.id" target="_blank" class="text-decoration-none text-white">Zacky Achmad</a></span>
</div>
</footer>

Expand Down
2 changes: 1 addition & 1 deletion application/views/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</div>
<?php endif; ?>
<a href="<?= base_url('auth/connect'); ?>" class="btn btn-md btn-dark btn-block">Sign in</a>
<p class="mt-5 mb-3 text-muted">Copyright 2020 <i class="far fa-copyright"></i> Zacky Achmad</p>
<p class="mt-5 mb-3 text-muted">Copyright <?= date('Y'); ?> <i class="far fa-copyright"></i> Zacky Achmad</p>
</div>

<script src="<?= base_url('assets/libs/jquery/jquery.min.js'); ?>"></script>
Expand Down
5 changes: 0 additions & 5 deletions vendor/abraham/twitteroauth/.gitignore

This file was deleted.

46 changes: 0 additions & 46 deletions vendor/abraham/twitteroauth/CODE_OF_CONDUCT.md

This file was deleted.

21 changes: 0 additions & 21 deletions vendor/abraham/twitteroauth/CONTRIBUTING.md

This file was deleted.

11 changes: 0 additions & 11 deletions vendor/abraham/twitteroauth/README.md

This file was deleted.

2 changes: 1 addition & 1 deletion vendor/abraham/twitteroauth/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"composer/ca-bundle": "^1.2"
},
"require-dev": {
"phpunit/phpunit": "^8",
"phpunit/phpunit": "^8 || ^9",
"squizlabs/php_codesniffer": "^3",
"phpmd/phpmd": "^2",
"php-vcr/php-vcr": "^1",
Expand Down
15 changes: 0 additions & 15 deletions vendor/abraham/twitteroauth/phpmd.xml

This file was deleted.

18 changes: 0 additions & 18 deletions vendor/abraham/twitteroauth/phpunit.xml

This file was deleted.

Loading

0 comments on commit 33fa6ec

Please sign in to comment.