This site is developed to XHTML and CSS2 W3C standards.
If you see this paragraph, your browser does not support those standards and you
need to upgrade. Visit WaSP
for a variety of options.
Paste #672
Posted by: BitByByte
Posted on: 2026-04-15 00:32:49
Age: 1 day ago
Views: 14
import socket
import threading
import time
import requests
HOST = "dmconnect.hoho.ws"
PORT = 42439
API_URL = "http://twitbirth.downgrade-net.ru/api.php?update.json"
twitbirth_auth = {
"email": None,
"password": None
}
def send(sock, text):
sock.sendall((text + "\n").encode("utf-8"))
def keep_alive(sock):
while True:
try:
sock.sendall(b"/")
time.sleep(5)
except:
break
def post_status(text):
if not twitbirth_auth["email"]:
return "Twitbirth not configured. Use !set email:password"
try:
r = requests.post(
API_URL,
data={"status": text},
auth=(twitbirth_auth["email"], twitbirth_auth["password"]),
timeout=10
)
if r.status_code == 200:
return "Posted!"
else:
return f"Error: {r.status_code} {r.text}"
except Exception as e:
return f"Error: {e}"
def handle_command(sock, user, message):
message = message.strip()
if message == "!help":
return "Commands: !help, !set email:password, !exit"
elif message.startswith("!set "):
try:
data = message[5:]
email, password = data.split(":", 1)
twitbirth_auth["email"] = email
twitbirth_auth["password"] = password
return "Twitbirth credentials set! Your status will now update after each message you send. If you want to log out, send the \"!exit\" command."
except:
return "Usage: !set email:password"
elif message == "!exit":
twitbirth_auth["email"] = None
twitbirth_auth["password"] = None
return "Logged out from Twitbirth. Login later with: !set email:password"
else:
return post_status(message)
def listen(sock):
buffer = ""
while True:
try:
data = sock.recv(4096).decode("utf-8", errors="ignore")
if not data:
break
buffer += data
while "\n" in buffer:
line, buffer = buffer.split("\n", 1)
line = line.strip()
if not line.startswith("*Ping!*"):
print(line)
if line.startswith("(Private) "):
try:
content = line[len("(Private) "):]
user, msg = content.split(":", 1)
user = user.strip()
msg = msg.strip()
response = handle_command(sock, user, msg)
if response:
send(sock, f"/pm {user} {response}")
except Exception as e:
print("Error:", e)
except Exception as e:
print("Error:", e)
break
def main():
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((HOST, PORT))
username = "XXXXXXXX"
password = "XXXXXXXX"
time.sleep(1)
send(sock, f"/login {username} {password}")
threading.Thread(target=keep_alive, args=(sock,), daemon=True).start()
listen(sock)
if __name__ == "__main__":
main()
Download raw |
Create new paste