def get_cargo(request, cid): """ Gets a carrier's cargo. :param request: Request object :param cid: Carrier ID :return: A list of dicts containing cargo info. """ carrier = request.dbsession.query(Carrier).filter(Carrier.id == cid).one_or_none() if carrier: clean_cargo = {} stolen_cargo = {} result = request.dbsession.query(Cargo).filter(Cargo.carrier_id == cid) for cg in result: if cg.stolen: if cg.commodity in stolen_cargo.keys(): stolen_cargo[cg.commodity]['quantity'] = stolen_cargo[cg.commodity]['quantity'] + cg.quantity else: stolen_cargo[cg.commodity] = {'commodity': translation.localize_commodity(cg.commodity), 'quantity': cg.quantity, 'value': format_number(cg.value), 'stolen': cg.stolen, 'locname': cg.locName } else: if cg.commodity in clean_cargo.keys(): clean_cargo[cg.commodity]['quantity'] = clean_cargo[cg.commodity]['quantity'] + cg.quantity else: clean_cargo[cg.commodity] = {'commodity': translation.localize_commodity(cg.commodity), 'quantity': cg.quantity, 'value': format_number(cg.value), 'stolen': cg.stolen, 'locname': cg.locName } data = {'clean_cargo': clean_cargo, 'stolen_cargo': stolen_cargo} return data
def get_market(request, cid): """ Populates the market list for a carrier :param request: The request object :param cid: Carrier ID to populate :return: A dict of market data """ mycarrier = request.dbsession.query(Carrier).filter( Carrier.id == cid).one_or_none() market = request.dbsession.query(Market).filter(Market.carrier_id == cid) res = [] for mk in market: if mk.categoryname != 'NonMarketable': res.append({ 'amount': (format_number(mk.demand) if mk.demand else format_number(mk.stock)), 'loc_commodity': translation.localize_commodity(mk.name), 'commodity': mk.name, 'buy_price': format_number(mk.buyPrice), 'sell_price': format_number(mk.sellPrice), 'id': mk.id }) return res
def market_update(request, cid, items, webhook_url, message=None): mycarrier = request.dbsession.query(Carrier).filter( Carrier.id == cid).one_or_none() extra = request.dbsession.query(CarrierExtra).filter( CarrierExtra.cid == cid).one_or_none() embed = DiscordEmbed( title='Priority Market Update', description= f'{mycarrier.callsign} {util.from_hex(mycarrier.name)} has issued a market ' f'notification.', color=242424, url=f'https://fleetcarrier.space/carrier/{mycarrier.callsign}') embed.set_author( name='Fleetcarrier.space', url=f'https://fleetcarrier.space/carrier/{mycarrier.callsign}') if extra: embed.set_image(url=request.storage.url(extra.carrier_image)) else: embed.set_image( url='https://fleetcarrier.space/static/img/carrier_default.png') embed.set_footer( text='Fleetcarrier.space - Fleet Carrier Management System') market = request.dbsession.query(Market).filter( Market.carrier_id == cid).all() for item in market: if item.categoryname == 'NonMarketable': continue if items and str(item.id) not in items: continue if item.stock > 0: embed.add_embed_field(name='Selling', value=item.name) embed.add_embed_field(name='For', value=format_number(item.buyPrice)) embed.add_embed_field(name='Quantity', value=format_number(item.stock)) if item.demand > 0: embed.add_embed_field(name='Buying', value=item.name) embed.add_embed_field(name='For', value=format_number(item.sellPrice)) embed.add_embed_field(name='Quantity', value=format_number(item.demand)) embed.add_embed_field(name='Current Location', value=mycarrier.currentStarSystem) embed.add_embed_field( name='Docking Access', value='Squadron and Friends' if mycarrier.dockingAccess == 'squadronfriends' else mycarrier.dockingAccess.title()) embed.set_timestamp(datetime.utcnow().timestamp()) if message: embed.add_embed_field(name='Message', value=message, inline=False) return send_webhook(webhook_url, 'Priority Market Update', hooktype='discord', myembed=embed)
def transform(s3_bucket, s3_file_path, s3_region): try: file_stream = s3_file_stream(s3_bucket, s3_file_path, s3_region) input_stream_reader = InputStreamReader(file_stream) input_stream_reader.validate_schema() LOGGER.info("schema validated") output_stream_writer = OutputStreamWriter(input_stream_reader.schema) product_data_cleaner = ProductDataCleaner() rows_processed = 0 bytes_processed = 0 for i, batch in input_stream_reader.batches(): valid_batch, invalid_batch = product_data_cleaner.filter(batch) output_stream_writer.write(valid_batch, invalid_batch) rows_processed += batch.num_rows bytes_processed += batch.nbytes LOGGER.info( "batch {} processed, total processed rows: {}, total processed {}" .format( i, humanfriendly.format_number(rows_processed), humanfriendly.format_size(bytes_processed), )) finally: if "file_stream" in locals(): file_stream.close() if "output_stream_writer" in locals(): output_stream_writer.close() LOGGER.info("cleanup completed")
def test_format_number(self): self.assertEqual('1', humanfriendly.format_number(1)) self.assertEqual('1.5', humanfriendly.format_number(1.5)) self.assertEqual('1.56', humanfriendly.format_number(1.56789)) self.assertEqual('1.567', humanfriendly.format_number(1.56789, 3)) self.assertEqual('1,000', humanfriendly.format_number(1000)) self.assertEqual('1,000', humanfriendly.format_number(1000.12, 0)) self.assertEqual('1,000,000', humanfriendly.format_number(1000000)) self.assertEqual('1,000,000.42', humanfriendly.format_number(1000000.42))
def test_format_number(self): """Test :func:`humanfriendly.format_number()`.""" self.assertEqual('1', humanfriendly.format_number(1)) self.assertEqual('1.5', humanfriendly.format_number(1.5)) self.assertEqual('1.56', humanfriendly.format_number(1.56789)) self.assertEqual('1.567', humanfriendly.format_number(1.56789, 3)) self.assertEqual('1,000', humanfriendly.format_number(1000)) self.assertEqual('1,000', humanfriendly.format_number(1000.12, 0)) self.assertEqual('1,000,000', humanfriendly.format_number(1000000)) self.assertEqual('1,000,000.42', humanfriendly.format_number(1000000.42))
def _add_global_IDP_mean_and_median_lines(self, ax): """ Given a matplolib axis, add the global mean and median taken from self.intervals['IDP']. """ sequencing_mean = self.intervals['IDP'].mean() seq_mean_pretty = format_number(sequencing_mean, num_decimals=0) sequencing_median = self.intervals['IDP'].median() seq_median_pretty = format_number(sequencing_median, num_decimals=0) line_opts = dict(linewidth=1, linestyle='dotted') ax.axhline(y=sequencing_mean, color='DodgerBlue', **line_opts) ax.axhline(y=sequencing_median, color='Navy', **line_opts) text_opts = dict(x=max(ax.get_xticks()) + 0.6, verticalalignment='center', horizontalalignment='left') ax.text(color='DodgerBlue', y=sequencing_mean, s=f'$mean={seq_mean_pretty}$', **text_opts) ax.text(color='Navy', y=sequencing_median, s=f'$median={seq_median_pretty}$', ** text_opts)
def generate_status(self): if self.plugin.get_printer().is_operational(): if self.plugin.get_printer().is_printing(): job_name = self.plugin.get_printer().get_current_data( )['job']['file']['name'] job_percent = self.plugin.get_printer().get_current_data( )['progress']['completion'] return "Printing {} - {}%".format( job_name, humanfriendly.format_number(job_percent, num_decimals=2)) else: return "Idle." else: return "Not operational."
def get_performance_report(repo_name, old_info, new_info): """compares retention policy performance, showing old amount of space and new. Args: repo_name (str): Name of repository old_info (dict): Metadata of repository before run new_info (dict): Metadata of repository after run """ old_space = parse_size(old_info['usedSpace']) new_space = parse_size(new_info['usedSpace']) old_files = old_info["filesCount"] new_files = new_info["filesCount"] LOG.info("%s size: %s; reduction: storage %s (%.1f%%), files %s (%.1f%%)", repo_name, format_size(new_space), format_size(new_space - old_space), get_percentage(old_space, new_space), format_number(new_files - old_files), get_percentage(old_files, new_files))
def plot_coverage_distribution(self, dest_dir=None): """ Plot an histogram + KDE for the distribution of coverage. """ sns.set_style('whitegrid') distribution = self.intervals['IDP'] sample_ids = self.intervals['sample_id'].unique() q = {str(n): int(distribution.quantile(n/100)) for n in [10, 25, 50, 75, 90, 99.5]} # format_number doesn't take a delimiter or locale option and we # need the thousand separators to be in Spanish, i.e. ".", not "," q_formatted = {n: format_number(v).replace(',', '.') for n, v in q.items()} ax, fig = plt.subplots(figsize=(10, 3)) ax = sns.distplot(distribution) ax.set_yticks([]) ax.set_ylabel('# Regiones') ax.set_xlabel('Cobertura') title = ( f'Cobertura observada en las regiones del panel ' + f'({", ".join(sample_ids)})\n' + f'$Q_{{10}} = {q_formatted["10"]}$ | ' + f'$Q_{{25}} = {q_formatted["25"]}$ | ' + f'$\\bf{{ Q_{{50}} = {q_formatted["50"]} }}$ | ' + f'$Q_{{75}} = {q_formatted["75"]}$ | ' + f'$Q_{{90}} = {q_formatted["90"]}$' ) ax.set_title(title, y=1.05) ax.axvline(x=q['50'], linestyle='dotted') ax.set_xticks(np.arange(0, self.intervals['IDP'].max(), step=500)) ax.set_xlim(0, q['99.5']) if dest_dir: fn = f'{"_".join(sample_ids)}.coverage_distribution.png' filepath = os.path.join(dest_dir,fn) plt.savefig(filepath, bbox_inches='tight', dpi=150) plt.close() return filepath return ax
def log_step_message(self, header, losses, speeds, comparative_loss, batch_size, is_training, tag=""): def get_loss_color(old_loss: float, new_loss: float): if old_loss < new_loss: return "red" else: return "green" def get_log_color(is_training: bool): if is_training: return {"color": "blue", "attrs": ["bold"]} else: return {"color": "yellow", "attrs": ["underline"]} self.last_loss.setdefault(tag, comparative_loss) loss_color = get_loss_color(self.last_loss.get(tag, 0), comparative_loss) self.last_loss[tag] = comparative_loss model_size = hf.format_size(self.model.total_params * 4) total_params = hf.format_number(self.model.total_params) loss_desc, loss_val = self.build_info_step_message(losses, "{:7.4f}") header_desc, header_val = self.build_duration_step_message(header) speed_desc, speed_val = self.build_info_step_message(speeds, "{:4.0f}") with utils.format_text(loss_color) as fmt: loss_val_colored = fmt(loss_val) msg = ( f"[{tag}] {header_desc}: {header_val}\t" f"{speed_desc}: {speed_val} ({self.args.width},{self.args.height};{batch_size})\t" f"{loss_desc}: {loss_val_colored} " f"| {model_size} {total_params}") with utils.format_text(**get_log_color(is_training)) as fmt: self.log.info(fmt(msg))
def get_finances(request, cid): """ Gets the financial information for a carrier. :param request: The request object :param cid: Carrier ID :return: A dict of financial information """ carrier = request.dbsession.query(Carrier).filter(Carrier.id == cid).one_or_none() if carrier: cdata = None if not carrier.cachedJson: cdata = update_carrier(request, cid, request.user) else: cdata = json.loads(carrier.cachedJson) data = {} for key, val in cdata['finance'].items(): data[key] = format_number(val) return data else: log.error("Attempt to get finances for non-existant carrier!") return None
def format_number(val): return humanfriendly.format_number(val)
def lineBot(op): try: if op.type == 0: print("DONE") return if op.type == 5: print("INFO SELBOT : ADA YANG ADD") if settings["autoAdd"] == True: boteater.sendMessage( op.param1, "=== SELFBOT SLACKBOT V1.0 === \nTERIMAKASIH {} TELAH ADD SAYA" .format(str(boteater.getContact(op.param1).displayName))) if op.type == 13: print("INFO SELBOT : ADA YANG INVITE GRUP") group = boteater.getGroup(op.param1) if settings["autoJoin"] == True: boteater.acceptGroupInvitation(op.param1) if op.type == 24: print("INFO SELBOT : LEAVE ROOM") if settings["autoLeave"] == True: boteater.leaveRoom(op.param1) if op.type == 26: print("INFO SELBOT : MENGIRIM PESAN") msg = op.message text = msg.text msg_id = msg.id receiver = msg.to sender = msg._from if msg.toType == 0: if sender != boteater.profile.mid: to = sender else: to = receiver else: to = receiver if msg.contentType == 0: if text is None: return if text.lower() == 'help': boteater.sendMessage( to, "╭══════╬╬═══════╮\n╠⎆ ●SLΔCҜβΩT●\n╰══════╬╬═══════╯\n╭══════╬╬═══════╮\n╠⎆ !bot menu \n╠⎆ !setting \n╠⎆ !self \n╠⎆ !group \n╠⎆ !media \n╠⎆ !tokenlist \n╠⎆ !nanimenew \n╠⎆ !nanimelist\n╰══════╬╬═══════╯" ) if text.lower() == '!tokenlist': boteater.sendMessage( to, "╭══════╬╬═══════╮\n╠⎆ ●SLΔCҜβΩT●\n╰══════╬╬═══════╯\n╭══════╬╬═══════╮\n╠⎆ !token desktopmac \n╠⎆ !token ios \n╠⎆ !token chrome \n╠⎆ !token win10 \n╠⎆ !token desktopwin \n╠⎆ !done\n╰══════╬╬═══════╯" ) elif text.lower() == '!botmenu': boteater.sendMessage( to, "╭══════╬╬═══════╮\n╠⎆ ●SLΔCҜβΩT●\n╰══════╬╬═══════╯\n╠⎆ !restart \n╠⎆ !speed \n╠⎆ !status \n╠⎆ !about \n╠⎆ !runtime \n╠⎆ !errorlog\n╰══════╬╬═══════╯" ) elif text.lower() == '!setting': boteater.sendMessage( to, "╭══════╬╬═══════╮\n╠⎆ ●SLΔCҜβΩT●\n╰══════╬╬═══════╯\n╠⎆ !autoadd(on/off) \n╠⎆ autoread(on/off) \n╠⎆ autojoin(on/off) \n╠⎆ autoleave(on/off) \n╠⎆ autochecksticker(on/off) \n╠⎆ detectmention(on/off)\n╰══════╬╬═══════╯" ) elif text.lower() == '!self': boteater.sendMessage( to, "╭══════╬╬═══════╮\n╠⎆ ●SLΔCҜβΩT●\n╰══════╬╬═══════╯\n╠⎆ !me \n╠⎆ !mymid \n╠⎆ !mypicture \n╠⎆ !myvideo \n╠⎆ !mycover \n╠⎆ !stealcontact(mention) \n╠⎆ !stealmid(mention) \n╠⎆ !stealbio(mention) \n╠⎆ !stealpicture(mention) \n╠⎆ !stealvideoprofile(mention) \n╠⎆ !stealcover(mention) \n╠⎆ !cloneprofile(mention) \n╠⎆ !restoreprofile \n╠⎆ mention\n╰══════╬╬═══════╯" ) elif text.lower() == '!group': boteater.sendMessage( to, "╭══════╬╬═══════╮\n╠⎆ ●SLΔCҜβΩT●\n╰══════╬╬═══════╯\n╠⎆ !gcreator \n╠⎆ !gpicture \n╠⎆ !glink \n╠⎆ !qr(on/off) \n╠⎆ !glist \n╠⎆ !gmember \n╠⎆ !ginfo \n╠⎆ !crash\n╰══════╬╬═══════╯" ) elif text.lower() == '!media': boteater.sendMessage( to, "╭══════╬╬═══════╮\n╠⎆ ●SLΔCҜβΩT●\n╰══════╬╬═══════╯\n╠⎆ !instagraminfo(username) \n╠⎆ !instagrampost(username) \n╠⎆ !youtubes(keyword) \n╠⎆ !image(keyword) \n╠⎆ !ssweb(link)\n╰══════╬╬═══════╯" ) ### BOT MENU COMMAND ### elif text.lower() == '!speed': start = time.time() boteater.sendMessage(to, "█▒▒▒▒▒▒▒▒▒...") elapsed_time = time.time() - start boteater.sendMessage(to, format(str(elapsed_time))) elif text.lower() == '!restart': boteater.sendMessage(to, "SEDANG RESTART") time.sleep(5) boteater.sendMessage(to, "SUKSES!!!") restartBot() elif text.lower() == '!errorlog': with open('error.txt', 'r') as er: error = er.read() boteater.sendMessage(to, str(error)) elif text.lower() == '!runtime': timeNow = time.time() runtime = timeNow - botStart runtime = format_timespan(runtime) boteater.sendMessage( to, "BOT ALREADY RUN IN \n {}".format(str(runtime))) elif text.lower() == '!about': try: arr = [] saya = "u4db055855928255a6f53054d0915f196" creator = boteater.getContact(saya) ret_ = "1⊙ INFO BOT ⊙" ret_ += "\n●TΣΔM SLΔCҜβΩT●" ret_ += "\nBOT INI MILIK ●SLΔCҜβΩT● TIDAK UNTUK DI PERJUAL BELIKAN!!! (GRATIS)" ret_ += "\nYANG BUAT : {}".format(creator.displayName) #ret_ += "\n===== IKLAN ===== \nSABUN GIF" boteater.sendMessage(to, str(ret_)) except Exception as e: boteater.sendMessage(msg.to, str(e)) elif text.lower() == '!status': try: ret_ = "⊙ STATUS BOT ⊙" if settings["autoAdd"] == True: ret_ += "\nAUTO ADD ACTIVED" else: ret_ += "\nAUTO ADD NOT ACTIVED" if settings["autoJoin"] == True: ret_ += "\nAUTO JOIN ACTIVED" else: ret_ += "\nAUTO JOIN NOT ACTIVED" if settings["autoLeave"] == True: ret_ += "\nAUTO LEAVE ACTIVED" else: ret_ += "\nAUTO LEAVE NOT ACTIVED" if settings["autoRead"] == True: ret_ += "\nAUTO READ ACTIVED" else: ret_ += "\nAUTO READ NOT ACTIVED" if settings["autochecksticker"] == True: ret_ += "\nAUTO CHECK STICKER ACTIVED" else: ret_ += "\nAUTO CHECK STICKER NOT ACTIVED" if settings["detectMention"] == True: ret_ += "\nDETECT MENTION ACTIVED" else: ret_ += "\nDETECT MENTION NOT ACTIVED" ret_ += " " boteater.sendMessage(to, str(ret_)) except Exception as e: boteater.sendMessage(msg.to, str(e)) elif text.lower() == '!autoadd on': settings["autoAdd"] = True boteater.sendMessage(to, "AUTO ADD IS ACTIVED") elif text.lower() == '!autoadd off': settings["autoAdd"] = False boteater.sendMessage(to, "AUTO ADD IS NOT ACTIVED") elif text.lower() == '!autojoin on': settings["autoJoin"] = True boteater.sendMessage(to, "AUTO JOIN IS IS ACTIVED") elif text.lower() == '!autojoin off': settings["autoJoin"] = False boteater.sendMessage(to, "AUTO JOIN IS IS NOT ACTIVED") elif text.lower() == '!autoleave on': settings["autoLeave"] = True boteater.sendMessage(to, "AUTO LEAVE IS ACTIVED") elif text.lower() == '!autojoin off': settings["autoLeave"] = False boteater.sendMessage(to, "AUTO LEAVE IS NOT ACTIVED") elif text.lower() == '!autoread on': settings["autoRead"] = True boteater.sendMessage(to, "AUTO READ IS ACTIVED") elif text.lower() == '!autoread off': settings["autoRead"] = False boteater.sendMessage(to, "AUTO READ IS NOT ACTIVED") elif text.lower() == '!autochecksticker on': settings["autochecksticker"] = True boteater.sendMessage(to, "AUTO zautochecksticker IS ACTIVED") elif text.lower() == '!autochecksticker off': settings["autochecksticker"] = False boteater.sendMessage( to, "AUTO zautochecksticker IS NOT ACTIVED") elif text.lower() == '!detectmention on': settings["datectMention"] = True boteater.sendMessage(to, "DETECT MENTION IS ACTIVED") elif text.lower() == '!detectmention off': settings["datectMention"] = False boteater.sendMessage(to, "DETECT MENTION IS NOT ACTIVED") elif text.lower() == '!clonecontact': settings["copy"] = True boteater.sendMessage(to, "SEND CONTACT TO CLONE!!!") ### SELFBOT COMMAND ### elif text.lower() == '!me': sendMessageWithMention(to, boteaterMID) boteater.sendContact(to, boteaterMID) elif text.lower() == '!mymid': boteater.sendMessage(msg.to, "MID KAMU : " + msg.from_) elif text.lower() == '!mypicture': me = boteater.getContact(boteaterMID) boteater.sendImageWithURL( msg.to, "http://dl.profile.line-cdn.net/" + me.pictureStatus) elif text.lower() == '!myvideo': me = boteater.getContact(boteaterMID) boteater.sendVideoWithURL( msg.to, "http://dl.profile.line-cdn.net/" + me.pictureStatus + "/vp") elif text.lower() == '!mycover': me = boteater.getContact(boteaterMID) cover = boteater.getProfileCoverURL(boteaterMID) boteater.sendImageWithURL(msg.to, cover) elif msg.text.lower().startswith("!stealcontact "): if 'MENTION' in msg.contentMetadata.keys() != None: names = re.findall(r'@(\w+)', text) mention = ast.literal_eval( msg.contentMetadata['MENTION']) mentionees = mention['MENTIONEES'] lists = [] for mention in mentionees: if mention["M"] not in lists: lists.append(mention["M"]) for ls in lists: contact = boteater.getContact(ls) mi_d = contact.mid boteater.sendContact(msg.to, mi_d) elif msg.text.lower().startswith("!stealmid "): if 'MENTION' in msg.contentMetadata.keys() != None: names = re.findall(r'@(\w+)', text) mention = ast.literal_eval( msg.contentMetadata['MENTION']) mentionees = mention['MENTIONEES'] lists = [] for mention in mentionees: if mention["M"] not in lists: lists.append(mention["M"]) ret_ = "MID : " for ls in lists: ret_ += "\n{}" + ls boteater.sendMessage(msg.to, str(ret_)) elif msg.text.lower().startswith("!stealname "): if 'MENTION' in msg.contentMetadata.keys() != None: names = re.findall(r'@(\w+)', text) mention = ast.literal_eval( msg.contentMetadata['MENTION']) mentionees = mention['MENTIONEES'] lists = [] for mention in mentionees: if mention["M"] not in lists: lists.append(mention["M"]) for ls in lists: contact = boteater.getContact(ls) boteater.sendMessage( msg.to, "NAME : \n" + contact.displayName) elif msg.text.lower().startswith("!stealbio "): if 'MENTION' in msg.contentMetadata.keys() != None: names = re.findall(r'@(\w+)', text) mention = ast.literal_eval( msg.contentMetadata['MENTION']) mentionees = mention['MENTIONEES'] lists = [] for mention in mentionees: if mention["M"] not in lists: lists.append(mention["M"]) for ls in lists: contact = boteater.getContact(ls) boteater.sendMessage( msg.to, "INFO BIO : \n{}" + contact.statusMessage) elif msg.text.lower().startswith("!stealpicture "): if 'MENTION' in msg.contentMetadata.keys() != None: names = re.findall(r'@(\w+)', text) mention = ast.literal_eval( msg.contentMetadata['MENTION']) mentionees = mention['MENTIONEES'] lists = [] for mention in mentionees: if mention["M"] not in lists: lists.append(mention["M"]) for ls in lists: path = "http://dl.profile.line.naver.jp/" + boteater.getContact( ls).pictureStatus boteater.sendImageWithURL(msg.to, str(path)) elif msg.text.lower().startswith("!stealvideoprofile "): if 'MENTION' in msg.contentMetadata.keys() != None: names = re.findall(r'@(\w+)', text) mention = ast.literal_eval( msg.contentMetadata['MENTION']) mentionees = mention['MENTIONEES'] lists = [] for mention in mentionees: if mention["M"] not in lists: lists.append(mention["M"]) for ls in lists: path = "http://dl.profile.line.naver.jp/" + boteater.getContact( ls).pictureStatus + "/vp" boteater.sendImageWithURL(msg.to, str(path)) elif msg.text.lower().startswith("!stealcover "): if line != None: if 'MENTION' in msg.contentMetadata.keys() != None: names = re.findall(r'@(\w+)', text) mention = ast.literal_eval( msg.contentMetadata['MENTION']) mentionees = mention['MENTIONEES'] lists = [] for mention in mentionees: if mention["M"] not in lists: lists.append(mention["M"]) for ls in lists: path = boteater.getProfileCoverURL(ls) boteater.sendImageWithURL(msg.to, str(path)) elif msg.text.lower().startswith("!cloneprofile "): if 'MENTION' in msg.contentMetadata.keys() != None: names = re.findall(r'@(\w+)', text) mention = ast.literal_eval( msg.contentMetadata['MENTION']) mentionees = mention['MENTIONEES'] for mention in mentionees: contact = mention["M"] break try: boteater.cloneContactProfile(contact) boteater.sendMessage( msg.to, "Berhasil clone member tunggu beberapa saat sampai profile berubah" ) except: boteater.sendMessage(msg.to, "Gagal clone member") elif text.lower() == '!restoreprofile': try: boteaterProfile.displayName = str( myProfile["displayName"]) boteaterProfile.statusMessage = str( myProfile["statusMessage"]) boteaterProfile.pictureStatus = str( myProfile["pictureStatus"]) boteater.updateProfileAttribute( 8, boteaterProfile.pictureStatus) boteater.updateProfile(boteaterProfile) boteater.sendMessage( msg.to, "Berhasil restore profile tunggu beberapa saat sampai profile berubah" ) except: boteater.sendMessage(msg.to, "Gagal restore profile") #=======### COMMAND GRUP ### elif text.lower() == '!crash': boteater.sendContact( to, "ub621484bd88d2486744123db00551d5e',") elif text.lower() == '!gcreator': group = boteater.getGroup(to) GS = group.creator.mid boteater.sendContact(to, GS) elif text.lower() == '!gpicture': group = boteater.getGroup(to) path = "http://dl.profile.line-cdn.net/" + group.pictureStatus boteater.sendImageWithURL(to, path) elif text.lower() == '!glink': if msg.toType == 2: group = boteater.getGroup(to) if group.preventedJoinByTicket == False: link = boteater.reissueGroupTicket(to) boteater.sendMessage( to, ">> LINK GRUP <<<\nhttps://line.me/R/ti/g/{}". format(str(link))) else: boteater.sendMessage(to, "QR NYA DI CLOSE") elif text.lower() == '!qr on': if msg.toType == 2: group = boteater.getGroup(to) if group.preventedJoinByTicket == False: boteater.sendMessage(to, "QR GRUP SUDAH DI OPEN!!!") else: group.preventedJoinByTicket = False boteater.updateGroup(group) boteater.sendMessage(to, "GRUP QR OPENED!!!") elif text.lower() == '!qr off': if msg.toType == 2: group = boteater.getGroup(to) if group.preventedJoinByTicket == True: boteater.sendMessage(to, "QR GRUP SUDAH DI CLOSE!!!") else: group.preventedJoinByTicket = True boteater.updateGroup(group) boteater.sendMessage(to, "GRUP QR CLOSED!!!") elif text.lower() == '!ginfo': group = boteater.getGroup(to) try: gCreator = group.creator.displayName except: gCreator = "GRUP CREATOR HILANG!!!" if group.preventedJoinByTicket == True: gQr = "CLOSED" gTicket = "Tidak ada" else: gQr = "OPEN" gTicket = "https://line.me/R/ti/g/{}".format( str(boteater.reissueglink(group.id))) path = "http://dl.profile.line-cdn.net/" + group.pictureStatus ret_ = "⊙ GRUP INFO ⊙" ret_ += "\nNAMA GRUP : {}".format(str(group.name)) ret_ += "\nCREATOR GRUP : {}".format(str(gCreator)) ret_ += "\nJUMBLAH MEMBER : {}".format( str(len(group.members))) ret_ += "\nGRUP QR : {}".format(gQr) ret_ += "\nLINK JOIN : {}".format(gTicket) boteater.sendMessage(to, str(ret_)) boteater.sendImageWithURL(to, path) elif text.lower() == '!gmember': if msg.toType == 2: group = boteater.getGroup(to) ret_ = ">>> LIST MEMBER <<<" no = 0 + 1 for mem in group.members: ret_ += "\n{}. {}".format(str(no), str(mem.displayName)) no += 1 ret_ += "\nTOTAL MEMBER: \n{}".format( str(len(group.members))) boteater.sendMessage(to, str(ret_)) elif text.lower() == '!glist': groups = boteater.groups ret_ = "⊙ LIST GRUP ⊙" no = 0 + 1 for gid in groups: group = boteater.getGroup(gid) ret_ += "\n{}. {} | {}".format(str(no), str(group.name), str(len(group.members))) no += 1 ret_ += "\nTOTAL GRUP : \n{}".format(str(len(groups))) boteater.sendMessage(to, str(ret_)) elif text.lower() == '!mention': group = boteater.getGroup(msg.to) nama = [contact.mid for contact in group.members] k = len(nama) // 100 for a in range(k + 1): txt = u'' s = 0 b = [] for i in group.members[a * 100:(a + 1) * 100]: b.append({ "S": str(s), "E": str(s + 6), "M": i.mid }) s += 7 txt += u' ' boteater.sendMessage(to, text=txt, contentMetadata={ u'MENTION': json.dumps({'MENTIONEES': b}) }, contentType=0) boteater.sendMessage( to, "TOTAL MENTION : \n{}".format(str(len(nama)))) ###ELIF COMMAND### elif text.lower() == '!kalender': tz = pytz.timezone("Asia/Jakarta") timeNow = datetime.now(tz=tz) day = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ] hari = [ "Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu" ] bulan = [ "Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember" ] hr = timeNow.strftime("%A") bln = timeNow.strftime("%m") for i in range(len(day)): if hr == day[i]: hasil = hari[i] for k in range(0, len(bulan)): if bln == str(k): bln = bulan[k - 1] readTime = hasil + ", " + timeNow.strftime( '%d') + " - " + bln + " - " + timeNow.strftime( '%Y') + "\nJam : [ " + timeNow.strftime( '%H:%M:%S') + " ]" boteater.sendMessage(msg.to, readTime) elif "!ssweb" in msg.text.lower(): sep = text.split(" ") query = text.replace(sep[0] + " ", "") with requests.session() as web: r = web.get( "http://rahandiapi.herokuapp.com/sswebAPI?key=betakey&link={}" .format(urllib.parse.quote(query))) data = r.text data = json.loads(data) boteater.sendImageWithURL(to, data["result"]) elif "!instagraminfo" in msg.text.lower(): sep = text.split(" ") search = text.replace(sep[0] + " ", "") with requests.session() as web: web.headers["User-Agent"] = random.choice( settings["userAgent"]) r = web.get( "https://www.instagram.com/{}/?__a=1".format( search)) try: data = json.loads(r.text) ret_ = ("⊙ INFO INSTAGRAM {} ⊙".format(search)) ret_ += "\nPROFIL : {}".format( str(data["user"]["full_name"])) ret_ += "\nUSERNAME : {}".format( str(data["user"]["username"])) ret_ += "\nSTATUS BIO : {}".format( str(data["user"]["biography"])) ret_ += "\nFOLLOWERS : {}".format( format_number( data["user"]["followed_by"]["count"])) ret_ += "\nFOLLOWING : {}".format( format_number( data["user"]["follows"]["count"])) if data["user"]["is_verified"] == True: ret_ += "\nSTATUS VERIFIED : VERIFIED" else: ret_ += "\nSTATUS VERIFIED : NOT VERIFIED" if data["user"]["is_private"] == True: ret_ += "\nSTATUS PRIVATE : PRIVATE" else: ret_ += "\nSTATUS PRIVATE : NOT PRIVATE" ret_ += "\nTOTAL POST : {}".format( format_number(data["user"]["media"]["count"])) ret_ += "\nLINK : https://www.instagram.com/{} ]".format( search) path = data["user"]["profile_pic_url_hd"] boteater.sendImageWithURL(to, str(path)) boteater.sendMessage(to, str(ret_)) except: boteater.sendMessage(to, "INSTAGRAM TIDAK DI TEMUKAN") elif "!instagrampost" in msg.text.lower(): separate = msg.text.split(" ") user = msg.text.replace(separate[0] + " ", "") profile = "https://www.instagram.com/" + user with requests.session() as x: x.headers['user-agent'] = 'Mozilla/5.0' end_cursor = '' for count in range(1, 999): print('PAGE: ', count) r = x.get(profile, params={'max_id': end_cursor}) data = re.search( r'window._sharedData = (\{.+?});</script>', r.text).group(1) j = json.loads(data) for node in j['entry_data']['ProfilePage'][0][ 'user']['media']['nodes']: if node['is_video']: page = 'https://www.instagram.com/p/' + node[ 'code'] r = x.get(page) url = re.search(r'"video_url": "([^"]+)"', r.text).group(1) print(url) boteater.sendVideoWithURL(msg.to, url) else: print(node['display_src']) boteater.sendImageWithURL( msg.to, node['display_src']) end_cursor = re.search(r'"end_cursor": "([^"]+)"', r.text).group(1) elif "!image " in msg.text.lower(): separate = msg.text.split(" ") search = msg.text.replace(separate[0] + " ", "") with requests.session() as web: web.headers["User-Agent"] = random.choice( settings["userAgent"]) r = web.get( "http://rahandiapi.herokuapp.com/imageapi?key=betakey&q={}" .format(urllib.parse.quote(search))) data = r.text data = json.loads(data) if data["result"] != []: items = data["result"] path = random.choice(items) a = items.index(path) b = len(items) boteater.sendImageWithURL(to, str(path)) elif "!youtube" in msg.text.lower(): sep = text.split(" ") search = text.replace(sep[0] + " ", "") params = {"search_query": search} with requests.session() as web: web.headers["User-Agent"] = random.choice( settings["userAgent"]) r = web.get("https://www.youtube.com/results", params=params) soup = BeautifulSoup(r.content, "html5lib") ret_ = "⊙ HASIL YOUTUBE ⊙" datas = [] for data in soup.select(".yt-lockup-title > a[title]"): if "&lists" not in data["href"]: datas.append(data) for data in datas: ret_ += "\nJUDUL : {} ".format(str(data["title"])) ret_ += "\nLINK : https://www.youtube.com{}".format( str(data["href"])) boteater.sendMessage(to, str(ret_)) #######################TAMBAHAN################################### elif text.lower() == '!animelist': data = {'submit2': ''} r = requests.post(url='https://boteater.com/anime/', data=data) qr = r.text os.system('rm {}.txt'.format(msg._from)) urllib.request.urlretrieve( 'http://149.28.137.54/animelist.json', '{}.txt'.format(msg._from)) links = [] juduls = [] if r.status_code == 404: boteater.sendMessage(msg.to, 'FAIL!!!') else: j = json.loads(qr) for p in j['result']: juduls.append(p['judul']) links.append(p['link']) h = ('⊙ANIME LIST⊙') number = 1 try: for numx in range(1000): xx = juduls[numx] h += ('\n{}. {}'.format(numx, xx)) number += 1 except: boteater.sendMessage(msg.to, h) boteater.sendMessage( msg.to, 'PLEASE TYPE = EPPLIST [NUMBER]') if text.lower() == '!animenew': data = {'submit1': ''} r = requests.post(url='https://boteater.com/anime/', data=data) qr = r.text os.system('rm {}.txt'.format(msg._from)) urllib.request.urlretrieve( 'http://149.28.137.54/animebaru.json', '{}.txt'.format(msg._from)) links = [] juduls = [] if r.status_code == 404: boteater.sendMessage(msg.to, 'FAIL!!!') else: j = json.loads(qr) for p in j['result']: juduls.append(p['judul']) links.append(p['link']) h = ('⊙ANIME LIST⊙') number = 1 try: for numx in range(1000): xx = juduls[numx] h += ('\n{}. {}'.format(numx, xx)) number += 1 except: boteater.sendMessage(msg.to, h) boteater.sendMessage( msg.to, 'PLEASE TYPE = STREAMEPPZ [NUMBER]') elif "!epplist " in msg.text.lower(): separate = msg.text.split(" ") numf = msg.text.replace(separate[0] + " ", "") numzz = int(numf) numz = numzz with open('{}.txt'.format(msg._from), 'r') as f: qr = f.read() j = json.loads(qr) juduls = [] links = [] for p in j['result']: juduls.append(p['judul']) links.append(p['link']) xx = links[numz] xxx = juduls[numz] data = {'link2': '{}'.format(xx), 'submit4': ''} r = requests.post(url='https://boteater.com/anime/', data=data) qr = r.text f = open('{}.txt'.format(msg._from), 'w') f.write(qr) f.close() links = [] juduls = [] if r.status_code == 404: boteater.sendMessage( msg.to, 'FAIL!!! SELECT YOUR ANIME FIRST!!!') else: j = json.loads(qr) for p in j['result']: juduls.append(p['epp']) links.append(p['link']) h = ('⊙EPISODE LIST LIST⊙ \n⊙{}⊙'.format(xxx)) number = 1 try: for numx in range(1000): zzz = juduls[numx] h += ('\n{}. {}'.format(numx, zzz)) number += 1 except: boteater.sendMessage(msg.to, h) boteater.sendMessage( msg.to, 'PLEASE TYPE = STREAMEPP [NUMBER]') if juduls in ["", "\n", " ", None]: boteater.sendMessage( msg.to, 'LINK ANIME IS DIED!!') elif "!streamepp " in msg.text.lower(): separate = msg.text.split(" ") numf = msg.text.replace(separate[0] + " ", "") numzz = int(numf) numz = numzz with open('{}.txt'.format(msg._from), 'r') as f: qr = f.read() j = json.loads(qr) juduls = [] links = [] for p in j['result']: juduls.append(p['epp']) links.append(p['link']) xx = links[numz] xxx = juduls[numz] data = {'link1': '{}'.format(xx), 'submit3': ''} r = requests.post(url='https://boteater.com/anime/', data=data) link = r.text boteater.sendMessage( msg.to, ">> STREAM ANIME<< \n>> {} << \n{}".format( xxx, link)) elif "!streameppz " in msg.text.lower(): separate = msg.text.split(" ") numf = msg.text.replace(separate[0] + " ", "") numzz = int(numf) numz = numzz with open('{}.txt'.format(msg._from), 'r') as f: qr = f.read() j = json.loads(qr) juduls = [] links = [] for p in j['result']: juduls.append(p['judul']) links.append(p['link']) xx = links[numz] xxx = juduls[numz] data = {'link1': '{}'.format(xx), 'submit3': ''} r = requests.post(url='https://boteater.com/anime/', data=data) link = r.text boteater.sendMessage( msg.to, ">> STREAM ANIME<< \n>> {} << \n{}".format( xxx, link)) elif text.lower() == '!token desktopmac': data = {'nama': '{}'.format(msg._from), 'submit4': ''} post_response = requests.post( url='https://boteater.com/sniff/', data=data) qr = post_response.text boteater.sendMessage(msg.to, '{}'.format(qr)) elif text.lower() == '!token win10': data = {'nama': '{}'.format(msg._from), 'submit3': ''} post_response = requests.post( url='https://boteater.com/sniff/', data=data) qr = post_response.text boteater.sendMessage(msg.to, '{}'.format(qr)) elif text.lower() == '!token ios': data = {'nama': '{}'.format(msg._from), 'submit2': ''} post_response = requests.post( url='https://boteater.com/sniff/', data=data) qr = post_response.text boteater.sendMessage(msg.to, '{}'.format(qr)) elif text.lower() == '!token chrome': data = {'nama': '{}'.format(msg._from), 'submit1': ''} post_response = requests.post( url='https://boteater.com/sniff/', data=data) qr = post_response.text boteater.sendMessage(msg.to, '{}'.format(qr)) elif text.lower() == '!token desktopwin': data = {'nama': '{}'.format(msg._from), 'submit7': ''} post_response = requests.post( url='https://boteater.com/sniff/', data=data) qr = post_response.text boteater.sendMessage(msg.to, '{}'.format(qr)) elif text.lower() == '!done': data = {'nama': '{}'.format(msg._from), 'submit5': ''} post_response = requests.post( url='https://boteater.com/sniff/', data=data) qr = post_response.text boteater.sendMessage(to, "YOUR TOKEN!!") boteater.sendMessage(msg.to, '{}'.format(qr)) elif msg.contentType == 7: if settings["autochecksticker"] == True: stk_id = msg.contentMetadata['STKID'] stk_ver = msg.contentMetadata['STKVER'] pkg_id = msg.contentMetadata['STKPKGID'] ret_ = "⊙ INFO STICKER ⊙" ret_ += "\n⊙ID STICKER : {}".format(stk_id) ret_ += "\n⊙LINK STICKER : line://shop/detail/{}".format( pkg_id) ret_ += "\n⊙●SLΔCҜβΩT● STICKER DETECTED⊙" boteater.sendMessage(to, str(ret_)) elif msg.contentType == 13: if settings["copy"] == True: _name = msg.contentMetadata["displayName"] copy = msg.contentMetadata["mid"] groups = boteater.getGroup(msg.to) targets = [] for s in groups.members: if _name in s.displayName: print("[Target] Copy") break else: targets.append(copy) if targets == []: boteater.sendText(msg.to, "TARGET TIDAK DI TEMUKAN") pass else: for target in targets: try: boteater.cloneContactProfile(target) boteater.sendMessage( msg.to, "BERHASIL MENIRU PROFIL!!!") settings['copy'] = False break except: msg.contentMetadata = {'mid': target} settings["copy"] = False break if op.type == 25: print("PENSAN TELAH DI TERIMA!!!") msg = op.message text = msg.text msg_id = msg.id receiver = msg.to sender = msg._from if msg.toType == 0: if sender != boteater.profile.mid: to = sender else: to = receiver else: to = receiver if settings["autoRead"] == True: boteater.sendChatChecked(to, msg_id) if to in read["readPoint"]: if sender not in read["ROM"][to]: read["ROM"][to][sender] = True if sender in settings["mimic"]["target"] and settings["mimic"][ "status"] == True and settings["mimic"]["target"][ sender] == True: text = msg.text if text is not None: boteater.sendMessage(msg.to, text) if msg.contentType == 0 and sender not in boteaterMID and msg.toType == 2: if 'MENTION' in msg.contentMetadata.keys() != None: names = re.findall(r'@(\w+)', text) mention = ast.literal_eval( msg.contentMetadata['MENTION']) mentionees = mention['MENTIONEES'] lists = [] for mention in mentionees: if boteaterMID in mention["M"]: if settings["detectMention"] == True: contact = boteater.getContact(sender) boteater.sendMessage(to, "sundala nu") sendMessageWithMention(to, contact.mid) break if op.type == 55: print("PESAN TELAH DI BACA!!!") try: if op.param1 in read['readPoint']: if op.param2 in read['readMember'][op.param1]: pass else: read['readMember'][op.param1] += op.param2 read['ROM'][op.param1][op.param2] = op.param2 backupData() else: pass except: pass except Exception as error: logError(error)
def print_formatted_number(value): """Print large numbers in a human readable format.""" print(format_number(float(value)))
def nullsafe_format_number(n) -> Optional[str]: return format_number(n) if n is not None else None
def fn(n): return humanfriendly.format_number(n).replace(",", ".")
def lineBot(op): try: if op.type == 0: print("DONE") return if op.type == 5: print("INFO SELBOT : ADA YANG ADD") if settings["autoAdd"] == True: boteater.sendMessage( op.param1, "=== SELFBOT BOTEATER V1.0 === \nTERIMAKASIH {} TELAH ADD SAYA" .format(str(boteater.getContact(op.param1).displayName))) if op.type == 13: print("INFO SELBOT : ADA YANG INVITE GRUP") group = boteater.getGroup(op.param1) if settings["autoJoin"] == True: boteater.acceptGroupInvitation(op.param1) if op.type == 24: print("INFO SELBOT : LEAVE ROOM") if settings["autoLeave"] == True: boteater.leaveRoom(op.param1) if op.type == 25: print("INFO SELBOT : MENGIRIM PESAN") msg = op.message text = msg.text msg_id = msg.id receiver = msg.to sender = msg._from if msg.toType == 0: if sender != boteater.profile.mid: to = sender else: to = receiver else: to = receiver if msg.contentType == 0: if text is None: return if text.lower() == 'help': boteater.sendMessage( to, "=== BOTEATER SELFBOT V.1 === \nbotmenu \nsetting \nselfmenu \ngrupmenu \nmedia" ) elif text.lower() == 'botmenu': boteater.sendMessage( to, "=== BOTEATER SELFBOT V.1 === \nrestart \nspeed \nstatus \nabout \nruntime \nerrorlog" ) elif text.lower() == 'setting': boteater.sendMessage( to, "=== BOTEATER SELFBOT V.1 === \nautoadd(on/off) \nautoread(on/off) \nautojoin(on/off) \nautoleave(on/off) \nautochecksticker(on/off) \ndetectmention(on/off)" ) elif text.lower() == 'selfmenu': boteater.sendMessage( to, "=== BOTEATER SELFBOT V.1 === \nme \nmymid \nmypicture \nmyvideo \nmycover \nstealcontact(mention) \nstealmid(mention) \nstealbio(mention) \nstealpicture(mention) \nstealvideoprofile(mention) \nstealcover(mention) \ncloneprofile(mention) \nrestoreprofile \nmention" ) elif text.lower() == 'grupmenu': boteater.sendMessage( to, "=== BOTEATER SELFBOT V.1 === \ngcreator \ngpicture \nglink \nqr(on/off) \nglist \ngmember \nginfo \ncrash" ) elif text.lower() == 'media': boteater.sendMessage( to, "=== BOTEATER SELFBOT V.1 === \ninstagraminfo(username) \ninstagrampost(username) \nyoutubes(keyword) \nimage(keyword) \nssweb(link)" ) ### BOT MENU COMMAND ### elif text.lower() == 'speed': start = time.time() boteater.sendMessage(to, "SPEED CHECK...") elapsed_time = time.time() - start boteater.sendMessage(to, format(str(elapsed_time))) elif text.lower() == 'restart': boteater.sendMessage(to, "SEDANG RESTART") time.sleep(5) boteater.sendMessage(to, "SUKSES!!!") restartBot() elif text.lower() == 'errorlog': with open('error.txt', 'r') as er: error = er.read() boteater.sendMessage(to, str(error)) elif text.lower() == 'runtime': timeNow = time.time() runtime = timeNow - botStart runtime = format_timespan(runtime) boteater.sendMessage( to, "BOT ALREADY RUN IN \n {}".format(str(runtime))) elif text.lower() == 'about': try: arr = [] saya = "uedcb4744c255b5cf5eb4a43f700a6c32" creator = boteater.getContact(saya) ret_ = ">>> INFO BOT <<<" ret_ += "\nSELFBOT PYTHON 3 BOTEATER V1.0" ret_ += "\nBOT INI MILIK BOTEATER TIDAK UNTUK DI PERJUAL BELIKAN!!! (GRATIS)" ret_ += "\nYANG BUAT : {}".format(creator.displayName) ret_ += "\n===== IKLAN ===== \nSEDIA BERBAGAI MACAM VPS MURAH : https://lazybot.us" boteater.sendMessage(to, str(ret_)) except Exception as e: boteater.sendMessage(msg.to, str(e)) elif text.lower() == 'status': try: ret_ = " >>> STATUS BOT <<<" if settings["autoAdd"] == True: ret_ += "\nAUTO ADD ACTIVED" else: ret_ += "\nAUTO ADD NOT ACTIVED" if settings["autoJoin"] == True: ret_ += "\nAUTO JOIN ACTIVED" else: ret_ += "\nAUTO JOIN NOT ACTIVED" if settings["autoLeave"] == True: ret_ += "\nAUTO LEAVE ACTIVED" else: ret_ += "\nAUTO LEAVE NOT ACTIVED" if settings["autoRead"] == True: ret_ += "\nAUTO READ ACTIVED" else: ret_ += "\nAUTO READ NOT ACTIVED" if settings["autochecksticker"] == True: ret_ += "\nAUTO CHECK STICKER ACTIVED" else: ret_ += "\nAUTO CHECK STICKER NOT ACTIVED" if settings["detectMention"] == True: ret_ += "\nDETECT MENTION ACTIVED" else: ret_ += "\nDETECT MENTION NOT ACTIVED" ret_ += " " boteater.sendMessage(to, str(ret_)) except Exception as e: boteater.sendMessage(msg.to, str(e)) elif text.lower() == 'autoadd on': settings["autoAdd"] = True boteater.sendMessage(to, "AUTO ADD IS ACTIVED") elif text.lower() == 'autoadd off': settings["autoAdd"] = False boteater.sendMessage(to, "AUTO ADD IS NOT ACTIVED") elif text.lower() == 'autojoin on': settings["autoJoin"] = True boteater.sendMessage(to, "AUTO JOIN IS IS ACTIVED") elif text.lower() == 'autojoin off': settings["autoJoin"] = False boteater.sendMessage(to, "AUTO JOIN IS IS NOT ACTIVED") elif text.lower() == 'autoleave on': settings["autoLeave"] = True boteater.sendMessage(to, "AUTO LEAVE IS ACTIVED") elif text.lower() == 'autojoin off': settings["autoLeave"] = False boteater.sendMessage(to, "AUTO LEAVE IS NOT ACTIVED") elif text.lower() == 'autoread on': settings["autoRead"] = True boteater.sendMessage(to, "AUTO READ IS ACTIVED") elif text.lower() == 'autoread off': settings["autoRead"] = False boteater.sendMessage(to, "AUTO READ IS NOT ACTIVED") elif text.lower() == 'autochecksticker on': settings["autochecksticker"] = True boteater.sendMessage(to, "AUTO zautochecksticker IS ACTIVED") elif text.lower() == 'autochecksticker off': settings["autochecksticker"] = False boteater.sendMessage( to, "AUTO zautochecksticker IS NOT ACTIVED") elif text.lower() == 'detectmention on': settings["datectMention"] = True boteater.sendMessage(to, "DETECT MENTION IS ACTIVED") elif text.lower() == 'detectmention off': settings["datectMention"] = False boteater.sendMessage(to, "DETECT MENTION IS NOT ACTIVED") elif text.lower() == 'clonecontact': settings["copy"] = True boteater.sendMessage(to, "SEND CONTACT TO CLONE!!!") ### SELFBOT COMMAND ### elif text.lower() == 'me': sendMessageWithMention(to, boteaterMID) boteater.sendContact(to, boteaterMID) elif text.lower() == 'mymid': boteater.sendMessage(msg.to, "MID KAMU : " + boteaterMID) elif text.lower() == 'mypicture': me = boteater.getContact(boteaterMID) boteater.sendImageWithURL( msg.to, "http://dl.profile.line-cdn.net/" + me.pictureStatus) elif text.lower() == 'myvideo': me = boteater.getContact(boteaterMID) boteater.sendVideoWithURL( msg.to, "http://dl.profile.line-cdn.net/" + me.pictureStatus + "/vp") elif text.lower() == 'mycover': me = boteater.getContact(boteaterMID) cover = boteater.getProfileCoverURL(boteaterMID) boteater.sendImageWithURL(msg.to, cover) elif msg.text.lower().startswith("stealcontact "): if 'MENTION' in msg.contentMetadata.keys() != None: names = re.findall(r'@(\w+)', text) mention = ast.literal_eval( msg.contentMetadata['MENTION']) mentionees = mention['MENTIONEES'] lists = [] for mention in mentionees: if mention["M"] not in lists: lists.append(mention["M"]) for ls in lists: contact = boteater.getContact(ls) mi_d = contact.mid boteater.sendContact(msg.to, mi_d) elif msg.text.lower().startswith("stealmid "): if 'MENTION' in msg.contentMetadata.keys() != None: names = re.findall(r'@(\w+)', text) mention = ast.literal_eval( msg.contentMetadata['MENTION']) mentionees = mention['MENTIONEES'] lists = [] for mention in mentionees: if mention["M"] not in lists: lists.append(mention["M"]) ret_ = "MID : " for ls in lists: ret_ += "\n{}" + ls boteater.sendMessage(msg.to, str(ret_)) elif msg.text.lower().startswith("stealname "): if 'MENTION' in msg.contentMetadata.keys() != None: names = re.findall(r'@(\w+)', text) mention = ast.literal_eval( msg.contentMetadata['MENTION']) mentionees = mention['MENTIONEES'] lists = [] for mention in mentionees: if mention["M"] not in lists: lists.append(mention["M"]) for ls in lists: contact = boteater.getContact(ls) boteater.sendMessage( msg.to, "NAME : \n" + contact.displayName) elif msg.text.lower().startswith("stealbio "): if 'MENTION' in msg.contentMetadata.keys() != None: names = re.findall(r'@(\w+)', text) mention = ast.literal_eval( msg.contentMetadata['MENTION']) mentionees = mention['MENTIONEES'] lists = [] for mention in mentionees: if mention["M"] not in lists: lists.append(mention["M"]) for ls in lists: contact = boteater.getContact(ls) boteater.sendMessage( msg.to, "INFO BIO : \n{}" + contact.statusMessage) elif msg.text.lower().startswith("stealpicture "): if 'MENTION' in msg.contentMetadata.keys() != None: names = re.findall(r'@(\w+)', text) mention = ast.literal_eval( msg.contentMetadata['MENTION']) mentionees = mention['MENTIONEES'] lists = [] for mention in mentionees: if mention["M"] not in lists: lists.append(mention["M"]) for ls in lists: path = "http://dl.profile.line.naver.jp/" + boteater.getContact( ls).pictureStatus boteater.sendImageWithURL(msg.to, str(path)) elif msg.text.lower().startswith("stealvideoprofile "): if 'MENTION' in msg.contentMetadata.keys() != None: names = re.findall(r'@(\w+)', text) mention = ast.literal_eval( msg.contentMetadata['MENTION']) mentionees = mention['MENTIONEES'] lists = [] for mention in mentionees: if mention["M"] not in lists: lists.append(mention["M"]) for ls in lists: path = "http://dl.profile.line.naver.jp/" + boteater.getContact( ls).pictureStatus + "/vp" boteater.sendImageWithURL(msg.to, str(path)) elif msg.text.lower().startswith("stealcover "): if line != None: if 'MENTION' in msg.contentMetadata.keys() != None: names = re.findall(r'@(\w+)', text) mention = ast.literal_eval( msg.contentMetadata['MENTION']) mentionees = mention['MENTIONEES'] lists = [] for mention in mentionees: if mention["M"] not in lists: lists.append(mention["M"]) for ls in lists: path = boteater.getProfileCoverURL(ls) boteater.sendImageWithURL(msg.to, str(path)) elif msg.text.lower().startswith("cloneprofile "): if 'MENTION' in msg.contentMetadata.keys() != None: names = re.findall(r'@(\w+)', text) mention = ast.literal_eval( msg.contentMetadata['MENTION']) mentionees = mention['MENTIONEES'] for mention in mentionees: contact = mention["M"] break try: boteater.cloneContactProfile(contact) boteater.sendMessage( msg.to, "Berhasil clone member tunggu beberapa saat sampai profile berubah" ) except: boteater.sendMessage(msg.to, "Gagal clone member") elif text.lower() == 'restoreprofile': try: boteaterProfile.displayName = str( myProfile["displayName"]) boteaterProfile.statusMessage = str( myProfile["statusMessage"]) boteaterProfile.pictureStatus = str( myProfile["pictureStatus"]) boteater.updateProfileAttribute( 8, boteaterProfile.pictureStatus) boteater.updateProfile(boteaterProfile) boteater.sendMessage( msg.to, "Berhasil restore profile tunggu beberapa saat sampai profile berubah" ) except: boteater.sendMessage(msg.to, "Gagal restore profile") #=======### COMMAND GRUP ### elif text.lower() == 'crash': boteater.sendContact( to, "ub621484bd88d2486744123db00551d5e',") elif text.lower() == 'gcreator': group = boteater.getGroup(to) GS = group.creator.mid boteater.sendContact(to, GS) elif text.lower() == 'gpicture': group = boteater.getGroup(to) path = "http://dl.profile.line-cdn.net/" + group.pictureStatus boteater.sendImageWithURL(to, path) elif text.lower() == 'glink': if msg.toType == 2: group = boteater.getGroup(to) if group.preventedJoinByTicket == False: link = boteater.reissueGroupTicket(to) boteater.sendMessage( to, ">> LINK GRUP <<<\nhttps://line.me/R/ti/g/{}". format(str(link))) else: boteater.sendMessage(to, "QR NYA DI CLOSE") elif text.lower() == 'qr on': if msg.toType == 2: group = boteater.getGroup(to) if group.preventedJoinByTicket == False: boteater.sendMessage(to, "QR GRUP SUDAH DI OPEN!!!") else: group.preventedJoinByTicket = False boteater.updateGroup(group) boteater.sendMessage(to, "GRUP QR OPENED!!!") elif text.lower() == 'qr off': if msg.toType == 2: group = boteater.getGroup(to) if group.preventedJoinByTicket == True: boteater.sendMessage(to, "QR GRUP SUDAH DI CLOSE!!!") else: group.preventedJoinByTicket = True boteater.updateGroup(group) boteater.sendMessage(to, "GRUP QR CLOSED!!!") elif text.lower() == 'ginfo': group = boteater.getGroup(to) try: gCreator = group.creator.displayName except: gCreator = "GRUP CREATOR HILANG!!!" if group.preventedJoinByTicket == True: gQr = "CLOSED" gTicket = "Tidak ada" else: gQr = "OPEN" gTicket = "https://line.me/R/ti/g/{}".format( str(boteater.reissueglink(group.id))) path = "http://dl.profile.line-cdn.net/" + group.pictureStatus ret_ = ">>> GRUP INFO <<<" ret_ += "\nNAMA GRUP : {}".format(str(group.name)) ret_ += "\nCREATOR GRUP : {}".format(str(gCreator)) ret_ += "\nJUMBLAH MEMBER : {}".format( str(len(group.members))) ret_ += "\nGRUP QR : {}".format(gQr) ret_ += "\nLINK JOIN : {}".format(gTicket) boteater.sendMessage(to, str(ret_)) boteater.sendImageWithURL(to, path) elif text.lower() == 'gmember': if msg.toType == 2: group = boteater.getGroup(to) ret_ = ">>> LIST MEMBER <<<" no = 0 + 1 for mem in group.members: ret_ += "\n{}. {}".format(str(no), str(mem.displayName)) no += 1 ret_ += "\nTOTAL MEMBER: \n{}".format( str(len(group.members))) boteater.sendMessage(to, str(ret_)) elif text.lower() == 'glist': groups = boteater.groups ret_ = ">>> LIST GRUP <<<" no = 0 + 1 for gid in groups: group = boteater.getGroup(gid) ret_ += "\n{}. {} | {}".format(str(no), str(group.name), str(len(group.members))) no += 1 ret_ += "\nTOTAL GRUP : \n{}".format(str(len(groups))) boteater.sendMessage(to, str(ret_)) elif text.lower() == 'mention': group = boteater.getGroup(msg.to) nama = [contact.mid for contact in group.members] k = len(nama) // 100 for a in range(k + 1): txt = u'' s = 0 b = [] for i in group.members[a * 100:(a + 1) * 100]: b.append({ "S": str(s), "E": str(s + 6), "M": i.mid }) s += 7 txt += u' ' boteater.sendMessage(to, text=txt, contentMetadata={ u'MENTION': json.dumps({'MENTIONEES': b}) }, contentType=0) boteater.sendMessage( to, "TOTAL MENTION : \n{}".format(str(len(nama)))) ###ELIF COMMAND### elif text.lower() == 'kalender': tz = pytz.timezone("Asia/Jakarta") timeNow = datetime.now(tz=tz) day = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ] hari = [ "Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu" ] bulan = [ "Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember" ] hr = timeNow.strftime("%A") bln = timeNow.strftime("%m") for i in range(len(day)): if hr == day[i]: hasil = hari[i] for k in range(0, len(bulan)): if bln == str(k): bln = bulan[k - 1] readTime = hasil + ", " + timeNow.strftime( '%d') + " - " + bln + " - " + timeNow.strftime( '%Y') + "\nJam : [ " + timeNow.strftime( '%H:%M:%S') + " ]" boteater.sendMessage(msg.to, readTime) elif "ssweb" in msg.text.lower(): sep = text.split(" ") query = text.replace(sep[0] + " ", "") with requests.session() as web: r = web.get( "http://rahandiapi.herokuapp.com/sswebAPI?key=betakey&link={}" .format(urllib.parse.quote(query))) data = r.text data = json.loads(data) boteater.sendImageWithURL(to, data["result"]) elif "instagraminfo" in msg.text.lower(): sep = text.split(" ") search = text.replace(sep[0] + " ", "") with requests.session() as web: web.headers["User-Agent"] = random.choice( settings["userAgent"]) r = web.get( "https://www.instagram.com/{}/?__a=1".format( search)) try: data = json.loads(r.text) ret_ = (">>> INFO INSTAGRAM {} <<<".format(search)) ret_ += "\nPROFIL : {}".format( str(data["user"]["full_name"])) ret_ += "\nUSERNAME : {}".format( str(data["user"]["username"])) ret_ += "\nSTATUS BIO : {}".format( str(data["user"]["biography"])) ret_ += "\nFOLLOWERS : {}".format( format_number( data["user"]["followed_by"]["count"])) ret_ += "\nFOLLOWING : {}".format( format_number( data["user"]["follows"]["count"])) if data["user"]["is_verified"] == True: ret_ += "\nSTATUS VERIFIED : VERIFIED" else: ret_ += "\nSTATUS VERIFIED : NOT VERIFIED" if data["user"]["is_private"] == True: ret_ += "\nSTATUS PRIVATE : PRIVATE" else: ret_ += "\nSTATUS PRIVATE : NOT PRIVATE" ret_ += "\nTOTAL POST : {}".format( format_number(data["user"]["media"]["count"])) ret_ += "\nLINK : https://www.instagram.com/{} ]".format( search) path = data["user"]["profile_pic_url_hd"] boteater.sendImageWithURL(to, str(path)) boteater.sendMessage(to, str(ret_)) except: boteater.sendMessage(to, "INSTAGRAM TIDAK DI TEMUKAN") elif "instagrampost" in msg.text.lower(): separate = msg.text.split(" ") user = msg.text.replace(separate[0] + " ", "") profile = "https://www.instagram.com/" + user with requests.session() as x: x.headers['user-agent'] = 'Mozilla/5.0' end_cursor = '' for count in range(1, 999): print('PAGE: ', count) r = x.get(profile, params={'max_id': end_cursor}) data = re.search( r'window._sharedData = (\{.+?});</script>', r.text).group(1) j = json.loads(data) for node in j['entry_data']['ProfilePage'][0][ 'user']['media']['nodes']: if node['is_video']: page = 'https://www.instagram.com/p/' + node[ 'code'] r = x.get(page) url = re.search(r'"video_url": "([^"]+)"', r.text).group(1) print(url) boteater.sendVideoWithURL(msg.to, url) else: print(node['display_src']) boteater.sendImageWithURL( msg.to, node['display_src']) end_cursor = re.search(r'"end_cursor": "([^"]+)"', r.text).group(1) elif "image" in msg.text.lower(): separate = msg.text.split(" ") search = msg.text.replace(separate[0] + " ", "") with requests.session() as web: web.headers["User-Agent"] = random.choice( settings["userAgent"]) r = web.get( "http://rahandiapi.herokuapp.com/imageapi?key=betakey&q={}" .format(urllib.parse.quote(search))) data = r.text data = json.loads(data) if data["result"] != []: items = data["result"] path = random.choice(items) a = items.index(path) b = len(items) boteater.sendImageWithURL(to, str(path)) elif "youtubes" in msg.text.lower(): sep = text.split(" ") search = text.replace(sep[0] + " ", "") params = {"search_query": search} with requests.session() as web: web.headers["User-Agent"] = random.choice( settings["userAgent"]) r = web.get("https://www.youtube.com/results", params=params) soup = BeautifulSoup(r.content, "html5lib") ret_ = ">>> HASIL YOUTUBE <<<" datas = [] for data in soup.select(".yt-lockup-title > a[title]"): if "&lists" not in data["href"]: datas.append(data) for data in datas: ret_ += "\nJUDUL : {} ".format(str(data["title"])) ret_ += "\nLINK : https://www.youtube.com{}".format( str(data["href"])) boteater.sendMessage(to, str(ret_)) elif msg.contentType == 7: if settings["autochecksticker"] == True: stk_id = msg.contentMetadata['STKID'] stk_ver = msg.contentMetadata['STKVER'] pkg_id = msg.contentMetadata['STKPKGID'] ret_ = ">>> INFO STICKER <<<" ret_ += "\nID STICKER : {}".format(stk_id) ret_ += "\nLINK STICKER : line://shop/detail/{}".format( pkg_id) ret_ += "\n>>BOTEATER STICKER DETECTED<<" boteater.sendMessage(to, str(ret_)) elif msg.contentType == 13: if settings["copy"] == True: _name = msg.contentMetadata["displayName"] copy = msg.contentMetadata["mid"] groups = boteater.getGroup(msg.to) targets = [] for s in groups.members: if _name in s.displayName: print("[Target] Copy") break else: targets.append(copy) if targets == []: boteater.sendText(msg.to, "TARGET TIDAK DI TEMUKAN") pass else: for target in targets: try: boteater.cloneContactProfile(target) boteater.sendMessage( msg.to, "BERHASIL MENIRU PROFIL!!!") settings['copy'] = False break except: msg.contentMetadata = {'mid': target} settings["copy"] = False break if op.type == 26: print("PENSAN TELAH DI TERIMA!!!") msg = op.message text = msg.text msg_id = msg.id receiver = msg.to sender = msg._from if msg.toType == 0: if sender != boteater.profile.mid: to = sender else: to = receiver else: to = receiver if settings["autoRead"] == True: boteater.sendChatChecked(to, msg_id) if to in read["readPoint"]: if sender not in read["ROM"][to]: read["ROM"][to][sender] = True if sender in settings["mimic"]["target"] and settings["mimic"][ "status"] == True and settings["mimic"]["target"][ sender] == True: text = msg.text if text is not None: boteater.sendMessage(msg.to, text) if msg.contentType == 0 and sender not in boteaterMID and msg.toType == 2: if 'MENTION' in msg.contentMetadata.keys() != None: names = re.findall(r'@(\w+)', text) mention = ast.literal_eval( msg.contentMetadata['MENTION']) mentionees = mention['MENTIONEES'] lists = [] for mention in mentionees: if boteaterMID in mention["M"]: if settings["detectMention"] == True: contact = boteater.getContact(sender) boteater.sendMessage(to, "sundala nu") sendMessageWithMention(to, contact.mid) break if op.type == 55: print("PESAN TELAH DI BACA!!!") try: if op.param1 in read['readPoint']: if op.param2 in read['readMember'][op.param1]: pass else: read['readMember'][op.param1] += op.param2 read['ROM'][op.param1][op.param2] = op.param2 backupData() else: pass except: pass except Exception as error: logError(error)
def populate_subview(request, cid, subview): """ Populates a subview page's data. :param request: Request object (For DB access) :param cid: Carrier ID to populate :param subview: Which subview to fetch :return: """ res = [] headers = {} if subview == 'shipyard': ships = request.dbsession.query(Ship).filter(Ship.carrier_id == cid) for sp in ships: res.append({ 'col1_svg': 'inline_svgs/shipyard.jinja2', 'col1': translation.localize_shipyard(sp.name), 'col2': sp.basevalue, 'col3': sp.stock, 'col4': '<i class="fas fa-search"></i>' }) headers = { 'col1_header': 'Name', 'col2_header': 'Value', 'col3_header': 'stock', 'col4_header': 'Coriolis' } if subview == 'itinerary': itinerary = request.dbsession.query(Itinerary).filter( Itinerary.carrier_id == cid) mycarrier = request.dbsession.query(Carrier).filter( Carrier.id == cid).one_or_none() if request.user: if mycarrier.showItinerary or mycarrier.owner == request.user.id or request.user.userlevel >= 4: itinerary = request.dbsession.query(Itinerary).filter( Itinerary.carrier_id == cid) elif mycarrier.showItinerary: itinerary = request.dbsession.query(Itinerary).filter( Itinerary.carrier_id == cid) else: itinerary = [] for it in itinerary: res.append({ 'col1_svg': 'inline_svgs/completed_jumps.jinja2', 'col1': it.starsystem, 'col2': it.arrivalTime, 'col3': format_timespan(it.visitDurationSeconds), 'col4': it.departureTime }) headers = { 'col1_header': 'Star system', 'col2_header': 'Arrival time', 'col3_header': 'Visit duration', 'col4_header': 'Departure time' } if subview == 'market': mycarrier = request.dbsession.query(Carrier).filter( Carrier.id == cid).one_or_none() if request.user: if mycarrier.showMarket or mycarrier.owner == request.user.id or request.user.userlevel >= 4: market = request.dbsession.query(Market).filter( Market.carrier_id == cid) elif mycarrier.showMarket: market = request.dbsession.query(Market).filter( Market.carrier_id == cid) else: market = [] for mk in market: if mk.categoryname != 'NonMarketable': res.append({ 'col1_svg': 'inline_svgs/commodities.jinja2', 'col1': (format_number(mk.demand) if mk.demand else format_number(mk.stock)), 'col2': translation.localize_commodity(mk.name), 'col3': format_number(mk.buyPrice), 'col4': format_number(mk.sellPrice) }) headers = { 'col1_header': 'Demand/Supply', 'col2_header': 'Commodity', 'col3_header': 'Buy price', 'col4_header': 'Sell price' } if subview == 'outfitting': module = request.dbsession.query(Module).filter( Module.carrier_id == cid) for md in module: res.append({ 'col1_svg': 'inline_svgs/outfitting.jinja2', 'col1': format_number(md.stock), 'col2': md.category, 'col3': translation.localize_outfitting(md.name), 'col4': format_number(md.cost) }) headers = { 'col1_header': 'Stock', 'col2_header': 'Category', 'col3_header': 'Name', 'col4_header': 'Cost' } if subview == 'calendar': headers = { 'col1_header': "Not yet", 'col2_header': "Not yet", 'col3_header': 'Not yet', 'col4_header': "Not yet" } res.append({ "col1_svg": 'inline_svgs/completed_jumps.jinja2', 'col1': 'Not yet', 'col2': 'Not yet', 'col3': 'Not yet', 'col4': 'But soon!' }) return headers, res
def getDashboardInfo(): def getPhase(filepath): if 'pilot' in filepath: return 'pilot' elif 'phase1' in filepath: return 'phase1' elif 'phase2' in filepath: return 'phase2' else: return 'unknown' raw = {} raw['phases'] = {} for bagfile in RawBagfile.objects: phase = getPhase(bagfile.path) if phase not in raw['phases']: p = {} p["locations"] = {} p["total_size"] = 0 p["total_duration"] = 0 p["total_distance"] = 0 p["total_frames"] = 0 raw["phases"][phase] = p if bagfile.location not in raw["phases"][phase]["locations"]: loc = {} loc["fileinfo"] = [] loc["total_size"] = 0 loc["total_duration"] = 0 loc["total_distance"] = 0 loc["total_frames"] = 0 raw["phases"][phase]["locations"][bagfile.location] = loc frames = 0 for item in bagfile.info["topics"]: if "frontNear/left/image_raw" in item["topic"]: frames = item["messages"] break raw["phases"][phase]["locations"][bagfile.location]["fileinfo"].append( { 'name': bagfile.filename, 'size': bagfile.hsize, 'duration': bagfile.hduration, 'distance': bagfile.distance, 'frames': frames }) dst = 0 if bagfile.distance != "": dst = float(bagfile.distance.split(" ")[0]) # total for each location raw["phases"][phase]["locations"][ bagfile.location]["total_size"] += bagfile.info['size'] raw["phases"][phase]["locations"][ bagfile.location]["total_duration"] += bagfile.info['duration'] raw["phases"][phase]["locations"][ bagfile.location]["total_distance"] += dst raw["phases"][phase]["locations"][ bagfile.location]["total_frames"] += frames # total for each phase raw["phases"][phase]["total_size"] += bagfile.info['size'] raw["phases"][phase]["total_duration"] += bagfile.info['duration'] raw["phases"][phase]["total_distance"] += dst raw["phases"][phase]["total_frames"] += frames # totals for all data total_size = 0 total_duration = 0 total_distance = 0 total_frames = 0 for phase in raw["phases"]: for location in raw["phases"][phase]["locations"]: m, s = divmod( raw["phases"][phase]["locations"][location]["total_duration"], 60) h, m = divmod(m, 60) raw["phases"][phase]["locations"][location][ "total_size"] = humanfriendly.format_size( raw["phases"][phase]["locations"][location]["total_size"]) raw["phases"][phase]["locations"][location][ "total_duration"] = str(int(h)) + "hrs " + str( int(m)) + " mins " + str(int(s)) + " sec" raw["phases"][phase]["locations"][location][ "total_distance"] = humanfriendly.format_number( raw["phases"][phase]["locations"][location] ["total_distance"]) raw["phases"][phase]["locations"][location][ "total_frames"] = humanfriendly.format_number( raw["phases"][phase]["locations"][location] ["total_frames"]) total_size += raw["phases"][phase]["total_size"] total_duration += raw["phases"][phase]["total_duration"] total_distance += raw["phases"][phase]["total_distance"] total_frames += raw["phases"][phase]["total_frames"] m, s = divmod(raw["phases"][phase]["total_duration"], 60) h, m = divmod(m, 60) raw["phases"][phase]["total_duration"] = str(int(h)) + "hrs " + str( int(m)) + " mins " + str(int(s)) + " sec" raw["phases"][phase]["total_size"] = humanfriendly.format_size( raw["phases"][phase]["total_size"]) raw["phases"][phase]["total_distance"] = humanfriendly.format_number( raw["phases"][phase]["total_distance"]) raw["phases"][phase]["total_frames"] = humanfriendly.format_number( raw["phases"][phase]["total_frames"]) bagfiles_info = {} bagfiles_info['raw'] = raw m, s = divmod(total_duration, 60) h, m = divmod(m, 60) bagfiles_info['total_size'] = humanfriendly.format_size(total_size) bagfiles_info['total_duration'] = str(h) + " hours" bagfiles_info['total_distance'] = humanfriendly.format_number( total_distance) bagfiles_info['total_frames'] = humanfriendly.format_number(total_frames) return bagfiles_info
def lineBot(op): try: if op.type == 0: print("DONE") return if op.type == 5: print("INFO SELBOT : ADA YANG ADD") if settings["autoAdd"] == True: Hans.sendMessage( op.param1, "Psdbots v1.55\nThanks for add {} im here".format( str(Hans.getContact(op.param1).displayName))) if op.type == 13: print("INFO SELBOT : ADA YANG INVITE GRUP") group = Hans.getGroup(op.param1) if settings["autoJoin"] == True: Hans.acceptGroupInvitation(op.param1) if op.type == 24: print("INFO SELBOT : LEAVE ROOM") if settings["autoLeave"] == True: Hans.leaveRoom(op.param1) if op.type == 25: print("INFO SELBOT : MENGIRIM PESAN") msg = op.message text = msg.text msg_id = msg.id receiver = msg.to sender = msg._from if msg.toType == 0: if sender != Hans.profile.mid: to = sender else: to = receiver else: to = receiver if msg.contentType == 0: if text is None: return if text.lower() == 'help': Hans.sendMessage( to, "Psdbots v1.55\n1. my help \n2. setting \n3. help self \n4. help group \n5. help media" ) elif text.lower() == 'my help': Hans.sendMessage( to, "Psdbots v1.55\n1. restart \n2. speed \n3. status \n4. about \n5. runtime \n6. errorlog" ) elif text.lower() == 'setting': Hans.sendMessage( to, "Psdbots v1.55\n1. autoadd(on/off) \n2. autoread(on/off) \n3. autojoin(on/off) \n4. autoleave(on/off) \n5. autochecksticker(on/off) \n6. detectmention(on/off)" ) elif text.lower() == 'help self': Hans.sendMessage( to, "Psdbots v1.55\n1. me \n2. mymid \n3. mypicture \n4. myvideo \n5. mycover \n6. stealcontact(mention) \n7. stealmid(mention) \n8. stealbio(mention) \n9. stealpicture(mention) \n10. stealvideoprofile(mention) \n11. stealcover(mention) \n12. cloneprofile(mention) \n13. restoreprofile \n14. mention" ) elif text.lower() == 'help group': Hans.sendMessage( to, "Psdbots v1.55\n1. gcreator \n2. gpicture \n3. glink \n4. qr(on/off) \n5. glist \n6. gmember \n7. ginfo \n8. crash" ) elif text.lower() == 'help media': Hans.sendMessage( to, "Psdbots v1.55\n1. instagraminfo(username) \n2. instagrampost(username) \n3. youtubes(keyword) \n4. image(keyword) \n5. ssweb(link)" ) ### BOT MENU COMMAND ### elif text.lower() == 'speed': start = time.time() Hans.sendMessage(to, "Testing...") elapsed_time = time.time() - start Hans.sendMessage(to, format(str(elapsed_time))) elif text.lower() == 'restart': Hans.sendMessage(to, "Brb, going to pee") time.sleep(5) Hans.sendMessage(to, "Psdbots v1.55 done restart") restartBot() elif text.lower() == 'errorlog': with open('error.txt', 'r') as er: error = er.read() Hans.sendMessage(to, str(error)) elif text.lower() == 'runtime': timeNow = time.time() runtime = timeNow - botStart runtime = format_timespan(runtime) Hans.sendMessage(to, "Time it: \n {}".format(str(runtime))) elif text.lower() == 'about': try: arr = [] saya = "u504305ce649823fa9084b743983b40ac" creator = Hans.getContact(saya) ret_ = "Info Bots" ret_ += "\nPsdbots v1.55" ret_ += "\nBot fun (GRATIS)" ret_ += "\nowner bots : {}".format(creator.displayName) ret_ += "\nId Line : 1. line.me/ti/p/~psd_cihanz\n2. line.me/ti/p/~bangsat-12\n3. line.me/ti/p/~keilanooo\n4. line.me/ti/p/~psd_pps" Hans.sendMessage(to, str(ret_)) except Exception as e: Hans.sendMessage(msg.to, str(e)) elif text.lower() == 'status': try: ret_ = "Status:" if settings["autoAdd"] == True: ret_ += "\nAutoadd:on" else: ret_ += "\nAutoadd:off" if settings["autoJoin"] == True: ret_ += "\nAutojoin:on" else: ret_ += "\nAutojoin:off" if settings["autoLeave"] == True: ret_ += "\nAutoleave:on" else: ret_ += "\nAutoleave:off" if settings["autoRead"] == True: ret_ += "\nAutoread:on" else: ret_ += "\nAutoread:off" if settings["checkSticker"] == True: ret_ += "\nStickerDetect:on" else: ret_ += "\nStickerDetect:off" if settings["detectMention"] == True: ret_ += "\nMentionDetect:on" else: ret_ += "\nMentionDetect:off" ret_ += " " Hans.sendMessage(to, str(ret_)) except Exception as e: Hans.sendMessage(msg.to, str(e)) elif text.lower() == 'autoadd on': settings["autoAdd"] = True Hans.sendMessage(to, "<on>") elif text.lower() == 'autoadd off': settings["autoAdd"] = False Hans.sendMessage(to, "<off>") elif text.lower() == 'autojoin on': settings["autoJoin"] = True Hans.sendMessage(to, "<on>") elif text.lower() == 'autojoin off': settings["autoJoin"] = False Hans.sendMessage(to, "<off>") elif text.lower() == 'autoleave on': settings["autoLeave"] = True Hans.sendMessage(to, "<on>") elif text.lower() == 'autojoin off': settings["autoLeave"] = False Hans.sendMessage(to, "<off>") elif text.lower() == 'autoread on': settings["autoRead"] = True Hans.sendMessage(to, "<on>") elif text.lower() == 'autoread off': settings["autoRead"] = False Hans.sendMessage(to, "<off>") elif text.lower() == 'autochecksticker on': settings["checkSticker"] = True Hans.sendMessage(to, "<on>") elif text.lower() == 'autochecksticker off': settings["checkSticker"] = False Hans.sendMessage(to, "<off>") elif text.lower() == 'detectmention on': settings["datectMention"] = True Hans.sendMessage(to, "<on>") elif text.lower() == 'detectmention off': settings["datectMention"] = False Hans.sendMessage(to, "<off>") elif text.lower() == 'clonecontact': settings["copy"] = True Hans.sendMessage(to, "Send contact please") ### SELFBOT COMMAND ### elif text.lower() == 'me': sendMessageWithMention(to, HansMID) Hans.sendContact(to, HansMID) elif text.lower() == 'mymid': Hans.sendMessage(msg.to, "Mid: " + HansMID) elif text.lower() == 'mypicture': me = Hans.getContact(HansMID) Hans.sendImageWithURL( msg.to, "http://dl.profile.line-cdn.net/" + me.pictureStatus) elif text.lower() == 'myvideo': me = Hans.getContact(HansMID) Hans.sendVideoWithURL( msg.to, "http://dl.profile.line-cdn.net/" + me.pictureStatus + "/vp") elif text.lower() == 'mycover': me = Hans.getContact(HansMID) cover = Hans.getProfileCoverURL(HansMID) Hans.sendImageWithURL(msg.to, cover) elif msg.text.lower().startswith("stealcontact "): if 'MENTION' in msg.contentMetadata.keys() != None: names = re.findall(r'@(\w+)', text) mention = ast.literal_eval( msg.contentMetadata['MENTION']) mentionees = mention['MENTIONEES'] lists = [] for mention in mentionees: if mention["M"] not in lists: lists.append(mention["M"]) for ls in lists: contact = Hans.getContact(ls) mi_d = contact.mid Hans.sendContact(msg.to, mi_d) elif msg.text.lower().startswith("stealmid "): if 'MENTION' in msg.contentMetadata.keys() != None: names = re.findall(r'@(\w+)', text) mention = ast.literal_eval( msg.contentMetadata['MENTION']) mentionees = mention['MENTIONEES'] lists = [] for mention in mentionees: if mention["M"] not in lists: lists.append(mention["M"]) ret_ = "MID : " for ls in lists: ret_ += "\n{}" + ls Hans.sendMessage(msg.to, str(ret_)) elif msg.text.lower().startswith("stealname "): if 'MENTION' in msg.contentMetadata.keys() != None: names = re.findall(r'@(\w+)', text) mention = ast.literal_eval( msg.contentMetadata['MENTION']) mentionees = mention['MENTIONEES'] lists = [] for mention in mentionees: if mention["M"] not in lists: lists.append(mention["M"]) for ls in lists: contact = Hans.getContact(ls) Hans.sendMessage(msg.to, "NAME : \n" + contact.displayName) elif msg.text.lower().startswith("stealbio "): if 'MENTION' in msg.contentMetadata.keys() != None: names = re.findall(r'@(\w+)', text) mention = ast.literal_eval( msg.contentMetadata['MENTION']) mentionees = mention['MENTIONEES'] lists = [] for mention in mentionees: if mention["M"] not in lists: lists.append(mention["M"]) for ls in lists: contact = Hans.getContact(ls) Hans.sendMessage( msg.to, "INFO BIO : \n{}" + contact.statusMessage) elif msg.text.lower().startswith("stealpicture "): if 'MENTION' in msg.contentMetadata.keys() != None: names = re.findall(r'@(\w+)', text) mention = ast.literal_eval( msg.contentMetadata['MENTION']) mentionees = mention['MENTIONEES'] lists = [] for mention in mentionees: if mention["M"] not in lists: lists.append(mention["M"]) for ls in lists: path = "http://dl.profile.line.naver.jp/" + Hans.getContact( ls).pictureStatus Hans.sendImageWithURL(msg.to, str(path)) elif msg.text.lower().startswith("stealvideoprofile "): if 'MENTION' in msg.contentMetadata.keys() != None: names = re.findall(r'@(\w+)', text) mention = ast.literal_eval( msg.contentMetadata['MENTION']) mentionees = mention['MENTIONEES'] lists = [] for mention in mentionees: if mention["M"] not in lists: lists.append(mention["M"]) for ls in lists: path = "http://dl.profile.line.naver.jp/" + Hans.getContact( ls).pictureStatus + "/vp" Hans.sendImageWithURL(msg.to, str(path)) elif msg.text.lower().startswith("stealcover "): if line != None: if 'MENTION' in msg.contentMetadata.keys() != None: names = re.findall(r'@(\w+)', text) mention = ast.literal_eval( msg.contentMetadata['MENTION']) mentionees = mention['MENTIONEES'] lists = [] for mention in mentionees: if mention["M"] not in lists: lists.append(mention["M"]) for ls in lists: path = Hans.getProfileCoverURL(ls) Hans.sendImageWithURL(msg.to, str(path)) elif msg.text.lower().startswith("cloneprofile "): if 'MENTION' in msg.contentMetadata.keys() != None: names = re.findall(r'@(\w+)', text) mention = ast.literal_eval( msg.contentMetadata['MENTION']) mentionees = mention['MENTIONEES'] for mention in mentionees: contact = mention["M"] break try: Hans.cloneContactProfile(contact) Hans.sendMessage(msg.to, "Done clone contact") except: Hans.sendMessage(msg.to, "Failed") elif text.lower() == 'restoreprofile': try: HansProfile.displayName = str(myProfile["displayName"]) HansProfile.statusMessage = str( myProfile["statusMessage"]) HansProfile.pictureStatus = str( myProfile["pictureStatus"]) Hans.updateProfileAttribute(8, HansProfile.pictureStatus) Hans.updateProfile(HansProfile) Hans.sendMessage(msg.to, "Profile backsr") except: Hans.sendMessage(msg.to, "Failed") #=======### COMMAND GRUP ### elif text.lower() == 'crash': Hans.sendContact(to, "ub621484bd88d2486744123db00551d5e',") elif text.lower() == 'gcreator': group = Hans.getGroup(to) GS = group.creator.mid Hans.sendContact(to, GS) elif text.lower() == 'gpicture': group = Hans.getGroup(to) path = "http://dl.profile.line-cdn.net/" + group.pictureStatus Hans.sendImageWithURL(to, path) elif text.lower() == 'glink': if msg.toType == 2: group = Hans.getGroup(to) if group.preventedJoinByTicket == False: link = Hans.reissueGroupTicket(to) Hans.sendMessage( to, "Link:\nhttps://line.me/R/ti/g/{}".format( str(link))) else: Hans.sendMessage(to, "Please qr open in groups") elif text.lower() == 'qr on': if msg.toType == 2: group = Hans.getGroup(to) if group.preventedJoinByTicket == False: Hans.sendMessage(to, "Link open") else: group.preventedJoinByTicket = False Hans.updateGroup(group) Hans.sendMessage(to, "Group qr open") elif text.lower() == 'qr off': if msg.toType == 2: group = Hans.getGroup(to) if group.preventedJoinByTicket == True: Hans.sendMessage(to, "Link close") else: group.preventedJoinByTicket = True Hans.updateGroup(group) Hans.sendMessage(to, "Group qr close") elif text.lower() == 'ginfo': group = Hans.getGroup(to) try: gCreator = group.creator.displayName except: gCreator = "No makers" if group.preventedJoinByTicket == True: gQr = "Close" gTicket = "Tidak ada" else: gQr = "Open" gTicket = "https://line.me/R/ti/g/{}".format( str(Hans.reissueglink(group.id))) path = "http://dl.profile.line-cdn.net/" + group.pictureStatus ret_ = "Info Group: " ret_ += "\n1. NAMA GRUP : {}".format(str(group.name)) ret_ += "\n2. CREATOR GRUP : {}".format(str(gCreator)) ret_ += "\n3. JUMBLAH MEMBER : {}".format( str(len(group.members))) ret_ += "\n4. GRUP QR : {}".format(gQr) ret_ += "\n5. LINK JOIN : {}".format(gTicket) Hans.sendMessage(to, str(ret_)) Hans.sendImageWithURL(to, path) elif text.lower() == 'gmember': if msg.toType == 2: group = Hans.getGroup(to) ret_ = "List anggota" no = 0 + 1 for mem in group.members: ret_ += "\n{}. {}".format(str(no), str(mem.displayName)) no += 1 ret_ += "\nTotal:\n{}".format(str(len(group.members))) Hans.sendMessage(to, str(ret_)) elif text.lower() == 'glist': groups = Hans.groups ret_ = "List Group" no = 0 + 1 for gid in groups: group = Hans.getGroup(gid) ret_ += "\n{}. {} | {}".format(str(no), str(group.name), str(len(group.members))) no += 1 ret_ += "\nTotal: \n{}".format(str(len(groups))) Hans.sendMessage(to, str(ret_)) elif text.lower() == 'mention': group = Hans.getGroup(msg.to) nama = [contact.mid for contact in group.members] k = len(nama) // 100 for a in range(k + 1): txt = u'' s = 0 b = [] for i in group.members[a * 100:(a + 1) * 100]: b.append({ "S": str(s), "E": str(s + 6), "M": i.mid }) s += 7 txt += u'@Alin \n' Hans.sendMessage(to, text=txt, contentMetadata={ u'MENTION': json.dumps({'MENTIONEES': b}) }, contentType=0) Hans.sendMessage( to, "Total {} Mention".format(str(len(nama)))) ###ELIF COMMAND### elif text.lower() == 'kalender': tz = pytz.timezone("Asia/Jakarta") timeNow = datetime.now(tz=tz) day = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ] hari = [ "Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu" ] bulan = [ "Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember" ] hr = timeNow.strftime("%A") bln = timeNow.strftime("%m") for i in range(len(day)): if hr == day[i]: hasil = hari[i] for k in range(0, len(bulan)): if bln == str(k): bln = bulan[k - 1] readTime = hasil + ", " + timeNow.strftime( '%d') + " - " + bln + " - " + timeNow.strftime( '%Y') + "\nJam : [ " + timeNow.strftime( '%H:%M:%S') + " ]" Hans.sendMessage(msg.to, readTime) elif "ssweb" in msg.text.lower(): sep = text.split(" ") query = text.replace(sep[0] + " ", "") with requests.session() as web: r = web.get( "http://rahandiapi.herokuapp.com/sswebAPI?key=betakey&link={}" .format(urllib.parse.quote(query))) data = r.text data = json.loads(data) Hans.sendImageWithURL(to, data["result"]) elif "instagraminfo" in msg.text.lower(): sep = text.split(" ") search = text.replace(sep[0] + " ", "") with requests.session() as web: web.headers["User-Agent"] = random.choice( settings["userAgent"]) r = web.get( "https://www.instagram.com/{}/?__a=1".format( search)) try: data = json.loads(r.text) ret_ = ("Instagram Info <{}> ".format(search)) ret_ += "\n1. PROFIL : {}".format( str(data["user"]["full_name"])) ret_ += "\n2. USERNAME : {}".format( str(data["user"]["username"])) ret_ += "\n3. STATUS BIO : {}".format( str(data["user"]["biography"])) ret_ += "\n4. FOLLOWERS : {}".format( format_number( data["user"]["followed_by"]["count"])) ret_ += "\n5. FOLLOWING : {}".format( format_number( data["user"]["follows"]["count"])) if data["user"]["is_verified"] == True: ret_ += "\nSTATUS VERIFIED : VERIFIED" else: ret_ += "\nSTATUS VERIFIED : NOT VERIFIED" if data["user"]["is_private"] == True: ret_ += "\nSTATUS PRIVATE : PRIVATE" else: ret_ += "\nSTATUS PRIVATE : NOT PRIVATE" ret_ += "\nTOTAL POST : {}".format( format_number(data["user"]["media"]["count"])) ret_ += "\nLINK : https://www.instagram.com/{} ]".format( search) path = data["user"]["profile_pic_url_hd"] Hans.sendImageWithURL(to, str(path)) Hans.sendMessage(to, str(ret_)) except: Hans.sendMessage(to, "INSTAGRAM TIDAK DI TEMUKAN") elif "instagrampost" in msg.text.lower(): separate = msg.text.split(" ") user = msg.text.replace(separate[0] + " ", "") profile = "https://www.instagram.com/" + user with requests.session() as x: x.headers['user-agent'] = 'Mozilla/5.0' end_cursor = '' for count in range(1, 999): print('PAGE: ', count) r = x.get(profile, params={'max_id': end_cursor}) data = re.search( r'window._sharedData = (\{.+?});</script>', r.text).group(1) j = json.loads(data) for node in j['entry_data']['ProfilePage'][0][ 'user']['media']['nodes']: if node['is_video']: page = 'https://www.instagram.com/p/' + node[ 'code'] r = x.get(page) url = re.search(r'"video_url": "([^"]+)"', r.text).group(1) print(url) Hans.sendVideoWithURL(msg.to, url) else: print(node['display_src']) Hans.sendImageWithURL( msg.to, node['display_src']) end_cursor = re.search(r'"end_cursor": "([^"]+)"', r.text).group(1) elif "image" in msg.text.lower(): separate = msg.text.split(" ") search = msg.text.replace(separate[0] + " ", "") with requests.session() as web: web.headers["User-Agent"] = random.choice( settings["userAgent"]) r = web.get( "http://rahandiapi.herokuapp.com/imageapi?key=betakey&q={}" .format(urllib.parse.quote(search))) data = r.text data = json.loads(data) if data["result"] != []: items = data["result"] path = random.choice(items) a = items.index(path) b = len(items) Hans.sendImageWithURL(to, str(path)) elif "youtubes" in msg.text.lower(): sep = text.split(" ") search = text.replace(sep[0] + " ", "") params = {"search_query": search} with requests.session() as web: web.headers["User-Agent"] = random.choice( settings["userAgent"]) r = web.get("https://www.youtube.com/results", params=params) soup = BeautifulSoup(r.content, "html5lib") ret_ = "List Youtube" datas = [] for data in soup.select(".yt-lockup-title > a[title]"): if "&lists" not in data["href"]: datas.append(data) for data in datas: ret_ += "\nJUDUL : {} ".format(str(data["title"])) ret_ += "\nLINK : https://www.youtube.com{}".format( str(data["href"])) Hans.sendMessage(to, str(ret_)) elif msg.contentType == 7: if settings["autochecksticker"] == True: stk_id = msg.contentMetadata['STKID'] stk_ver = msg.contentMetadata['STKVER'] pkg_id = msg.contentMetadata['STKPKGID'] ret_ = "Info sticker: " ret_ += "\nID STICKER : {}".format(stk_id) ret_ += "\nLINK STICKER : line://shop/detail/{}".format( pkg_id) ret_ += "\nPsdbots v1.55" Hans.sendMessage(to, str(ret_)) elif msg.contentType == 13: if settings["copy"] == True: _name = msg.contentMetadata["displayName"] copy = msg.contentMetadata["mid"] groups = Hans.getGroup(msg.to) targets = [] for s in groups.members: if _name in s.displayName: print("[Target] Copy") break else: targets.append(copy) if targets == []: Hans.sendText(msg.to, "Target, not found") pass else: for target in targets: try: Hans.cloneContactProfile(target) Hans.sendMessage(msg.to, "Done copy contact") settings['copy'] = False break except: msg.contentMetadata = {'mid': target} settings["copy"] = False break if op.type == 26: print("PENSAN TELAH DI TERIMA!!!") msg = op.message text = msg.text msg_id = msg.id receiver = msg.to sender = msg._from if msg.toType == 0: if sender != Hans.profile.mid: to = sender else: to = receiver else: to = receiver if settings["autoRead"] == True: Hans.sendChatChecked(to, msg_id) if to in read["readPoint"]: if sender not in read["ROM"][to]: read["ROM"][to][sender] = True if sender in settings["mimic"]["target"] and settings["mimic"][ "status"] == True and settings["mimic"]["target"][ sender] == True: text = msg.text if text is not None: Hans.sendMessage(msg.to, text) if msg.contentType == 0 and sender not in HansMID and msg.toType == 2: if 'MENTION' in msg.contentMetadata.keys() != None: names = re.findall(r'@(\w+)', text) mention = ast.literal_eval( msg.contentMetadata['MENTION']) mentionees = mention['MENTIONEES'] lists = [] for mention in mentionees: if HansMID in mention["M"]: if settings["detectMention"] == True: contact = Hans.getContact(sender) Hans.sendMessage(to, "sundala nu") sendMessageWithMention(to, contact.mid) break if op.type == 55: print("PESAN TELAH DI BACA!!!") try: if op.param1 in read['readPoint']: if op.param2 in read['readMember'][op.param1]: pass else: read['readMember'][op.param1] += op.param2 read['ROM'][op.param1][op.param2] = op.param2 backupData() else: pass except: pass except Exception as error: logError(error)
def human_number(value, decimals=0): return humanfriendly.format_number(value, num_decimals=decimals)
def print_time_report(time: float, num: int): logging.info("Processed: {0} / Took: {1} / {2} TPS".format( humanfriendly.format_number(num), humanfriendly.format_timespan(time), humanfriendly.format_number(num / time, 3)))
def print_formatted_number(value): """Print large numbers in a human readable format.""" output(format_number(float(value)))
def lineBot(op): try: #=================================================================# if op.type == 0: print("DONE") return #=================================================================# if op.type == 5: print("通知 : 加入好友") if settings["autoAdd"] == True: boteater.sendMessage( op.param1, "=== 尹莫測試 V1.0 === \n嘿嘿! {} 恭喜您成為白老鼠".format( str(boteater.getContact(op.param1).displayName))) #=================================================================# if op.type == 13: print("通知 : 加入群組") group = boteater.getGroup(op.param1) if settings["autoJoin"] == True: boteater.acceptGroupInvitation(op.param1) #=================================================================# if op.type == 24: print("通知 : 離開副本") if settings["autoLeave"] == True: boteater.leaveRoom(op.param1) #=================================================================# if op.type == 25: print("通知 : 傳送訊息") msg = op.message text = msg.text msg_id = msg.id receiver = msg.to sender = msg._from if msg.toType == 0: if sender != boteater.profile.mid: to = sender else: to = receiver else: to = receiver if msg.contentType == 0: #=================================================================# #=================================================================# if text is None: return #=================================================================# #=================================================================# if text.lower() == 'help': boteater.sendMessage( to, "=== SELFBOT V.1 === \nbotmenu \nsetting \nselfmenu \ngrupmenu \nmedia \ntokenlist \nanimenew \nanimelist" ) if text.lower() == 'tokenlist': boteater.sendMessage( to, "=== SELFBOT V.1 === \ntoken mac \ntoken ios \ntoken chrome \ntoken win10 \ntoken desktop \ntoken done" ) elif text.lower() == 'botmenu': boteater.sendMessage( to, "=== SELFBOT V.1 === \nrestart \nspeed \nstatus \nabout \nruntime \nerrorlog" ) elif text.lower() == 'setting': boteater.sendMessage( to, "=== SELFBOT V.1 === \nautoadd(on/off) \nautoread(on/off) \nautojoin(on/off) \nautoleave(on/off) \nautochecksticker(on/off) \ndetectmention(on/off)" ) elif text.lower() == 'selfmenu': boteater.sendMessage( to, "=== SELFBOT V.1 === \nme \nmymid \nmypicture \nmyvideo \nmycover \nstealcontact(mention) \nstealmid(mention) \nstealbio(mention) \nstealpicture(mention) \nstealvideoprofile(mention) \nstealcover(mention) \ncloneprofile(mention) \nrestoreprofile \nmention" ) elif text.lower() == 'grupmenu': boteater.sendMessage( to, "=== SELFBOT V.1 === \ngcreator \ngpicture \nglink \nqr(on/off) \nglist \ngmember \nginfo \ncrash" ) elif text.lower() == 'media': boteater.sendMessage( to, "=== SELFBOT V.1 === \ninstagraminfo(username) \ninstagrampost(username) \nyoutubes(keyword) \nimage(keyword) \nssweb(link)" ) #=================================================================# ### BOT MENU COMMAND ### #=================================================================# #=================================================================# elif text.lower() == 'speed': start = time.time() boteater.sendMessage(to, "█▒▒▒▒▒▒▒▒▒...") elapsed_time = time.time() - start boteater.sendMessage(to, format(str(elapsed_time))) elif text.lower() == 'restart': boteater.sendMessage(to, "正在重啟...") time.sleep(5) boteater.sendMessage(to, "系統載入完畢") restartBot() elif text.lower() == 'errorlog': with open('error.txt', 'r') as er: error = er.read() boteater.sendMessage(to, str(error)) elif text.lower() == 'runtime': timeNow = time.time() runtime = timeNow - botStart runtime = format_timespan(runtime) boteater.sendMessage(to, "系統已運行 \n {}".format(str(runtime))) elif text.lower() == 'about': try: arr = [] saya = "MIDMU" creator = boteater.getContact(saya) ret_ = ">>> 關於本機 <<<" ret_ += "\n PYTHON 3 測試版 V1.0" ret_ += "\n此為公開型機器" ret_ += "\n作者 : {}".format(creator.displayName) boteater.sendMessage(to, str(ret_)) except Exception as e: boteater.sendMessage(msg.to, str(e)) elif text.lower() == 'status': try: ret_ = " >>> 本機狀態 <<<" if settings["autoAdd"] == True: ret_ += "\n自動加入好友✔" else: ret_ += "\n自動加入好友✘" if settings["autoJoin"] == True: ret_ += "\n自動進群✔" else: ret_ += "\n自動進群✘" if settings["autoLeave"] == True: ret_ += "\n離開副本✔" else: ret_ += "\n離開副本✘" if settings["autoRead"] == True: ret_ += "\n自動已讀✔" else: ret_ += "\n自動已讀✘" if settings["autochecksticker"] == True: ret_ += "\n鑑定貼圖✔" else: ret_ += "\n鑑定貼圖✘" if settings["detectMention"] == True: ret_ += "\n標註回覆✔" else: ret_ += "\n標註回覆✘" ret_ += " " boteater.sendMessage(to, str(ret_)) except Exception as e: boteater.sendMessage(msg.to, str(e)) elif text.lower() == 'autoadd on': settings["autoAdd"] = True boteater.sendMessage(to, "自動加入好友✔") elif text.lower() == 'autoadd off': settings["autoAdd"] = False boteater.sendMessage(to, "自動加入好友✘") elif text.lower() == 'autojoin on': settings["autoJoin"] = True boteater.sendMessage(to, "自動進群✔") elif text.lower() == 'autojoin off': settings["autoJoin"] = False boteater.sendMessage(to, "自動進群✘") elif text.lower() == 'autoleave on': settings["autoLeave"] = True boteater.sendMessage(to, "離開副本✔") elif text.lower() == 'autoleave off': settings["autoLeave"] = False boteater.sendMessage(to, "離開副本✘") elif text.lower() == 'autoread on': settings["autoRead"] = True boteater.sendMessage(to, "自動已讀✔") elif text.lower() == 'autoread off': settings["autoRead"] = False boteater.sendMessage(to, "自動已讀✘") elif text.lower() == 'autochecksticker on': settings["autochecksticker"] = True boteater.sendMessage(to, "鑑定貼圖✔") elif text.lower() == 'autochecksticker off': settings["autochecksticker"] = False boteater.sendMessage(to, "鑑定貼圖✘") elif text.lower() == 'detectmention on': settings["datectMention"] = True boteater.sendMessage(to, "標註回覆✔") elif text.lower() == 'detectmention off': settings["datectMention"] = False boteater.sendMessage(to, "標註回覆✘") elif text.lower() == 'clonecontact': settings["copy"] = True boteater.sendMessage(to, "請傳送友資以模仿") #=================================================================# ### SELFBOT COMMAND ### #=================================================================# elif text.lower() == 'me': sendMessageWithMention(to, boteaterMID) boteater.sendContact(to, boteaterMID) elif text.lower() == 'mymid': boteater.sendMessage(msg.to, "MID : " + msg.from_) elif text.lower() == 'mypicture': me = boteater.getContact(boteaterMID) boteater.sendImageWithURL( msg.to, "http://dl.profile.line-cdn.net/" + me.pictureStatus) elif text.lower() == 'myvideo': me = boteater.getContact(boteaterMID) boteater.sendVideoWithURL( msg.to, "http://dl.profile.line-cdn.net/" + me.pictureStatus + "/vp") elif text.lower() == 'mycover': me = boteater.getContact(boteaterMID) cover = boteater.getProfileCoverURL(boteaterMID) boteater.sendImageWithURL(msg.to, cover) elif msg.text.lower().startswith("stealcontact "): if 'MENTION' in msg.contentMetadata.keys() != None: names = re.findall(r'@(\w+)', text) mention = ast.literal_eval( msg.contentMetadata['MENTION']) mentionees = mention['MENTIONEES'] lists = [] for mention in mentionees: if mention["M"] not in lists: lists.append(mention["M"]) for ls in lists: contact = boteater.getContact(ls) mi_d = contact.mid boteater.sendContact(msg.to, mi_d) elif msg.text.lower().startswith("stealmid "): if 'MENTION' in msg.contentMetadata.keys() != None: names = re.findall(r'@(\w+)', text) mention = ast.literal_eval( msg.contentMetadata['MENTION']) mentionees = mention['MENTIONEES'] lists = [] for mention in mentionees: if mention["M"] not in lists: lists.append(mention["M"]) ret_ = "此人MID : " for ls in lists: ret_ += "\n{}" + ls boteater.sendMessage(msg.to, str(ret_)) elif msg.text.lower().startswith("stealname "): if 'MENTION' in msg.contentMetadata.keys() != None: names = re.findall(r'@(\w+)', text) mention = ast.literal_eval( msg.contentMetadata['MENTION']) mentionees = mention['MENTIONEES'] lists = [] for mention in mentionees: if mention["M"] not in lists: lists.append(mention["M"]) for ls in lists: contact = boteater.getContact(ls) boteater.sendMessage( msg.to, "此人名字 : \n" + contact.displayName) elif msg.text.lower().startswith("stealbio "): if 'MENTION' in msg.contentMetadata.keys() != None: names = re.findall(r'@(\w+)', text) mention = ast.literal_eval( msg.contentMetadata['MENTION']) mentionees = mention['MENTIONEES'] lists = [] for mention in mentionees: if mention["M"] not in lists: lists.append(mention["M"]) for ls in lists: contact = boteater.getContact(ls) boteater.sendMessage( msg.to, "此人各簽 : \n{}" + contact.statusMessage) elif msg.text.lower().startswith("stealpicture "): if 'MENTION' in msg.contentMetadata.keys() != None: names = re.findall(r'@(\w+)', text) mention = ast.literal_eval( msg.contentMetadata['MENTION']) mentionees = mention['MENTIONEES'] lists = [] for mention in mentionees: if mention["M"] not in lists: lists.append(mention["M"]) for ls in lists: path = "http://dl.profile.line.naver.jp/" + boteater.getContact( ls).pictureStatus boteater.sendImageWithURL(msg.to, str(path)) elif msg.text.lower().startswith("stealvideoprofile "): if 'MENTION' in msg.contentMetadata.keys() != None: names = re.findall(r'@(\w+)', text) mention = ast.literal_eval( msg.contentMetadata['MENTION']) mentionees = mention['MENTIONEES'] lists = [] for mention in mentionees: if mention["M"] not in lists: lists.append(mention["M"]) for ls in lists: path = "http://dl.profile.line.naver.jp/" + boteater.getContact( ls).pictureStatus + "/vp" boteater.sendImageWithURL(msg.to, str(path)) elif msg.text.lower().startswith("stealcover "): if line != None: if 'MENTION' in msg.contentMetadata.keys() != None: names = re.findall(r'@(\w+)', text) mention = ast.literal_eval( msg.contentMetadata['MENTION']) mentionees = mention['MENTIONEES'] lists = [] for mention in mentionees: if mention["M"] not in lists: lists.append(mention["M"]) for ls in lists: path = boteater.getProfileCoverURL(ls) boteater.sendImageWithURL(msg.to, str(path)) elif msg.text.lower().startswith("cloneprofile "): if 'MENTION' in msg.contentMetadata.keys() != None: names = re.findall(r'@(\w+)', text) mention = ast.literal_eval( msg.contentMetadata['MENTION']) mentionees = mention['MENTIONEES'] for mention in mentionees: contact = mention["M"] break try: boteater.cloneContactProfile(contact) boteater.sendMessage(msg.to, "寶貝我愛你") except: boteater.sendMessage(msg.to, "不要!他好醜") elif text.lower() == 'restoreprofile': try: boteaterProfile.displayName = str( myProfile["displayName"]) boteaterProfile.statusMessage = str( myProfile["statusMessage"]) boteaterProfile.pictureStatus = str( myProfile["pictureStatus"]) boteater.updateProfileAttribute( 8, boteaterProfile.pictureStatus) boteater.updateProfile(boteaterProfile) boteater.sendMessage(msg.to, "寶貝我不愛妳了") except: boteater.sendMessage(msg.to, "拉機換不回去==") #=================================================================# #=======### GROUP COMMAND ### #=================================================================# elif text.lower() == 'crash': boteater.sendContact( to, "ub621484bd88d2486744123db00551d5e',") elif text.lower() == 'gcreator': group = boteater.getGroup(to) GS = group.creator.mid boteater.sendContact(to, GS) elif text.lower() == 'gpicture': group = boteater.getGroup(to) path = "http://dl.profile.line-cdn.net/" + group.pictureStatus boteater.sendImageWithURL(to, path) elif text.lower() == 'glink': if msg.toType == 2: group = boteater.getGroup(to) if group.preventedJoinByTicket == False: link = boteater.reissueGroupTicket(to) boteater.sendMessage( to, ">> 群組網址 <<<\nhttps://line.me/R/ti/g/{}". format(str(link))) else: boteater.sendMessage(to, "請先開啟群組網址") elif text.lower() == 'qr on': if msg.toType == 2: group = boteater.getGroup(to) if group.preventedJoinByTicket == False: boteater.sendMessage(to, "群組網址已開啟") else: group.preventedJoinByTicket = False boteater.updateGroup(group) boteater.sendMessage(to, "群組網址已經是開啟的") elif text.lower() == 'qr off': if msg.toType == 2: group = boteater.getGroup(to) if group.preventedJoinByTicket == True: boteater.sendMessage(to, "群組網址已關閉") else: group.preventedJoinByTicket = True boteater.updateGroup(group) boteater.sendMessage(to, "群組網址已經是關閉的") elif text.lower() == 'ginfo': group = boteater.getGroup(to) try: gCreator = group.creator.displayName except: gCreator = "不明(已砍帳)" if group.preventedJoinByTicket == True: gQr = "關閉" gTicket = "不開放" else: gQr = "開放" gTicket = "https://line.me/R/ti/g/{}".format( str(boteater.reissueglink(group.id))) path = "http://dl.profile.line-cdn.net/" + group.pictureStatus ret_ = ">>> 群組資訊 <<<" ret_ += "\n群組名稱 : {}".format(str(group.name)) ret_ += "\n創群者 : {}".format(str(gCreator)) ret_ += "\n群組人數 : {}".format(str(len(group.members))) ret_ += "\n網址狀態 : {}".format(gQr) ret_ += "\n群組網址 : {}".format(gTicket) boteater.sendMessage(to, str(ret_)) boteater.sendImageWithURL(to, path) elif text.lower() == 'gmember': if msg.toType == 2: group = boteater.getGroup(to) ret_ = ">>> 都是智障 <<<" no = 0 + 1 for mem in group.members: ret_ += "\n{}. {}".format(str(no), str(mem.displayName)) no += 1 ret_ += "\n總共: \n{}".format(str(len(group.members))) boteater.sendMessage(to, str(ret_)) elif text.lower() == 'glist': groups = boteater.groups ret_ = ">>> 群組列表 <<<" no = 0 + 1 for gid in groups: group = boteater.getGroup(gid) ret_ += "\n{}. {} | {}".format(str(no), str(group.name), str(len(group.members))) no += 1 ret_ += "\n總共 : \n{}".format(str(len(groups))) boteater.sendMessage(to, str(ret_)) elif text.lower() == 'mention': group = boteater.getGroup(msg.to) nama = [contact.mid for contact in group.members] k = len(nama) // 20 for a in range(k + 1): txt = u'' s = 0 b = [] for i in group.members[a * 20:(a + 1) * 20]: b.append({ "S": str(s), "E": str(s + 6), "M": i.mid }) s += 7 txt += u' ' boteater.sendMessage(to, text=txt, contentMetadata={ u'MENTION': json.dumps({'MENTIONEES': b}) }, contentType=0) boteater.sendMessage( to, "總共標註 : \n{}".format(str(len(nama)))) #=================================================================# ###ELIF COMMAND### #=================================================================# elif text.lower() == 'kalender': tz = pytz.timezone("Asia/Taipei") timeNow = datetime.now(tz=tz) day = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ] hari = [ "Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu" ] bulan = [ "Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember" ] hr = timeNow.strftime("%A") bln = timeNow.strftime("%m") for i in range(len(day)): if hr == day[i]: hasil = hari[i] for k in range(0, len(bulan)): if bln == str(k): bln = bulan[k - 1] readTime = hasil + ", " + timeNow.strftime( '%d') + " - " + bln + " - " + timeNow.strftime( '%Y') + "\n時間 : [ " + timeNow.strftime( '%H:%M:%S') + " ]" boteater.sendMessage(msg.to, readTime) elif "ssweb" in msg.text.lower(): sep = text.split(" ") query = text.replace(sep[0] + " ", "") with requests.session() as web: r = web.get( "http://rahandiapi.herokuapp.com/sswebAPI?key=betakey&link={}" .format(urllib.parse.quote(query))) data = r.text data = json.loads(data) boteater.sendImageWithURL(to, data["result"]) elif "instagraminfo" in msg.text.lower(): sep = text.split(" ") search = text.replace(sep[0] + " ", "") with requests.session() as web: web.headers["User-Agent"] = random.choice( settings["userAgent"]) r = web.get( "https://www.instagram.com/{}/?__a=1".format( search)) try: data = json.loads(r.text) ret_ = (">>> IG 查詢結果 {} <<<".format(search)) ret_ += "\n名字 : {}".format( str(data["user"]["full_name"])) ret_ += "\n使用者名稱 : {}".format( str(data["user"]["username"])) ret_ += "\n狀態消息 : {}".format( str(data["user"]["biography"])) ret_ += "\n追蹤者 : {}".format( format_number( data["user"]["followed_by"]["count"])) ret_ += "\n追蹤中 : {}".format( format_number( data["user"]["follows"]["count"])) if data["user"]["is_verified"] == True: ret_ += "\n驗證 : 商業" else: ret_ += "\n驗證 : 一般" if data["user"]["is_private"] == True: ret_ += "\n帳號 : 私人" else: ret_ += "\n帳號 : 公開" ret_ += "\n貼文數量 : {}".format( format_number(data["user"]["media"]["count"])) ret_ += "\n追蹤連結 : https://www.instagram.com/{} ]".format( search) path = data["user"]["profile_pic_url_hd"] boteater.sendImageWithURL(to, str(path)) boteater.sendMessage(to, str(ret_)) except: boteater.sendMessage(to, "查詢不到與此相關的使用者") elif "instagrampost" in msg.text.lower(): separate = msg.text.split(" ") user = msg.text.replace(separate[0] + " ", "") profile = "https://www.instagram.com/" + user with requests.session() as x: x.headers['user-agent'] = 'Mozilla/5.0' end_cursor = '' for count in range(1, 999): print('PAGE: ', count) r = x.get(profile, params={'max_id': end_cursor}) data = re.search( r'window._sharedData = (\{.+?});</script>', r.text).group(1) j = json.loads(data) for node in j['entry_data']['ProfilePage'][0][ 'user']['media']['nodes']: if node['is_video']: page = 'https://www.instagram.com/p/' + node[ 'code'] r = x.get(page) url = re.search(r'"video_url": "([^"]+)"', r.text).group(1) print(url) boteater.sendVideoWithURL(msg.to, url) else: print(node['display_src']) boteater.sendImageWithURL( msg.to, node['display_src']) end_cursor = re.search(r'"end_cursor": "([^"]+)"', r.text).group(1) elif "image " in msg.text.lower(): separate = msg.text.split(" ") search = msg.text.replace(separate[0] + " ", "") with requests.session() as web: web.headers["User-Agent"] = random.choice( settings["userAgent"]) r = web.get( "http://rahandiapi.herokuapp.com/imageapi?key=betakey&q={}" .format(urllib.parse.quote(search))) data = r.text data = json.loads(data) if data["result"] != []: items = data["result"] path = random.choice(items) a = items.index(path) b = len(items) boteater.sendImageWithURL(to, str(path)) elif "youtubes" in msg.text.lower(): sep = text.split(" ") search = text.replace(sep[0] + " ", "") params = {"search_query": search} with requests.session() as web: web.headers["User-Agent"] = random.choice( settings["userAgent"]) r = web.get("https://www.youtube.com/results", params=params) soup = BeautifulSoup(r.content, "html5lib") ret_ = ">>> YOUTUBE 搜尋結果 <<<" datas = [] for data in soup.select(".yt-lockup-title > a[title]"): if "&lists" not in data["href"]: datas.append(data) for data in datas: ret_ += "\n影片標題 : {} ".format(str(data["title"])) ret_ += "\n觀賞連結 : https://www.youtube.com{}".format( str(data["href"])) boteater.sendMessage(to, str(ret_)) #=================================================================# #######################MEDIA############################# #=================================================================# elif text.lower() == 'animelist': data = {'submit2': ''} r = requests.post(url='https://boteater.com/anime/', data=data) qr = r.text os.system('rm {}.txt'.format(msg._from)) urllib.request.urlretrieve( 'http://149.28.137.54/animelist.json', '{}.txt'.format(msg._from)) links = [] juduls = [] if r.status_code == 404: boteater.sendMessage(msg.to, 'FAIL!!!') else: j = json.loads(qr) for p in j['result']: juduls.append(p['judul']) links.append(p['link']) h = ('>>ANIME LIST<<') number = 1 try: for numx in range(1000): xx = juduls[numx] h += ('\n{}. {}'.format(numx, xx)) number += 1 except: boteater.sendMessage(msg.to, h) boteater.sendMessage( msg.to, 'PLEASE TYPE = EPPLIST [NUMBER]') if text.lower() == 'animenew': data = {'submit1': ''} r = requests.post(url='https://boteater.com/anime/', data=data) qr = r.text os.system('rm {}.txt'.format(msg._from)) urllib.request.urlretrieve( 'http://149.28.137.54/animebaru.json', '{}.txt'.format(msg._from)) links = [] juduls = [] if r.status_code == 404: boteater.sendMessage(msg.to, 'FAIL!!!') else: j = json.loads(qr) for p in j['result']: juduls.append(p['judul']) links.append(p['link']) h = ('>>ANIME LIST<<') number = 1 try: for numx in range(1000): xx = juduls[numx] h += ('\n{}. {}'.format(numx, xx)) number += 1 except: boteater.sendMessage(msg.to, h) boteater.sendMessage( msg.to, 'PLEASE TYPE = STREAMEPPZ [NUMBER]') elif "epplist " in msg.text.lower(): separate = msg.text.split(" ") numf = msg.text.replace(separate[0] + " ", "") numzz = int(numf) numz = numzz with open('{}.txt'.format(msg._from), 'r') as f: qr = f.read() j = json.loads(qr) juduls = [] links = [] for p in j['result']: juduls.append(p['judul']) links.append(p['link']) xx = links[numz] xxx = juduls[numz] data = {'link2': '{}'.format(xx), 'submit4': ''} r = requests.post(url='https://boteater.com/anime/', data=data) qr = r.text f = open('{}.txt'.format(msg._from), 'w') f.write(qr) f.close() links = [] juduls = [] if r.status_code == 404: boteater.sendMessage( msg.to, 'FAIL!!! SELECT YOUR ANIME FIRST!!!') else: j = json.loads(qr) for p in j['result']: juduls.append(p['epp']) links.append(p['link']) h = ('>>EPISODE LIST LIST<< \n>>{}<<'.format(xxx)) number = 1 try: for numx in range(1000): zzz = juduls[numx] h += ('\n{}. {}'.format(numx, zzz)) number += 1 except: boteater.sendMessage(msg.to, h) boteater.sendMessage( msg.to, 'PLEASE TYPE = STREAMEPP [NUMBER]') if juduls in ["", "\n", " ", None]: boteater.sendMessage( msg.to, 'LINK ANIME IS DIED!!') elif "streamepp " in msg.text.lower(): separate = msg.text.split(" ") numf = msg.text.replace(separate[0] + " ", "") numzz = int(numf) numz = numzz with open('{}.txt'.format(msg._from), 'r') as f: qr = f.read() j = json.loads(qr) juduls = [] links = [] for p in j['result']: juduls.append(p['epp']) links.append(p['link']) xx = links[numz] xxx = juduls[numz] data = {'link1': '{}'.format(xx), 'submit3': ''} r = requests.post(url='https://boteater.com/anime/', data=data) link = r.text boteater.sendMessage( msg.to, ">> STREAM ANIME<< \n>> {} << \n{}".format( xxx, link)) elif "streameppz " in msg.text.lower(): separate = msg.text.split(" ") numf = msg.text.replace(separate[0] + " ", "") numzz = int(numf) numz = numzz with open('{}.txt'.format(msg._from), 'r') as f: qr = f.read() j = json.loads(qr) juduls = [] links = [] for p in j['result']: juduls.append(p['judul']) links.append(p['link']) xx = links[numz] xxx = juduls[numz] data = {'link1': '{}'.format(xx), 'submit3': ''} r = requests.post(url='https://boteater.com/anime/', data=data) link = r.text boteater.sendMessage( msg.to, ">> STREAM ANIME<< \n>> {} << \n{}".format( xxx, link)) #=================================================================# # LOGIN TOKEN. #=================================================================# elif text.lower() == 'token mac': data = {'nama': '{}'.format(msg._from), 'submit4': ''} post_response = requests.post( url='https://boteater.com/sniff/', data=data) qr = post_response.text boteater.sendMessage(msg.to, '{}'.format(qr)) elif text.lower() == 'token win10': data = {'nama': '{}'.format(msg._from), 'submit3': ''} post_response = requests.post( url='https://boteater.com/sniff/', data=data) qr = post_response.text boteater.sendMessage(msg.to, '{}'.format(qr)) elif text.lower() == 'token ios': data = {'nama': '{}'.format(msg._from), 'submit2': ''} post_response = requests.post( url='https://boteater.com/sniff/', data=data) qr = post_response.text boteater.sendMessage(msg.to, '{}'.format(qr)) elif text.lower() == 'token chrome': data = {'nama': '{}'.format(msg._from), 'submit1': ''} post_response = requests.post( url='https://boteater.com/sniff/', data=data) qr = post_response.text boteater.sendMessage(msg.to, '{}'.format(qr)) elif text.lower() == 'token desktop': data = {'nama': '{}'.format(msg._from), 'submit7': ''} post_response = requests.post( url='https://boteater.com/sniff/', data=data) qr = post_response.text boteater.sendMessage(msg.to, '{}'.format(qr)) elif text.lower() == 'token done': data = {'nama': '{}'.format(msg._from), 'submit5': ''} post_response = requests.post( url='https://boteater.com/sniff/', data=data) qr = post_response.text boteater.sendMessage(to, "TOKEN已經由私聊傳送") boteater.sendMessage(msg.to, '{}'.format(qr)) #=================================================================# #=================================================================# #=================================================================# elif msg.contentType == 7: if settings["autochecksticker"] == True: stk_id = msg.contentMetadata['STKID'] stk_ver = msg.contentMetadata['STKVER'] pkg_id = msg.contentMetadata['STKPKGID'] ret_ = ">>> 貼圖資訊 <<<" ret_ += "\n貼圖ID : {}".format(stk_id) ret_ += "\n貼圖連結 : line://shop/detail/{}".format(pkg_id) ret_ += "\n>>鑑定完畢<<" boteater.sendMessage(to, str(ret_)) elif msg.contentType == 13: if settings["copy"] == True: _name = msg.contentMetadata["displayName"] copy = msg.contentMetadata["mid"] groups = boteater.getGroup(msg.to) targets = [] for s in groups.members: if _name in s.displayName: print("[Target] Copy") break else: targets.append(copy) if targets == []: boteater.sendText(msg.to, "沒有可複製對象") pass else: for target in targets: try: boteater.cloneContactProfile(target) boteater.sendMessage(msg.to, "成功複製目標") settings['copy'] = False break except: msg.contentMetadata = {'mid': target} settings["copy"] = False break #=================================================================# #=================================================================# #=================================================================# #=================================================================# if op.type == 26: print("通知:收到訊息") msg = op.message text = msg.text msg_id = msg.id receiver = msg.to sender = msg._from if msg.toType == 0: if sender != boteater.profile.mid: to = sender else: to = receiver else: to = receiver if settings["autoRead"] == True: boteater.sendChatChecked(to, msg_id) if to in read["readPoint"]: if sender not in read["ROM"][to]: read["ROM"][to][sender] = True if sender in settings["mimic"]["target"] and settings["mimic"][ "status"] == True and settings["mimic"]["target"][ sender] == True: text = msg.text if text is not None: boteater.sendMessage(msg.to, text) if msg.contentType == 0 and sender not in boteaterMID and msg.toType == 2: if 'MENTION' in msg.contentMetadata.keys() != None: names = re.findall(r'@(\w+)', text) mention = ast.literal_eval( msg.contentMetadata['MENTION']) mentionees = mention['MENTIONEES'] lists = [] for mention in mentionees: if boteaterMID in mention["M"]: if settings["detectMention"] == True: contact = boteater.getContact(sender) boteater.sendMessage(to, "sundala nu") sendMessageWithMention(to, contact.mid) break #=================================================================# #=================================================================# if op.type == 55: print("通知:已讀訊息") try: if op.param1 in read['readPoint']: if op.param2 in read['readMember'][op.param1]: pass else: read['readMember'][op.param1] += op.param2 read['ROM'][op.param1][op.param2] = op.param2 backupData() else: pass except: pass except Exception as error: logError(error)