Esempio n. 1
0
	def command_001_setState(self, user, message, args):
		'''(available|online|busy|dnd|away|idle|out|xa)( +(.*))?$(?i)'''
		show = args[0]
		status = args[1]
		jid = user.getStripped()

		# Verify if the user is the Administrator of this bot
		if jid in self.BOT_ADMIN:
			#put a logger in place?
			print jid, " changed status to ---> ", status
			return strings().changed_status_to%status, status, show
		return strings().not_permitted,None,None 
Esempio n. 2
0
	def presenceHandler(self, conn, presence):
		#print_info(presence)
		if(configs().prod==0):        # so that it can load if any changes are there
			reload(all_handlers)

		if presence:
			if presence.getType()=='subscribe':
				#auto add friends.. Keep some checking here, and LOG!
				jid = presence.getFrom().getStripped()
				self.authorize(jid)
				self.replyMessage(jid, strings().first_welcome_msg%jid)
			else:
				all_handlers.presence().handle(conn, presence)
Esempio n. 3
0
	def command_003_shell(self, user, message, args):
		'''(shell|bash)( +(.*))?$(?i)'''
		jid = user.getStripped()
		if jid in self.BOT_ADMIN:
			cmd = args[1]
			p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
			output = ""
			for line in p.stdout.readlines():
				output += line
				# print line,
			# retval = p.wait()
			
			return output +" at: "+time.strftime("%Y-%m-%d %a %H:%M:%S", time.localtime()), None, None
		return strings().not_permitted,None,None 
Esempio n. 4
0
	def command_004_default(self, user, message, args):
		'''(jarvis )?(please download|download)( +(.*))?$(?i)'''
		show = args[0]
		download_string = args[2]
		jid = user.getStripped()
		if jid in self.BOT_ADMIN:
			#put a logger in place?
			print jid, " ----------> is downloading something ", download_string
			result=requests.get('http://apify.ifc0nfig.com/tpb/search?id='+download_string)
			json_data=json.loads(result.content)
			if(len(json_data) is 0):
				return 'No results found :( check for typos please?', None, None
			item=json_data[0]
			return_string = "Started download of '"+item['name']+"' with size "+item['size']+" uploaded "+item['uploaded']+"."

			cmd="transmission-cli '"+item['magnet']+"'"
			p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
			
			return return_string,None, None

		return strings().not_permitted, None, None
Esempio n. 5
0
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# PyGtalkRobot Homepage: http://code.google.com/p/pygtalkrobot/
# RaspiBot Homepage: http://code.google.com/p/pygtalkrobot/
#
import time

# import RPi.GPIO as GPIO
from PyGtalkRobot import GtalkRobot
from configs.config import configs
from configs.strings import strings


# GPIO.setmode(GPIO.BOARD) # or GPIO.setmode(GPIO.BCM)
############################################################################################################################


if __name__ == "__main__":
    bot = GtalkRobot(configs().settings["server"], configs().settings["port"], debug=configs().debug)
    bot.setState("available", strings().status)
    bot.start(configs().settings["BOT_GTALK_USER"], configs().settings["BOT_GTALK_PASS"])
Esempio n. 6
0
	def start(self, gmail_account, password):
		jid=xmpp.JID(gmail_account)
		user, server, password = jid.getNode(), jid.getDomain(), password
		
		self.conn=xmpp.Client(server, debug=self.debug)
		#talk.google.com
		print strings().connecting_string%(self.server_host,self.server_port)
		if(configs().prod==1):
			conres=self.conn.connect( server=(self.server_host, self.server_port))
		else:
			conres=self.conn.connect( server=(self.server_host, self.server_port),secure=0 )

		if not conres:
			print strings().cannot_connect%server
			sys.exit(1)
		if conres<>'tls':
			print strings().not_secure_connection
		print user,password
		authres=self.conn.auth(user, password)
		if not authres:
			print strings().wrong_password
			sys.exit(1)
		if authres<>"sasl":
			print strings().no_sasl%server
		
		self.conn.RegisterHandler("message", self.controller)
		self.conn.RegisterHandler('presence',self.presenceHandler)
		self.conn.sendInitPresence()
		
		self.setState(self.show, self.status)
		
		print strings().bot_start
		self.GoOn()