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 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)
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'