Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple bot functions in one script #66

Open
hcphoon01 opened this issue Jun 12, 2018 · 5 comments
Open

Multiple bot functions in one script #66

hcphoon01 opened this issue Jun 12, 2018 · 5 comments

Comments

@hcphoon01
Copy link

Is it possible to have multiple bot functions within one python script if there are multiple server admin logins?

@AdorablePotato
Copy link
Owner

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.

@hcphoon01
Copy link
Author

What would be the correct code for having two functions running in one bot?

@leon1995
Copy link

@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" )

@hcphoon01
Copy link
Author

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

@whookie
Copy link

whookie commented Jul 4, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants