def pb_submit_paste(pb_devkey, content, pastename, pb_sessionkey, cat):
    """
        Submit the paste to Pastebin
        This will end up in a list format
    """
    x = PastebinAPI()
    url = x.paste(pb_devkey, content, paste_name=pastename, api_user_key=pb_sessionkey, paste_private=cat)
    return url
def pb_generate_user_key(pb_devkey, pb_user, pb_pw):
    """
        Generate Pastebin session key for user
    """
    try:
        x = PastebinAPI()
        pb_sessionkey = x.generate_user_key(pb_devkey, pb_user, pb_pw)
        return pb_sessionkey
    except:
        return "Error getting Pastebin session key... check your deets"
Exemplo n.º 3
0
	def getRules(self,arg):
		if arg == "" or arg == "all":
			p = PastebinAPI()
			rules_string = ""
			for key in self.rules:
				if key == 0:
					rules_string += "Functionality rule: {}\n".format(default_rules[key])
				elif key == 101:
					rules_string += "\nImmutable rules:\n{}: {}\n".format(key,default_rules[key])
				elif key == 201:
					rules_string += "\nMutable rules:\n{}: {}\n".format(key,default_rules[key])
				else:
					rules_string += "{}:{}\n".format(key,default_rules[key])
			self.bot.send(p.paste("81e0f310510d91c8901c970f19dce3b4", rules_string, None, "Gnomic Ruleset", None, "unlisted", "1H"),self.room)
		elif arg in self.rules:
			if len(self.rules[arg]) < 80:
				self.bot.send(self.rules[arg],self.room)
			else: 
				p = PastebinAPI()
				self.bot.send(p.paste("81e0f310510d91c8901c970f19dce3b4","Rule {}:{}".format(arg,self.rules[arg]), None, "Gnomic Ruleset", None, "unlisted", "1H"),self.room)
		else:
			self.bot.send("Invalid argument. Valid arguments are the number of a rule, or 'all'.",self.room)
Exemplo n.º 4
0
	def __init__(self,nickname=NICK,server=HOST,port=PORT,channel=CHAN):
		ircbot.SingleServerIRCBot.__init__(self,[(server, port)],nickname,nickname)
		self.reactor.add_global_handler('all_events',self.command_caller)
		self.cbot = cbot
		self.cbots = {}
		self.channel = channel
		self.build_commands()
		self.pick = pickle
		self.datetime = datetime
		self.tyme = time
		self.fnmatch = fnmatch
		self.version = VERSION
		self.re = re
		self.rng = random
		self.soop = BeautifulSoup
		self.url2 = urllib2
		self.boss = '%s.users.quakenet.org' % BOSS
		self.hashlib = hashlib
		self.mqueue = []
		self.urllib = urllib
		self.requests = requests
		self.stripclub = stripclub
		self.udquery = udquery
		self.math = math
		self.os = os
		self.sys = sys
		self.json = json
		self.traceback = traceback
		self.botconfig = {}
		trpbot_commands.on_initialize(os.path.isfile,pickle,json,time)
		self.reactor.execute_every(1.5,self.process_mqueue)
		self.load_config()
		self.pb = PastebinAPI()
		self.pbkey = None
		self.AUTOJOIN = AUTOJOIN
		self.socket = socket
		if 'pb_devkey' in self.botconfig and 'pb_username' in self.botconfig and 'pb_password' in self.botconfig and self.botconfig['pb_devkey'] and self.botconfig['pb_username'] and self.botconfig['pb_password']:
			self.pbkey = self.pb.generate_user_key(self.botconfig['pb_devkey'],self.botconfig['pb_username'],self.botconfig['pb_password'])
username = '******'
password = '******'

def get_clipboard():
	win32clipboard.OpenClipboard()
	data = win32clipboard.GetClipboardData()
	win32clipboard.CloseClipboard()
	return data

def set_clipboard(text):
	win32clipboard.OpenClipboard()
	win32clipboard.EmptyClipboard()
	win32clipboard.SetClipboardText(text.encode('utf-8'),
		win32clipboard.CF_TEXT)
	win32clipboard.SetClipboardText(unicode(text),
		win32clipboard.CF_UNICODETEXT)
	win32clipboard.CloseClipboard()

clipboard_text = get_clipboard()
print 'Got text from clipboard'
x = PastebinAPI()
api_user_key = x.generate_user_key(api_dev_key, username, password)
print 'Pasting to Pastebin'
x.paste(api_dev_key, clipboard_text, api_user_key, paste_name = None, paste_format = 'python', paste_private = 'unlisted', paste_expire_date = 'N')
print 'Getting URL'
my_pastes = x.pastes_by_user(api_dev_key, api_user_key, results_limit = 1)
tree = e.fromstring(my_pastes)
url = tree[8].text
set_clipboard(url)
print 'Clipboard set to URL'
Exemplo n.º 6
0
class TRPBot(ircbot.SingleServerIRCBot):
	def __init__(self,nickname=NICK,server=HOST,port=PORT,channel=CHAN):
		ircbot.SingleServerIRCBot.__init__(self,[(server, port)],nickname,nickname)
		self.reactor.add_global_handler('all_events',self.command_caller)
		self.cbot = cbot
		self.cbots = {}
		self.channel = channel
		self.build_commands()
		self.pick = pickle
		self.datetime = datetime
		self.tyme = time
		self.fnmatch = fnmatch
		self.version = VERSION
		self.re = re
		self.rng = random
		self.soop = BeautifulSoup
		self.url2 = urllib2
		self.boss = '%s.users.quakenet.org' % BOSS
		self.hashlib = hashlib
		self.mqueue = []
		self.urllib = urllib
		self.requests = requests
		self.stripclub = stripclub
		self.udquery = udquery
		self.math = math
		self.os = os
		self.sys = sys
		self.json = json
		self.traceback = traceback
		self.botconfig = {}
		trpbot_commands.on_initialize(os.path.isfile,pickle,json,time)
		self.reactor.execute_every(1.5,self.process_mqueue)
		self.load_config()
		self.pb = PastebinAPI()
		self.pbkey = None
		self.AUTOJOIN = AUTOJOIN
		self.socket = socket
		if 'pb_devkey' in self.botconfig and 'pb_username' in self.botconfig and 'pb_password' in self.botconfig and self.botconfig['pb_devkey'] and self.botconfig['pb_username'] and self.botconfig['pb_password']:
			self.pbkey = self.pb.generate_user_key(self.botconfig['pb_devkey'],self.botconfig['pb_username'],self.botconfig['pb_password'])
		#def execute_every(self, period, function, arguments=())
		
	def load_config(self):
		if os.path.isfile(CONFIG):
			with open(CONFIG) as f:
				self.botconfig = json.load(f)
		else:
			self.botconfig = {
				'pb_devkey':'',
				'pb_username':'',
				'pb_password':'',
				'irc_auth':'',
			}
			self.save_config()
		
	def save_config(self):
		with open(CONFIG,'wb') as f:
			self.json.dump(self.botconfig,f,sort_keys=True,indent=4)

	def process_mqueue(self):
		if not len(self.mqueue):
			return
		c,target,msg = self.mqueue.pop(0)
		try:
			msg = ''.join(msg.splitlines())
			msg1 = msg[:386]
			msg2 = msg[386:]
			c.privmsg(target,msg1)
			if len(msg2):
				self.mqueue.append((c,target,msg2))
		except:
			#print('process_mqueue exception: %s' % (self.sys.exc_info(),))
			traceback.print_exc(file=sys.stdout)
			
	def add_mqueue(self,c,target,msg):
		self.mqueue.append((c,target,msg))
		
	def build_commands(self):
		self.commands = {}
		self.chatcmds = {}
		found = getmembers(trpbot_commands,isfunction)		
		for fname,f in found:
			if len(fname) > 3 and fname[0:3] == 'on_':
				self.commands[fname] = f
			elif len(fname) > 4 and fname[0:4] == 'cmd_':
				self.chatcmds[fname] = f

	def command_caller(self,c,e):
		event_name = 'on_%s' % (e.type,)
		if event_name in self.commands:
			self.commands[event_name](self,c,e)
		#print('%s: %s' % (e.type,e.arguments[0] if len(e.arguments) else ''))
			
	def on_pubmsg(self,c,e):
		if e.target in self.channels:
			ch = self.channels[e.target]
			if self.boss in e.source and e.arguments[0] == '.reload':
				reloader.reload(trpbot_commands)
				self.build_commands()
				self.add_mqueue(c,e.target,'reload complete')
		
	def on_nicknameinuse(self,c,e):
		c.nick('%s_' % (c.get_nickname(),))
		
	def on_welcome(self,c,e):
		if AUTH or ('irc_auth' in self.botconfig and self.botconfig['irc_auth']):
			c.send_raw(AUTH if AUTH else self.botconfig['irc_auth'])
			c.mode(c.get_nickname(),'+x')
		c.join(self.channel)
		for each_chan in AUTOJOIN:
			c.join(each_chan)
		
	def on_ctcp(self,c,e):
		nick = e.source.nick
		if e.arguments[0] == 'VERSION':
			c.ctcp_reply(nick,'VERSION %s' % (VERSION,))
		elif e.arguments[0] == 'PING':
			if len(e.arguments) > 1:
				c.ctcp_reply(nick,'PING %s' % (e.arguments[1],))
		elif e.arguments[0] == 'DCC' and e.arguments[1].split(' ',1)[0] == 'CHAT':
			self.on_dccchat(c,e)

	def on_dccchat(self,c,e):
		pass