Created
December 21, 2016 05:26
-
-
Save NMelis/cc177ffdf66882c43f0b8760855aa28f to your computer and use it in GitHub Desktop.
botMobi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from grab import Grab | |
import re | |
class Connect: | |
__login = '' # Логин | |
__password = '' # Пароль | |
__site = '' # Сайт с которого играет пользователь | |
# Статистика | |
__user_nik = '' # Никнейм | |
__user_lvl = 0 # Уровень | |
__user_floor = 0 # Этажи игрока | |
__user_coin = 0 # Монеты | |
__user_dollar = 0 # Баксы | |
__user_exp = '' # Опыт пользователя | |
__user_percent_exp = 0 # Собранные опыт пользователя в процентах | |
__user_total_percent_epx = 0 # - | |
__user_exp_city = 0 # Опыт игрока в городе | |
__user_days_in_city = 0 # Дней в городе | |
__user_days_in_game = 0 # Дней в игре | |
__user_contributed_coin_in_city = 0 # Внесеные МОНЕТ в бюджет города | |
__user_contributed_dollar_in_city = 0 # Внесеные БАКСЫ в бюджет города | |
__user_city = '' # Название города игрока | |
__user_city_position = '' # Должность/Позиция игрока в городе | |
__user_happy_employees = 0 # Счастливые работник игрока | |
__user_specialists = 0 # Работники ->Специалисты | |
__user_total_personnel = 0 # Общий количество работников игрока | |
__user_Equipment = 0 # Количество техник у игрока | |
__operating_profit = 0 # Текущая выручка | |
__user_record_profit = 0 # Рекорд выручки | |
__user_gifts = 0 # Подарок пользователя | |
# Лабиринт | |
__user_door_key = 0 | |
__user_where_doors = '' | |
# Гостиница | |
__user_popel_in_hotel = 0 # Люди в госитинце | |
__user_popel_empty_seats = 0 # Свободные места | |
__user_total_count_popel = 0 # Оющий количество мест в гостинице | |
def __init__(self, login, password, site): | |
self.__login = login | |
self.__password = password | |
self.__site = site | |
global g | |
g = Grab(timeout=10, connect_timeout=13) | |
def connecting(self): | |
if self.__site == 'nebo.mobi': | |
g.go('nebo.mobi/login') | |
g.doc.set_input('login', self.__login) | |
g.doc.set_input('password', self.__password) | |
g.doc.submit() | |
g.doc.select('//div[@class="cntr"]/span/span[1]/span/span').text() | |
self.__get_statistics() | |
def isint(self, b): | |
count = '' | |
res = re.findall('(\d+)', b) | |
for i in res: | |
count = count + i | |
return int(count) | |
def get_nik(self): | |
print(self.user_nik) | |
print(self.user_coin) | |
print(self.user_dollar) | |
print(self.user_floor) | |
print(self.user_city) | |
print(self.user_city_position) | |
print(self.user_exp) | |
print('Ключ: ', self.__user_door_key) | |
print(self.__user_where_doors) | |
print('Заcелены люди: ', self.__user_popel_in_hotel, "Осталось мест в гостинице: ", self.__user_popel_empty_seats, " общий место в гостинице: ", self.__user_total_count_popel) | |
def run_lifts(self): | |
g.go('/lift') | |
gs = g.doc.select('//div/span[@class="white"]').number() | |
if gs == 0: | |
print('Ваш чудо скрип позднее все сделал и сейчас это не требуется так как нету Посетителей в лифте') | |
else: | |
while True: | |
g.go('/lift/wicket:interface/:90:liftState:upLink::ILinkListener::') | |
assert isinstance(g.doc.select, object) | |
gn = g.doc.select('//span[@class="ctrl"]/b').text() | |
if gn == "Спасибо!": | |
self.run_chai() | |
else: | |
g.go('/lift/wicket:interface/:90:liftState:upLink::ILinkListener::') | |
gn = g.doc.select('//span[@class="ttl"]/b').text() | |
if gn == "Главная": | |
gn = 'Конец' | |
print('Ваша чудо БОТ который вы написали с нуля исправился на твердую 5') | |
break | |
def run_procure(self): | |
def res(i, n): | |
result = re.search(i, n) | |
return result.group(0) == i | |
g.go('/floors/0/2') | |
if (g.doc.select('/html/head/title').text() == 'Можно закупить товар') and g.doc.select( | |
'/html/body/div/div[5]/ul/li[1]/div/div/div[1]/span/a').text() == 'Закупить товар': | |
count_empty = g.doc.select('/html/body/div/div[1]/div/span[1]/b').number() | |
user_otvet = input('На ' + str(count_empty) + ': Этажие нужно закупить товар - начинать? [Да/Нет]: ') | |
user_ot = int(input('Какие покупать - Самые дешевые или Самые Дорогие товары? --> [1|2|3]? ')) | |
if user_otvet == 'Да': | |
while True: | |
if g.doc.select('/html/head/title').text() == 'Небоскребы: онлайн игра': | |
print('Who') | |
break | |
else: | |
gn = g.doc.select('/html/body/div/div[5]/ul/li[1]/div/div/div[1]/span/a/@href').text() | |
g.go(gn) | |
if user_ot == 1: | |
print('jpen 1') | |
print(g.doc.select('//title').text()) | |
rel = g.doc.select('/html/body/div/div[4]/div/ul[1]/li[1]').text() | |
print(res('Закупить', rel)) | |
elif user_ot == 2: | |
print('jpen 2') | |
print(g.doc.select('//title').text()) | |
rel = g.doc.select('/html/body/div/div[4]/div/ul[1]/li[2]').text() | |
print(res('Закупить', rel)) | |
elif user_ot == 3: | |
print('jpen 3') | |
print(g.doc.select('//title').text()) | |
rel = g.doc.select('/html/body/div/div[4]/div/ul[1]/li[3]').text() | |
print(res('Закупить', rel)) | |
break | |
else: | |
print('Ну как хочешь') | |
def run_cargo(self): | |
g.go('/floors/0/3') | |
if (g.doc.select('/html/head/title').text() == 'Товар доставлен!'): | |
if g.doc.select('/html/body/div/div[5]/ul/li[1]/div/div/div[1]/span/a').text() == 'Выложить товар': | |
count_empty = g.doc.select('/html/body/div/div[1]/div/span[1]/b').number() | |
user_otvet = input('На ' + str(count_empty) + ': Этажие нужно выложить товар - начинать? [Да/Нет]: ') | |
if user_otvet == 'Да': | |
while True: | |
if count_empty >= 1: | |
gn = g.doc.select('/html/body/div/div[5]/ul/li[1]/div/div/div[1]/span/a/@href').text() | |
g.go(gn) | |
count_empty -= 1 | |
print('Осталось: ', count_empty) | |
else: | |
print('Все') | |
break | |
else: | |
print('Ну ок') | |
# print(g.doc.select('/html/body/div/div[5]/ul/li[1]/div/div/div[1]/span/a').text(), '\nНачинааем') | |
else: | |
print('Выручка уже собрана, сечас собирать нечего') | |
def run_empty(self): | |
g.go('/floors/0/5') | |
if g.doc.select('/html/head/title').text() == 'Товар продан!': | |
if g.doc.select('/html/body/div/div[5]/ul/li[1]/div/div/div[1]/span/a').text() == 'Собрать выручку!': | |
count_empty = g.doc.select('/html/body/div/div[1]/div/span[1]/b').number() | |
user_otvet = input('У ' + str(count_empty) + ': Этажи нужно собрать выручки начинать? [Да/Нет]: ') | |
if user_otvet == 'Да': | |
while True: | |
if count_empty >= 1: | |
gn = g.doc.select('/html/body/div/div[5]/ul/li[1]/div/div/div[1]/span/a/@href').text() | |
g.go(gn) | |
count_empty -= 1 | |
print('Осталось: ', count_empty) | |
else: | |
print('Все') | |
break | |
else: | |
print('Ну ок') | |
#print(g.doc.select('/html/body/div/div[5]/ul/li[1]/div/div/div[1]/span/a').text(), '\nНачинааем') | |
else: | |
print('Товары уже выложены, сейчас выгруживать нечего') | |
def run_chai(self): | |
prosran = 0 | |
g.go('/lift/wicket:interface/:143:liftState:tipsLink:link::ILinkListener::') | |
gs = g.doc.select('//html/body/div/div[4]/span').text() | |
if gs == '': | |
print('Вот и все В итоги Просран ', prosran, "жителей") | |
elif gs == 'Расширьте гостиницу или освободите место': | |
prosran += 1 | |
else: | |
if g.doc.select('//html/body/div/div[4]/span').number() < 10: | |
print('Посетитель поднят Осталось: ', g.doc.select('//html/body/div/div[4]/span').text(), ' |||||', | |
self.user_nik) | |
else: | |
print('Посетитель поднят Осталось: ', g.doc.select('//html/body/div/div[4]/span').text(), '|||||', | |
self.user_nik) | |
def __get_statistics(self): | |
g.go('/') | |
gn = g.doc.select('//div[@class="ftr"]/a[@class="btn fclr"]/@href').text() | |
g.go(gn) | |
self.user_nik = g.doc.select('//span[@class="user"]/span/span').text() | |
self.user_coin = self.isint(g.doc.select('//span[@class="nwr"]/span/span').text()) | |
self.user_dollar = g.doc.select('//div/span[2]/span[2]/span/span').number() | |
self.user_floor = g.doc.select('//span[@class="flr"]/strong[@class="white"]').number() | |
self.user_city = g.doc.select('//a[@class="white"]/span[@class="amount"]').text() | |
self.user_city_position = g.doc.select('//span[@class="white"]/span').text() | |
self.user_exp = g.doc.select('//div[@class="main"]/div/div[@class="m5"]/span[2]').text() | |
g.go('/quests') | |
self.__user_door_key = g.doc.select('//span[@class="amount flr"]/span').text() | |
g.go('/doors') | |
self.__user_where_doors = g.doc.select('//*[@class="m5"]').text() | |
g.go('/home') | |
self.__user_popel_in_hotel = g.doc.select('//span[@class="rs small"]/span').number() | |
self.__user_popel_empty_seats = g.doc.select('//span[@class="rs small"]/span[2]').number() | |
self.__user_total_count_popel = self.__user_popel_in_hotel + self.__user_popel_empty_seats | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from User import Connect | |
user = Connect('Вадим Дунаев', 'mm1998mm', 'nebo.mobi') | |
user.connecting() | |
user.run_cargo() | |
user.run_empty() | |
user.run_procure() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment