Ejemplo n.º 1
0
def fileLatestCommit( self, rev ):
	rowId = ""
	try:
		db = sqlite3.connect("sysmodules/data/commits.db")
		cur = db.cursor()
		cur.execute("""SELECT id FROM commits WHERE id = 1""")

		try:
			rowId = cur.fetchone()[0]
		except TypeError:
			rowId = ""

		if rowId:
			cur.execute("""UPDATE commits SET rev = (?) WHERE id = rowId""",(rev,))
			db.commit()
			return True
		else:
			cur.execute("""INSERT INTO commits(rev) VALUES(?)""",(rev,))
			db.commit()
			return True

		db.close()

	except Exception as e:
		self.errormsg = "[ERROR]-[syscmd] fileLatestCommit() stating: {0}".format(e)
		sysErrorLog (self)
		if self.config["debug"]:
			print("{0}{1}{2}".format(self.color("red"), self.errormsg, self.color("end")))
		raise e
Ejemplo n.º 2
0
def readRevisionNumber( self ):
	result = ""
	try:
		db = sqlite3.connect("sysmodules/data/commits.db")
		cur = db.cursor()

		try:
			result = cur.execute("""SELECT rev FROM commits WHERE id = 1""").fetchone()[0]
		except TypeError:
			result = "Unknown build"

		return(result)
		db.close()

	except Exception as e:
		self.errormsg = "[ERROR]-[syscmd] readRevisionNumber() stating: {0}".format(e)
		sysErrorLog (self)
		if self.config["debug"]:
			print("{0}{1}{2}".format(self.color("red"), self.errormsg, self.color("end")))
		raise e
Ejemplo n.º 3
0
def addautomode ( self, modes, chan ):
	
	identhost = self.hostident		 	#this is created by getRemoteHost() down below which is later on called
					   					#in core as a bot wide variable when server sends whoise code 311

	if modes == "ao" or modes == "av":
		try:
			db = sqlite3.connect("modules/data/automodes.db")
			cursor = db.cursor()
			cursor.execute("""SELECT id FROM automodes WHERE identhost = ? AND channel = ?""", (identhost, chan))
			try:
				rowId = cursor.fetchone()[0]
			except TypeError:
				rowId = None
			if not rowId:
				cursor.execute("""INSERT INTO automodes(identhost,channel,mode) VALUES(?,?,?)""", (identhost,chan,modes))
				db.commit()
				self.send_data("PRIVMSG {2} :Automode ({0}) added for {1} on channel {2}".format(modes,identhost,chan))
				return True
			else:
				cursor.execute("""UPDATE automodes SET mode = ? WHERE id = ?""", (modes, rowId))
				db.commit()
				self.send_data("PRIVMSG {2} :Automode changed for ({1}) on channel {2}. The new mode is ({0})".format(modes,identhost,chan))
				return True
		except Exception as e:
			self.errormsg = "[ERROR]-[syscmd] addautomode() stating: {0}".format(e)
			sysErrorLog (self)
			if self.config["debug"]:
				print("{0}{1}{2}".format(self.color("red"), self.errormsg, self.color("end")))
			raise e
		finally:
			db.close()

	elif modes == "reset":
		try: 
			if identhost:
				db = sqlite3.connect("modules/data/automodes.db")
				cur = db.cursor()
				cur.execute("""SELECT id FROM automodes WHERE identhost = ? AND channel = ?""", (identhost,chan))

				try:
					rowId = cur.fetchone()[0]
				except TypeError:
					rowId = False

				if rowId:
					cur.execute("""DELETE FROM automodes WHERE id = ?""", (rowId,))
					db.commit()
					self.send_data("PRIVMSG {0} :Automode removed from user ({1}) on channel {0}".format(chan,identhost))
				else:
					self.send_data("PRIVMSG {0} :There is no such user ({1}) on channel {0} in my database".format(chan, identhost))

				db.close()
			
			else:
				self.send_data("PRIVMSG {0} :There is no such user on channel {0} in my database".format(chan))

		except Exception as e:
			self.errormsg = "[ERROR]-[syscmd] addautomode()(1) stating: {0}".format(e)
			sysErrorLog (self)
			if self.config["debug"]:
				print("{0}{1}{2}".format(self.color("red"), self.errormsg, self.color("end")))
			raise e

			

	else:
		self.send_data("PRIVMSG {0} :Currently the only user flags are 'ao' & 'av'".format(chan))