Last active
December 1, 2022 15:37
-
-
Save divinity76/9c9d3fc46d637cb7fc36fcf5efb724ea to your computer and use it in GitHub Desktop.
tibia broadcast
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
$message = 'Looking for people to join lvl 350 armor quest. meet us at lvl 350 door in premium area 12:15! (UTC+2/Poland time)'; | |
$hostname = "tibiafun.zapto.org"; | |
$port = 7171; | |
$account = 123; | |
$password = "?"; | |
$charname = "Stupid Broadcaster"; | |
broadcast_headless($message, $hostname, $port, $account, $password, $charname); | |
if (!function_exists("to_little_uint16_t")) { | |
function to_little_uint16_t(int $i): string | |
{ | |
return pack('v', $i); | |
} | |
} | |
function tibiastring(string $str): string | |
{ | |
return to_little_uint16_t(strlen($str)) . $str; | |
} | |
function broadcast_headless(string $message, string $hostname, int $port, int $account, string $password, string $charname): void | |
{ | |
require_once('classes/7.6.tibia_client.class.php'); | |
$client = new Tibia_client($hostname, $port, $account, $password, $charname); | |
sleep(1); | |
$client->say("!online"); | |
while ($packet = $client->internal->read_next_packet(true, true)) { | |
if (false !== stripos($packet, 'Players online')) { | |
var_dump($packet); | |
preg_match_all('/[A-Z][\w\ ]+/', $packet, $matches); | |
$matches = $matches[0]; | |
$matches = array_values(array_filter(array_map('trim', $matches), function (string $name): bool { | |
if (in_array($name, array("Players online", "Total"), true)) { | |
return false; | |
} | |
return !empty($name); | |
})); | |
var_dump($matches); | |
foreach ($matches as $recipient) { | |
echo "sending to {$recipient}\n"; | |
$data = "\x96"; // say | |
$data .= "\x04"; // SPEAK_PRIVATE | |
$data .= tibiastring($recipient); | |
$data .= tibiastring($message); | |
$client->internal->send($data); | |
sleep(1); | |
} | |
return; | |
} | |
} | |
} | |
function generate_private_message_packet(string $recipient, string $message): string | |
{ | |
$data = "\x96"; // say | |
$data .= "\x04"; // SPEAK_PRIVATE | |
$data .= tibiastring($recipient); | |
$data .= tibiastring($message); | |
return tibiastring($data); | |
} | |
function generate_cavebot_broadcast(): void | |
{ | |
$text = ' | |
Erehith [702], Szymon [402], Rick Sanchezos [17], Rick Sanchez [827], Sample [1049], Bamberek [865], Bring Back Ssa [593], Koku [1372], Marek Mostowiak [336], Lovelas [1037], Pentagram [200], Cien Kriminal [815], Tatus [30], Kriminal [245], Bobasito [415], Nunek [396], Rick Sanchezo [721],Volkswagen [740], Reaper [846], Golden Account [308], | |
14:50 Biala Dama [286], Banger [351], Fly Arrow [48], Green [1032], Red [57], Manas [239], Allixea [1420], Psycho Teddy [49], Masturbator [417], Bobby [775], Nikes [343], Bimberek [910], Magiczny Kaktus [206], Bangladesh [1202], Czarodziej [501], Manarunka [440], Ikes [1102], Yale [1042], Pvp God[979], Sir Pawel [441], | |
14:50 Brunoise [352], Haya [853], Yurge [705], Xxlemxx [106], Skydancer [16], Assage [86], Nigg [619], Claire [482] and Moevot [166]. | |
14:50 Total: 49 | |
'; | |
$text = trim($text); | |
preg_match_all('/[A-Z][\w\ ]+/', $text, $matches); | |
$matches = $matches[0]; | |
$matches = array_values(array_filter(array_map('trim', $matches), function (string $name): bool { | |
if (in_array($name, array("Players online", "Total"), true)) { | |
return false; | |
} | |
return !empty($name); | |
})); | |
$message = 'looking for people to join lvl 350 armor quest, meet us at lvl 350 door in premium area!'; | |
//$matches=["Nigg"]; | |
foreach ($matches as $match) { | |
echo "# {$match}\n"; | |
echo "fastExiva >>" . bin2hex(generate_private_message_packet($match, $message)) . "\n"; | |
echo "WaitX 2\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment