zizuno 0 Junior Poster in Training

Basically I have an irc bot that connects to irc and listens to commands. Imports all of its functions from it. Here is some sample code with comments on what happens

So my question is: how can I pass all of the information required to send irc information without reconnecting to the server when passing the class?

mainscript.py
#python3 irc bot
import modules

#importing socket so I can connect to the irc server
import socket

#Creating an easy to use and memorable value to store the irc module
irc = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )

#connect to the irc module
irc.connect ( ( network, port ) )

#create a thread so the bot can simultaneously check for updates while still receiving commands. Fails when passing the irc value though. The variable passes successfully but cuts off the original value by resending the connect to network command.
t = threading.Timer(10, updatecheck(irc)
t.start()

#monitor incomming data so it can respond
while True:'
	do stuff here


functions.py
import modules

#create the function that will check for the updates and output when the update is found
def updatecheck(variable):

	#create a shorter name for the irc module and pass it
	shortname = variable
	
	#if update is found send a message on irc 
	if update found:
		shortname.send('irc message here')
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.