people playing: 80, servers online: 27, games played: 142,000,000 Top Player: imapirate

  Toribash Community » Toribash » Mods » Third party
Register FAQ General Rules Community
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old Jun 30, 2018   #1
Surge
 
4th Dan Black Belt
Join Date: May 2016
Posts: 1,886
Clan: Adventure



[WIP] Bet Server Hosting Bot
Hi, very early WIP of a bot to (help) host a betting server.

Run in Python 3.6.x. Install the modules required through pip, I explained it in one of my other threads.

Right now all it does is join a server and record the chat, I'm gonna be updating this thread as I go along so please report any bugs if you find them.

python code:

import socket
import hashlib
import time
import threading

while 1:
port = input("Enter room port: ")
try:
port = int(port)
break
except:
pass

un = input("Enter username: ")
pw = input("Enter password: ")

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

try:
s.connect(("144.76.163.135", port))
except:
print("\nFailed to connect, are you sure you wrote the port correctly?")

pw = hashlib.md5(str(pw).encode()).hexdigest()
data = "mlogin "+str(un) + " " + str(pw) +" 0 0\n"

print("\nConnecting: " + data)

s.send(data.encode())

s.send(b"SPEC\n")

print("Starting to ping the server...\n")

def ping_server():
s.send(b"PING\n")
ping = threading.Timer(15.0, ping_server)
ping.start()

ping = threading.Timer(15.0, ping_server)
ping.start()

data_last = 0
user_nudges = {}
nudgeline = 1

while 1:

data = s.recv(1024)
#print(data.decode())
try:
if not data.decode() == data_last:
if data.decode().startswith("SAY"):
if "<^" in data.decode():
chat_user = str(data.decode()[data.decode().find("<")+4:data.decode().find(">")-3])
chat_msg = str(data.decode()[data.decode().find(">")+2:][:-1])
if not chat_user == un:

print(chat_user, "said", chat_msg)

if chat_msg == "!usenudge":
if chat_user in user_nudges:
print("! Nudged", chat_user, "to", str(nudgeline))
s.send(b"NUDGE", chat_user, str(nudgeline)+"\n")
else:
print("! Did not nudge", chat_user + ": no nudges")
#if chat_msg.startswith("!givenudge "):
#if chat_user in user_nudges:

# else:




data_last = data.decode()
except:
data = ""



Last edited by Surge; Jun 30, 2018 at 09:52 PM..
Surge is offline   Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:36 PM.




Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
ragdoll fighting game physics fighting game ragdoll fighting physics funmotion joints martial arts karate pc mac free game turn based game