people playing: 34, servers online: 13, games played: 142,000,000 Top Player: Money

  Toribash Community » Toribash » Mods » Third party
Register FAQ General Rules Community
Reply
 
Thread Tools Display Modes
Old Jun 30, 2018   #1
Surge
Forumite
 
4th Dan Black Belt
Join Date: May 2016
Posts: 1,936



[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
Old Jun 30, 2018   #2
ЯMrMiyagy
Astrophysicist
 
Black Hole Belt
Join Date: Jul 2014
Posts: 1,332



Can you help provide me with a download for Python, I do not know where to download it tbh, I can never get Python code to work with me, I could pm with you on Discord if you would like to help.
Psychology, the way to win Toribash games.

MrMiyagy is offline   Reply With Quote
Old Jun 30, 2018   #3
Surge
Forumite
 
4th Dan Black Belt
Join Date: May 2016
Posts: 1,936



Discord is best. NKLI#7204
Surge is offline   Reply With Quote
Reply


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 03:08 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