Open hcphoon01 opened 6 years ago
Sure it is, but it depends on what you want to do. If you have two bots with different tasks then I'd choose one connection per bot. You can write a script for each one or you simply use threads, but that's up to you.
What would be the correct code for having two functions running in one bot?
@AdmagTwoXray You can just execute 2 times the login and save it in an other variable like:
First one
with ts3.query.TS3ServerConnection("localhost") as ts3conn: ts3conn.exec_( "login", client_login_name="login", client_login_password="password" )
Second one
with ts3.query.TS3ServerConnection("localhost") as ts3conn2: ts3conn.exec_( "login", client_login_name="login2", client_login_password="password2" )
I'm on v1 so used this code
if __name__ == "__main__": with ts3.query.TS3Connection(HOST, PORT) as ts3conn: ts3conn.login(client_login_name=USER, client_login_password=PASS) ts3conn.use(sid=SID) register(ts3conn) with ts3.query.TS3Connection(HOST, PORT) as ts3conn2: ts3conn2.login(client_login_name=USER2, client_login_password=PASS2) ts3conn2.use(sid=SID) bot(ts3conn2)
but it did not work
What you could do is:
import threading
def BotAction1(param1, param2, paramX):
pass # Your bot action here
def BotAction2(param1, paramX):
pass # Your bot action here
t1 = threading.Thread(target=BotAction1, args=(p1, p2, p3))
t1.start()
This starts a new nonblocking thread. Im just not really sure on how the telnet connection handles that, since I am using that construct (untested) by passing a TS3 Connection object as parameter, so I can use it inside a thread. Not sure if thats safe or if that would even work.
Is it possible to have multiple bot functions within one python script if there are multiple server admin logins?