Exemplo n.º 1
0
def get_afk_list(sender=None, msg=None):
    """
    Get afkmover saved client channels. Mainly for debugging.
    """
    if afkMover is not None:
        Bot.send_msg_to_client(bot.ts3conn, sender,
                               str(afkMover.client_channels))
Exemplo n.º 2
0
def test_luskania_danych_z_excela():
    specki = excelDigger.Loader("Specjalizacje.xlsx", ["umiejetnasci"], ["B26"])
    specki = specki.zwroc()
    specki = specki[0]
    assert specki[1][0] == "bron boczna"
    Bot.output("ladowanie z excela dziala")
    return 2
Exemplo n.º 3
0
def check_remaining_candy():
    global candy_remaining
    global machine
    global Transaction_Number
    global max_candy
    Transaction_Number += 1
    with open('var.csv', 'w') as csvfile:
        writer = csv.writer(csvfile,
                            delimiter=',',
                            quotechar='|',
                            quoting=csv.QUOTE_MINIMAL)
        writer.writerow([
            str(Transaction_Number),
            str(candy_remaining), machine,
            str(max_candy)
        ])
    if candy_remaining == 0:
        play_audio('out_of_candy.mp3')
        Bot.alert(machine)
        GPIO.wait_for_edge(10, GPIO.RISING)
        play_audio('candy_refilled.mp3')
        candy_remaining = max_candy
    else:
        candy_remaining -= 1
    with open('var.csv', 'w') as csvfile:
        writer = csv.writer(csvfile,
                            delimiter=',',
                            quotechar='|',
                            quoting=csv.QUOTE_MINIMAL)
        writer.writerow([
            str(Transaction_Number),
            str(candy_remaining), machine,
            str(max_candy)
        ])
Exemplo n.º 4
0
 def zaplac_i_otrzymaj(self, operator):
     if operator.pieniadze >= self.wartosc:
         operator.pieniadze -= self.wartosc
         return self
     Bot.output("nie stać Cię na " + self.nazwa + " brakuje Ci " +
                str(-1 * operator.pieniadze - self.wartosc) + "$")
     return False
Exemplo n.º 5
0
def receive_message():
    if request.method == 'GET':
        """Before allowing people to message your bot, Facebook has implemented a verify token
        that confirms all requests that your bot receives came from Facebook."""
        token_sent = request.args.get("hub.verify_token")
        return verify_fb_token(token_sent)
    #if the request was not get, it must be POST and we can just proceed with sending a message back to user
    else:
        # get whatever message a user sent the bot
        output = request.get_json()
        for event in output['entry']:
            messaging = event['messaging']
            for message in messaging:
                if message.get('message'):
                    #Facebook Messenger ID for user so we know where to send response back to
                    recipient_id = message['sender']['id']
                    if message['message'].get('text'):
                        # print(message['message'].get('text'))
                        response_sent_text = bt.predict(
                            message['message'].get('text'))
                        send_message(recipient_id, response_sent_text)
                    #if user sends us a GIF, photo,video, or any other non-text item
                    if message['message'].get('attachments'):
                        response_sent_nontext = bt.predict("attachments")
                        send_message(recipient_id, response_sent_nontext)
    return "Message Processed"
Exemplo n.º 6
0
def add_quote(sender, msg):
    """
    Add a quote.
    """
    if len(msg) > len("!addQuote "):
        add(msg[len("!addQuote "):])
        Bot.send_msg_to_client(bot.ts3conn, sender, "Quote '" + msg[len("!addQuote "):] + "' was added.")
Exemplo n.º 7
0
def hello_user():
    """
    Page dans laquelle l'utilisateur configure et lance le bot
    Encore en développement
    :return:
    """
    if request.method == 'POST':
        if request.form['submit_button'] == 'go':
            user = []
            passw = []
            order = request.form.getlist('accounts')

            for account in order:
                cred = (db.collection(account).document('credentials')).get()
                user.append(cred.get('email'))
                passw.append(cred.get('password'))
            tasks = db.collection('Tasks').stream()  # recuperation des tâches
            print(order)
            print(user)
            print(passw)
            bot_test = Bot(user, passw, order, int(request.form['retrieve']),
                           tasks)
            # bot_test.vivre()
            notifications = bot_test.getNotificationTwitter()

        elif request.form['submit_button'] == 'stop':
            raise Exception('Arreté prématurement')
        return render_template('hello_user.html', notifications=notifications)
    return render_template('hello_user.html')
Exemplo n.º 8
0
 def wydaj_pieniadze(self, kasa):
     if self.pieniadze - kasa < 0:
         Bot.output("Nie stac Cię!!!!")
         return False
     self.pieniadze -= kasa
     Bot.output(self.imie + " wydał " + str(kasa) + "$. \nPosiada teraz " + str(self.pieniadze) + "$.")
     return True
Exemplo n.º 9
0
 def handle_command(self, msg, sender=0):
     """
     Handle a new command by informing the corresponding handlers.
     :param msg: Command message.
     :param sender: Client id of the sender.
     """
     logger.debug("Handling message " + msg)
     command = msg.split(None, 1)[0]
     if len(command) > 1:
         command = command[1:]
         handlers = self.handlers.get(command)
         ci = ClientInfo.ClientInfo(sender, self.ts3conn)
         handled = False
         if handlers is not None:
             for handler in handlers:
                 if self.check_permission(handler, ci):
                     handled = True
                     handler(sender, msg)
             if not handled:
                 Bot.send_msg_to_client(
                     self.ts3conn, sender,
                     "You are not allowed to use this command!")
         else:
             Bot.send_msg_to_client(
                 self.ts3conn, sender,
                 "Dieser Befehl ist nicht verfügbar. Probier mal !help")
             logger.info("Unknown command " + msg + " received!")
Exemplo n.º 10
0
 def zmien_oslone(self, nowa_oslona):
     if nowa_oslona > 10:
         self.oslona = 0
         Bot.output("Nie wałuj! Jeśli zrobiłeś legitnie taką osłonę, zgłoś to na [email protected], i opisz.")
         return 0
     self.oslona = nowa_oslona
     return self.oslona
Exemplo n.º 11
0
 def _addBot(self):
     b = Bot(self._canvas, self._bx.get(), self._by.get(), sF = self._bs.get())
     k11 = self._k11.get()
     k12 = self._k12.get()
     k21 = self._k21.get()
     k22 = self._k22.get()
     b.setMatrix(k11,k12,k21,k22)
     self._world.addBot(b)
Exemplo n.º 12
0
 def __init__(self, symbol, starting_posn, code_file):
     """ Initializes the bike. """
     self.curr_posn = starting_posn
     self.prev_posn = Position(starting_posn.x, starting_posn.y,
                               starting_posn.max_x, starting_posn.max_y)
     self.symbol = symbol
     self.bot = Bot(symbol, code_file)
     self.is_dead = False
Exemplo n.º 13
0
def test_umiejetnosci_i_aktywacji(): # test mortal_base.py
    wojtek = mortal.IstotaZywa(8, 8, 8, "Wojtek")
    assert wojtek.aktywacja(2)
    assert wojtek.umiejetnosci[3][3] == 1
    assert wojtek.umiejetnosci[4][3] == 0
    assert wojtek.rzut_na_umiejetnasc("skupienie") >= 2
    Bot.output("umiejetnosci dzialaja")
    return 4
Exemplo n.º 14
0
 def test_trafienia(self,
                    operator,
                    cel,
                    dodatkowe,
                    zasieg=0):  # does not deal damage by itself.
     wynik = operator.rzut_na_umiejetnasc(self.rodzaj_testu) + self.aktualna_premia(operator, zasieg)\
             + dodatkowe  # because of trowing granades is based on area atacking, instead of normal target.
     Bot.output("Rzuciłeś na zasięg " + str(wynik * self.przyrost_zasiegu) +
                " metrów \n")
Exemplo n.º 15
0
def add_quote(sender, msg):
    """
    Add a quote.
    """
    if len(msg) > len("!addQuote "):
        add(msg[len("!addQuote "):])
        Bot.send_msg_to_client(
            bot.ts3conn, sender,
            "Quote '" + msg[len("!addQuote "):] + "' was added.")
Exemplo n.º 16
0
 def dokup_szyny(self, operator):
     if operator.pieniadze < 300:
         Bot.output("Nie masz dość forsy")
         return False
     operator.pieniadze = operator.pieniadze - 300  #zafiksowana cena szyn dodatkowych
     for i in range(0, len(self.szyny_montazowe)):
         if self.szyny_montazowe[i] == "wykup":
             self.szyny_montazowe[i] = "tak"
     return True
Exemplo n.º 17
0
 def wybierz_kamuflaz(self, wejscie):
     if "kamuflaż" in self.specjalne:
         if wejscie in ("zimowy", "pustynny", "leśny", "miejski"):
             self.kamuflaz = wejscie
             return True
         else:
             Bot.output("Jeśli chciałeś komuflaż, to powinneś wybrać spośród: \n zimowy, pustynny, leśny, miejski "
                        "\nJeśli chciałeś w innym kolorze, zignoruj tą wiadomość")
             self.kamuflaz = wejscie
             return False
Exemplo n.º 18
0
def main():
    EXCHANGE = setup()
    config_file = "bit_4py0.conf"
    minimum_crypto = 0.0001
    Bot.run_real(EXCHANGE,
                 "bitcoin",
                 "XBT",
                 "../jsons/exchange_balance.json",
                 minimum_crypto,
                 config_file=config_file)
Exemplo n.º 19
0
def main(argv):
    if os.path.exists(pid_file):
        print(
            'PID file exists! If the bot is not running, please delete this file before trying to start again!'
        )
        sys.exit(1)
    fork = False
    if len(argv) > 0:
        if argv[0] == '-fork':
            fork = True
    if fork:
        logging.basicConfig(filename=logging_file,
                            level=logging_level,
                            format=logging_format)
    else:
        logging.basicConfig(level=logging_level, format=logging_format)
    logging.info("Welcome to botje")
    if fork:
        try:
            pid = os.fork()
            if pid > 0:
                logging.info('Forked into PID {0}'.format(pid))
                with open(pid_file, 'w') as f:
                    f.write(str(pid))
                print(pid)
                return 0
        except OSError as error:
            logging.error('Unable to fork. Error: {0} ({1})'.format(
                error.errno, error.strerror))
            return 1
    botje = Bot.Bot()
    while True:
        try:
            logging.info('Starting bot...')
            botje.start()
        except Bot.BotRestartException:
            continue
        except Bot.BotReloadException:
            logging.info('Force reloading Bot class')
            botje = None
            reload(Bot)
            botje = Bot.Bot()
            botje.modules.reload_modules()
            continue
        except select.error as e:
            logging.exception("select.error")
            continue
        except (KeyboardInterrupt, Bot.BotExitException):
            botje.die()
            break
        logging.warning('Botje died, restarting in 5...')
        import time
        time.sleep(5)
    logging.info('Exiting bot...')
    if fork: os.remove(pid_file)
Exemplo n.º 20
0
def main():
    bot = Bot()
    autoit.win_wait(bot.title, 5)
    cycle = True
    # print 'Argument:', str(sys.argv[1])
    while cycle:
        if not bot.matchBuff(str(sys.argv[1]) + '.png'):
            # bot.clickBuff(str(sys.argv[1]) + '_click.png')
            autoit.control_send(bot.title, '', '{F4}', 0)
        bot.sleep(20,40)
    pass
Exemplo n.º 21
0
 def _addBot(self):
     b = Bot(self._canvas,
             self._bx.get(),
             self._by.get(),
             sF=self._bs.get())
     k11 = self._k11.get()
     k12 = self._k12.get()
     k21 = self._k21.get()
     k22 = self._k22.get()
     b.setMatrix(k11, k12, k21, k22)
     self._world.addBot(b)
Exemplo n.º 22
0
def list_suggestions(sender, msg):
    try:
        with open("./data/suggestions.txt", "r") as file:
            suggestions = "".join(file.readlines())
            file.close()
        Bot.send_msg_to_client(
            bot.ts3conn, sender,
            f"\nHier sind alle Vorschläge: \n {suggestions}")
    except (Exception) as err:
        Bot.send_msg_to_client(bot.ts3conn, sender,
                               f"\n Da ist etwas schief gelaufen: \n {err}")
Exemplo n.º 23
0
def main():
    bot = Bot()
    autoit.win_wait(bot.title, 5)
    cycle = True
    # print 'Argument:', str(sys.argv[1])
    while cycle:
        if not bot.matchBuff(str(sys.argv[1]) + '.png'):
            # bot.clickBuff(str(sys.argv[1]) + '_click.png')
            autoit.control_send(bot.title, '', '{F4}', 0)
        bot.sleep(20, 40)
    pass
Exemplo n.º 24
0
def load_bot(botModule, port, botName):
  nameMaxLength = 10
  if len(botName) > nameMaxLength: # Cut the name if too long.
    Bot.safe_print('Warning : Bot name too long ({}) truncated to {}'.format(botName, botName[:nameMaxLength]))
    botName = botName[:nameMaxLength]
  bot = Bot.Bot(port, botName) # Create the bot.
  try:
    botModule.main(bot) # Run the bot !
  except socket.error, exception: # The exception is raised when the socket is closed on server's side.
    Bot.safe_print('Bot {} shut down'.format(botName))
    del bot
Exemplo n.º 25
0
def main():
    bot = Bot()
    autoit.win_wait(bot.title, 5)
    cycle = True
    while cycle:
        mp = bot.checkOwnMp()
        print mp
        if mp < 2:
            autoit.control_send(bot.title, '', '{F11}', 0)
        bot.sleep(10, 30)
    pass
Exemplo n.º 26
0
 def __init__(self, player1, player2):
     self.grid = [[0 for x in range(self.COLUMNS)]
                  for y in range(self.ROWS)]
     self.player = []
     if player1 == 'p':
         self.player.append(Player(1))
     else:
         self.player.append(Bot(1))
     if player2 == 'p':
         self.player.append(Player(2))
     else:
         self.player.append(Bot(2))
Exemplo n.º 27
0
def player_change():
    global x1, y1
    while True:
        global c, i
        c = c + 1
        global player_no
        player_no = c % n
        if c % n == 0:
            player_no = n
        i = player_no - 1
        if player_names[i] in player_who_have_folded:
            continue
        else:
            break

    tpot = Label(text="Pot= $" + str(round_pool) + "            ",
                 fg="white",
                 bg="green")
    tpot.config(font=("Courier BOLD", 15))
    tpot.place(x=500, y=50)

    tbet = Label(text="Current Bet= $" + str(current_bet) + "           ",
                 fg="white",
                 bg="green")
    tbet.config(font=("Courier BOLD", 15))
    tbet.place(x=800, y=50)

    if player_names not in player_who_have_folded:
        x1, y1 = gui.player_reveal(List6[2 * i:2 * i + 2], deck1, x1, y1)
        pname = Label(text="Current Player: " + player_names[i] +
                      "                       ",
                      fg="white",
                      bg="green")
        pname.config(font=("Courier BOLD", 15))
        pname.place(x=570, y=600)

    yy1 = 10
    for j in range(n):
        ppurse = Label(text=player_names[j] + "= $" + str(purse[j]) +
                       "        ",
                       fg="white",
                       bg="green")
        ppurse.config(font=("Courier BOLD", 12))
        ppurse.place(x=1300, y=yy1)
        yy1 = yy1 + 25

    if (player_names[i] == "BOT"):
        Bot.head(round_no, current_bet, List6[-2:], table, deck, chc,
                 player_who_have_folded, n)
    else:
        print("It is", player_names[i], "'s turn")
        print("Current Bet is $", current_bet)
        print("Money in pot is $", round_pool)
Exemplo n.º 28
0
def send_quote(evt):
    for g in evt.client_servergroups.split(','):
        if len(g) == 0 or int(g) in dont_send:
            return
    conn = sqlite3.connect(path)
    c = conn.cursor()
    c.execute('SELECT * FROM Quotes ORDER BY RANDOM() LIMIT 1')
    quote = c.fetchone()
    Bot.send_msg_to_client(bot.ts3conn, evt.client_id, quote[1])
    c.execute('UPDATE Quotes SET shown=? WHERE id=?', (quote[4] + 1, quote[0]))
    conn.commit()
    conn.close()
Exemplo n.º 29
0
 def __strzelanie(self, postac, wrog="brak"):
     try:
         if wrog == "brak":
             return False
         return self.strzelanie.strzal(postac, self.__rozpoznaj_cel(wrog),
                                       self.__zasieg())
     except exceptions.Pudlo:
         Bot.output(
             "nie ma takiego celu!!! GMie popraw. wpisz brak, jeśli sytuacja się zmieniła i nie"
             " chcesz oddawać tego strzału")
         wrog = Bot.gm_input_for_bot()
         self.__strzelanie(postac, wrog)
def send_quote(evt):
    for g in evt.client_servergroups.split(','):
        if len(g) == 0 or int(g) in dont_send:
            return
    conn = sqlite3.connect(path)
    c = conn.cursor()
    c.execute('SELECT * FROM Quotes ORDER BY RANDOM() LIMIT 1')
    quote = c.fetchone()
    Bot.send_msg_to_client(bot.ts3conn, evt.client_id, quote[1])
    c.execute('UPDATE Quotes SET shown=? WHERE id=?', (quote[4] + 1, quote[0]))
    conn.commit()
    conn.close()
Exemplo n.º 31
0
 def __sprawdzenie_czy_mozna_strzelac(self, operator, tryb):
     if not operator.aktywna_bron.naboj_w_komorze:
         raise exceptions.NieWystrzelono(
             "brak naboju w komorze.\nPo nacisnieciu spustu nic sie nie stalo."
         )
     if tryb in ("samoczynny", "serie"):
         if operator.aktywna_bron.szybkostrzelnosc in ("sa", "ba", "bu"):
             tryb = "pojedynczy"
             Bot.output(
                 "Po nacisnieciu spustu, lufę opóścił tylko 1 nabój. "
                 "Następnym razem sprawdź z czego strzelasz")
     return tryb
Exemplo n.º 32
0
def inform(evt):
    """
    Send out a quote to joining users.
    :param evt: ClientEnteredEvent
    """
    for g in evt.client_servergroups.split(','):
        if len(g) == 0 or int(g) in dont_send:
            return
    with codecs.open("quotes", "r", "ISO-8859-1") as f:
        quote = ""
        while len(quote) == 0:
            quote = random_line(f)
        Bot.send_msg_to_client(bot.ts3conn, evt.client_id, quote)
Exemplo n.º 33
0
def inform(evt):
    """
    Send out a quote to joining users.
    :param evt: ClientEnteredEvent
    """
    for g in evt.client_servergroups.split(','):
        if len(g) == 0 or int(g) in dont_send:
            return
    with codecs.open("quotes", "r", "ISO-8859-1") as f:
        quote = ""
        while len(quote) == 0:
            quote = random_line(f)
        Bot.send_msg_to_client(bot.ts3conn, evt.client_id, quote)
Exemplo n.º 34
0
def note_suggestion(sender, msg):
    try:
        msg = msg.replace("!suggest", "")
        with open("./data/suggestions.txt", "a") as file:
            file.write(f"{datetime.now()} ({sender}):{msg} \n")
            file.close()
        Bot.send_msg_to_client(
            bot.ts3conn, sender,
            f"\nIch habe deinen Vorschlag eingetragen: \n{datetime.now()} {msg}"
        )
    except (Exception) as err:
        Bot.send_msg_to_client(bot.ts3conn, sender,
                               f"\n Da ist etwas schief gelaufen: \n {err}")
Exemplo n.º 35
0
 def rzut_na_awarie(self):
     kosc_rzutu = 10
     if "bezawaryjna" in self.zasady_specjalne:
         kosc_rzutu = 100
     result = Bot.roll_dice(kosc_rzutu)
     if result == 1:
         self.naboj_w_komorze = False
         kosc_rzutu = 10
         if "niezniszczalna" in self.zasady_specjalne:
             kosc_rzutu = 100
         result = Bot.roll_dice(kosc_rzutu)
         if result == 1:
             self.awaria = True
def add_quote(sender, msg):
    if len(msg) <= len('!quote '):
        Bot.send_msg_to_client(bot.ts3conn, sender, 'Please include a quote to save.')
    else:
        conn = sqlite3.connect(path)
        c = conn.cursor()
        quote = msg[len('!quote')+1:]
        quote = quote.replace('" ', '"\n')
        submitter = bot.ts3conn.clientinfo(sender)
        submitter = submitter['client_nickname']
        c.execute('INSERT INTO Quotes (quote, submitter, time, shown) VALUES (?, ?, strftime("%s", "now"), ?)', (quote, submitter, 0))
        conn.commit()
        conn.close()
        Bot.send_msg_to_client(bot.ts3conn, sender, 'Your quote has been saved!')
Exemplo n.º 37
0
def main():
    bot = Bot()
    print bot.title
    autoit.win_wait(bot.title, 5)
    bot.sleep(5,10)
    autoit.control_send(bot.title, '', 'oyajirospoil', 30)
    bot.sleep(7,10)
    autoit.control_send(bot.title, '', '8w141qtf', 30)
    bot.sleep(7,10)
    autoit.control_send(bot.title, '', '{NUMPADENTER}', 30)
    bot.sleep(7,10)
    autoit.control_send(bot.title, '', '{NUMPADENTER}', 30)
    pass
Exemplo n.º 38
0
def main():
    bot = Bot()
    autoit.win_wait(bot.title, 5)
    enchx = 1010
    ecnhy = 684
    cycle = True
    bot.sleep(3,5)
    print 'Count:', str(sys.argv[1])
    print 'X:', str(sys.argv[2])
    print 'Y:', str(sys.argv[3])
    count = sys.argv[1]
    x = sys.argv[2]
    y = sys.argv[3]
    while i <= count:
        bot.randClick(x, y, 'right')


    pass
Exemplo n.º 39
0
 def __init__ (self, symbol, starting_posn, code_file) :
     """ Initializes the bike. """
     self.curr_posn = starting_posn
     self.prev_posn = Position (starting_posn.x,
                                starting_posn.y,
                                starting_posn.max_x,
                                starting_posn.max_y)
     self.symbol    = symbol
     self.bot       = Bot (symbol, code_file)
     self.is_dead   = False
Exemplo n.º 40
0
def main():
    bot = Bot()
    autoit.win_wait(bot.title, 5)
    counter = 0
    poitonUse = 0
    cycle = True
    bot.sleep(3,5)
    bigsleep = round(random.uniform(10, 50))
    print 'Argument:', str(sys.argv[1])
    while cycle:
        bot.randClick(1444, 724, 'right')
        bot.sleep(1,1.5)
        counter += 1
        if counter >= int(sys.argv[1]):
            cycle = False
        print str(counter) + " bgs(" + str(bigsleep) + ")"
        if counter % bigsleep == 0:
            bot.sleep(1,2)
            bigsleep = round(random.uniform(10, 50))

    pass
Exemplo n.º 41
0
Arquivo: f1.py Projeto: oyajiro/l2bot
def main():
    bot = Bot()
    wincount = sys.argv[1]
    autoit.win_wait(bot.title, 5)
    counter = 0
    cycle = True
    while cycle:
        print 'send'
        for count in range(1, int(wincount)+1):
            title = "[TITLE:Lineage II; INSTANCE:" + str(count) + "]"
            autoit.control_send(title, '', '{F1}', 0)
            bot.sleep(0.1,0.3)
            autoit.control_send(title, '', '{F1}', 0)
            bot.sleep(0.7,1.3)
            print 'title ', title
        bot.sleep(0.3,0.8)
Exemplo n.º 42
0
def main():
    bot = Bot()
    autoit.win_wait(bot.title, 5)
    cycle = True
    colorMin = [160, 160, 5]
    colorMax = [237, 237, 30]
    cnt = 0
    found = 0
    temp = 0
    while cycle:
        if found == 0 and temp == 1: 
            autoit.control_send(bot.title, '', '{F4}', 0)
            bot.sleep(1,4)
            found = temp

            # systemChatCoord = (27, 751, 350, 870)
            # grab = ImageGrab.grab(systemChatCoord)
            # img =  array(grab.getdata(),dtype=uint8).reshape((grab.size[1],grab.size[0],3))
            # mask = cv2.inRange(img, array(colorMin, dtype='uint8'), array(colorMax, dtype='uint8'))
            # mask = cv2.filter2D(mask,-1, ones((2,30), float32))
            # (cnts, hierarchy) = cv2.findContours(mask,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
            # cv2.drawContours(img, cnts, -1, (255,0,0), 3)
            # cv2.imshow("images", img)
            # cv2.waitKey(0)
            # bla()

        if temp == 0:
            found = temp

        if cnt > 10 or found == 1:
            print found 
            cnt = 0
        cnt += 1
        bot.sleep(0.1,0.2)
        temp = bot.checkSystemChatColor(colorMin, colorMax)
    pass
Exemplo n.º 43
0
 def __init__(self, name, access_token, callback_url='', avatar_url=''):
     Bot.__init__(self, name, access_token, callback_url, avatar_url)
     self.input_file = open(sys.argv[1])
Exemplo n.º 44
0
def main():
    bot = Bot()
    print bot.title
    autoit.win_wait(bot.title, 5)
    counter = 0
    poitonUse = 0
    cycle = True
    summAttackCount = 0
    while cycle:
        hpstatus = bot.checkOwnHp()
        print 'hp ' + str(hpstatus)
        if hpstatus == 0:
            print 'Dead'
            cv2.imwrite('Dead' + str(int(time.time())) + '.png',getScreen(leftCornerx,leftCornery,x2,fullY2))
            cycle = False
        if hpstatus == 1:
            if poitonUse == 0:
                autoit.control_send(bot.title, '', '{F10}', 0)
            poitonUse += 1
            if poitonUse > 5:
                poitonUse = 0
        else:
            poitonUse = 0
        res = bot.findHP();
        print 'tgs ' + str(res)

        if res > 0:
            autoit.control_send(bot.title, '', '{F1}', 0)
            bot.sleep(0.1,0.6)
            autoit.control_send(bot.title, '', '{F2}', 0)
            counter = 0

            if res == 1:
                bot.sleep(0.3,0.6)
            if res > 1:
                if summAttackCount < 3:
                    autoit.control_send(bot.title, '', '{F2}', 0)
                bot.sleep(1,3)
                summAttackCount += 1
            # autoit.control_send(bot.title, '', '{F5}', 0)
        else:
            autoit.control_send(bot.title, '', '{F5}', 0)
            if counter < 3:
                autoit.control_send(bot.title, '', '{F3}', 0)
                bot.sleep(0.1,0.2)
                autoit.control_send(bot.title, '', '{F1}', 0)

            if counter > 1:
                # bot.findTarget()
                autoit.control_send(bot.title, '', '{F7}', 0)
            if counter > 2:
                autoit.control_send(bot.title, '', '{F8}', 0)
                counter = 0
            counter += 1
        print 'cnt ' + str(counter)
    pass
Exemplo n.º 45
0
def hello(sender, msg):
    Bot.send_msg_to_client(bot.ts3conn, sender, "Hello Admin!")
Exemplo n.º 46
0
        print  ('please enter an number')
        continue
    if number <= 0:
        print ('please enter an possitive number')
        continue 
    break
print ('please enter the number of bots')
botNumber = int(input())
print ('please enter the number of notbots')
notBotNumber = int(input())
print ('please enter a filename to output the apache log data')
filename = input()
botList = []
notBotList = []
for i in range(botNumber):
    bot = Bot(global_time)
    botList.append(bot)
for i in range(botNumber):
    notbot = notBot(global_time)
    notBotList.append(notbot)

while number:
    if (random.randint(0,botNumber+notBotNumber)<botNumber):
        for bot in botList:
            number = bot.activity(global_time,filename,number)
    if (random.randint(0,botNumber+notBotNumber)<notBotNumber):
        for notbot in notBotList:
            number = notbot.activity(global_time,filename,number)
    global_time = time.strftime('%d-%b-%Y:%H:%M:%S',time.localtime(global_time))
    date_time = datetime.datetime.strptime(global_time,'%d-%b-%Y:%H:%M:%S')
    date_time = date_time + datetime.timedelta(seconds = random.randint(1,60))
Exemplo n.º 47
0
def main():
    bot = Bot()
    print bot.title
    autoit.win_wait(bot.title, 5)
    counter = 0
    poitonUse = 0
    cycle = True
    spoilCount = 0
    fullCounter = 0
    deadCounter = 0
    sweepcounter = 0
    while cycle:
        hpstatus = bot.checkOwnHp()
        print 'hp ' + str(hpstatus)
        checkOwnMp()
        if hpstatus == 0:
            autoit.control_send(bot.title, '', '{F9}', 0)
            bot.sleep(0.3,0.6)
            print 'I\'m Dead', str(datetime.now())
            str(datetime.now())
            cv2.imwrite('Dead' + str(int(time.time())) + '.png',bot.getScreen(leftCornerx,leftCornery,x2,fullY2))
            cycle = False
        if hpstatus == 1:
            if poitonUse == 0:
                autoit.control_send(bot.title, '', '{F10}', 0)
            poitonUse += 1
            if poitonUse > 5:
                poitonUse = 0
        else:
            poitonUse = 0
        res = bot.findHP();
        print 'tgs ' + str(res)
        if res == 3:
            fullCounter += 1
            print 'fc ' + str(fullCounter)
            autoit.control_send(bot.title, '', '{F1}', 0)
        else:
            fullCounter = 0
        if fullCounter > 6:
            autoit.control_send(bot.title, '', '{ESC}', 0)
            bot.sleep(0.1,0.3)
            autoit.control_send(bot.title, '', '{F3}', 0)
            bot.sleep(0.1,0.3)
            # bot.mouseRotate()
            fullCounter = 0
            spoilCount = 0
        if res > 0:
            autoit.control_send(bot.title, '', '{F1}', 0)
            # autoit.control_send(bot.title, '', '{F2}', 0)
            if res < 3:
                counter = 0
                sweepcounter = 0
            deadCounter = 0

            if res > 0 and spoilCount < 4:
                autoit.control_send(bot.title, '', '{F5}', 0)
                bot.sleep(0.2, 0.4)
                # autoit.control_send(bot.title, '', '{F4}', 0)
            if spoilCount < 5:
                autoit.control_send(bot.title, '', '{F2}', 0)
                bot.sleep(0.2, 0.4)
                autoit.control_send(bot.title, '', '{F2}', 0)
                bot.sleep(0.2, 0.4)
                autoit.control_send(bot.title, '', '{F6}', 0)
                # if spoilCount % 2 == 0:
                #     autoit.control_send(bot.title, '', '{F2}', 0)
                # else:
                #     autoit.control_send(bot.title, '', '{F6}', 0)
                bot.sleep(0.2, 0.4)
                autoit.control_send(bot.title, '', '{F1}', 0)
                bot.sleep(0.1,0.3)
                autoit.control_send(bot.title, '', '{F1}', 0)
                spoilCount += 1
        else:
            deadCounter += 1
            spoilCount = 0
            bot.sleep(0.1,0.2)
            if res == 0 and counter < 2 and sweepcounter < 3:
                autoit.control_send(bot.title, '', '{F4}', 0)
                bot.sleep(0.1,0.3)
                autoit.control_send(bot.title, '', '{F4}', 0)    
                bot.sleep(0.1,0.3)
                autoit.control_send(bot.title, '', '{F4}', 0)                    
                bot.sleep(0.1,0.3)                
                autoit.control_send(bot.title, '', '{F4}', 0)                    
                bot.sleep(0.1,0.3)
                autoit.control_send(bot.title, '', '{F3}', 0)            
                print 'F4'
                deadCounter = 0
                sweepcounter += 1
            if counter < 3:
                autoit.control_send(bot.title, '', '{F3}', 0)
                bot.sleep(0.1,0.3)
                autoit.control_send(bot.title, '', '{F1}', 0)
                print 'F3'

            if counter > 2:
                # bot.findTarget()
                autoit.control_send(bot.title, '', '{F7}', 0)
                bot.sleep(0.1,0.3)
                autoit.control_send(bot.title, '', '{F7}', 0)
                print 'F7'
                counter = 0
            counter += 1
        print 'cnt ' + str(counter)
    pass
Exemplo n.º 48
0
def checkOwnMp():
    bot = Bot()
    if bot.checkOwnMp() <= 1:
        print 'MP_USE'
        autoit.control_send(bot.title, '', '{F12}', 0)
Exemplo n.º 49
0
Arquivo: att.py Projeto: oyajiro/l2bot
def main():
    bot = Bot()
    autoit.win_wait(bot.title, 5)
    item = 'vorpal_llg.png'
    stone = 'fire_stone.png'
    button = 'confirm.png'
    cycle = True
    while cycle:
        bot.clickTemplate(stone, 'items/', 'right')
        bot.sleep(0.3, 0.5)
        bot.clickTemplate(item, 'items/', 'left')
        bot.sleep(0.3, 0.5)
        bot.clickTemplate(button, 'buttons/', 'left')
        bot.sleep(3,5)
    pass
Exemplo n.º 50
0
def send_version(sender, msg):
    Bot.send_msg_to_client(bot.ts3conn, sender, __version__)
Exemplo n.º 51
0
class Bike :
    """ Represents the bike in arena. """
    
    def __init__ (self, symbol, starting_posn, code_file) :
        """ Initializes the bike. """
        self.curr_posn = starting_posn
        self.prev_posn = Position (starting_posn.x,
                                   starting_posn.y,
                                   starting_posn.max_x,
                                   starting_posn.max_y)
        self.symbol    = symbol
        self.bot       = Bot (symbol, code_file)
        self.is_dead   = False

    def __str__ (self) :
        """ For pretty printing the object. """
        return ("Current Position : " + self.curr_posn.__str__ () + linesep
                + "Previous Position : " + self.prev_posn.__str__ () + linesep
                + "Symbol : " + symbol + linesep)

    def put_trail_for_html (self, map) :
        """ The function which reports a different symbol for
        the trail for the visualizer purposes. """
        if self.symbol == BIKE_1_SYMBOL :
            trail_symbol = TRAIL1
        else :
            trail_symbol = TRAIL2
        map.log_updates (self.prev_posn.x,
                         self.prev_posn.y,
                         map.get_symbol (self.prev_posn),
                         trail_symbol)

    def get_move (self, updates, map, first_move = False) :
        """ Gets the move from the bot.
        Sets the curr_position accordingly. """
        direction = self.bot.get_move (updates, first_move)
        self.prev_posn = Position (self.curr_posn.x,
                                   self.curr_posn.y,
                                   self.curr_posn.max_x,
                                   self.curr_posn.max_y)
        self.curr_posn.update (direction)
        self.put_trail_for_html (map)
    
    def power_up (self, arena, power_symbol) :
        """ Take appropriate actions depending on
        the Power up symbol. """
        if power_symbol == RESET :
            # if the map cell is a bot symbol and not the head of the trail
            # ie, not the current position of the bike itself, delete all the
            map_size = arena.map.size
            for i in range (map_size) :
                for j in range (map_size) :
                    position = Position (i, j, map_size, map_size)
                    if (arena.map.get_symbol (position) in [BIKE_1_SYMBOL,
                                                            BIKE_2_SYMBOL]
                        and (arena.bikes[0].curr_posn != position)
                        and (arena.bikes[1].curr_posn != position)) :
                        arena.map.set_symbol (position, EMPTY)

        elif power_symbol == TRAVERSER :
            self.bot.traverser_left += TRAVERSER_CAPACITY + 1
            # The + 1 is necessary because later, during this move,
            # it is going to be decreased by 1.

        elif power_symbol == NITRO :
            self.bot.nitro_left += NITRO_QUANTITY + 1
Exemplo n.º 52
0
Arquivo: sh.py Projeto: oyajiro/l2bot
def main():
    bot = Bot()
    autoit.win_wait(bot.title, 5)
    counter = 0
    poitonUse = 0
    cycle = True
    fullCounter = 0
    while cycle:
        hpstatus = bot.checkOwnHp()
        print 'hp ' + str(hpstatus)
        checkOwnMp()
        if hpstatus == 0:
            print 'Dead'
            cv2.imwrite('Dead' + str(int(time.time())) + '.png',bot.getScreen(leftCornerx,leftCornery,x2,fullY2))
            cycle = False
        res = bot.findHP();
        if hpstatus < 2 and res > 0:
            autoit.control_send(bot.title, '', '{F5}', 0)
            bot.sleep(0.1,0.4)
            autoit.control_send(bot.title, '', '{F1}', 0)
            bot.sleep(0.1,0.3)
            autoit.control_send(bot.title, '', '{F3}', 0)
            continue
        print 'tgs ' + str(res)
        if res == 3:
            fullCounter += 1
            print 'fc ' + str(fullCounter)
        else:
            fullCounter = 0
        if fullCounter > 9:
            autoit.control_send(bot.title, '', '{ESC}', 0)
            bot.sleep(0.3,0.6)
            # autoit.control_send(bot.title, '', '{F3}', 0)
            # bot.mouseRotate()
            fullCounter = 0
            
        if res > 0:
            print 'F1'
            autoit.control_send(bot.title, '', '{F1}', 0)
            counter = 0
            bot.sleep(0.1,0.3)
            autoit.control_send(bot.title, '', '{F1}', 0)
            continue
            # autoit.control_send(bot.title, '', '{F4}', 0)
        else:
            fullCounter = 0
            if res == 0:
                autoit.control_send(bot.title, '', '{F11}', 0)
                bot.sleep(0.1,0.4)
                autoit.control_send(bot.title, '', '{F11}', 0)
            autoit.control_send(bot.title, '', '{F7}', 0)
            if counter < 3:
                autoit.control_send(bot.title, '', '{F3}', 0)
                print 'F3'
                bot.sleep(0.1,0.2)
                autoit.control_send(bot.title, '', '{F1}', 0)

            if counter > 2:
                # bot.findTarget()
                autoit.control_send(bot.title, '', '{F7}', 0)
                print 'F7'
                counter = 0
            counter += 1
        print 'cnt ' + str(counter)
    pass
Exemplo n.º 53
0
def main():
    bot = Bot()
    autoit.win_wait(bot.title, 5)
    counter = 0
    poitonUse = 0
    cycle = True
    fullCounter = 0
    while cycle:
        hpstatus = bot.checkOwnHp()
        print 'hp ' + str(hpstatus)
        if hpstatus == 0:
            bot.sleep(2,3)
            if hpstatus == 0:
                print 'Dead'
                cv2.imwrite('Dead' + str(int(time.time())) + '.png',bot.getScreen(leftCornerx,leftCornery,x2,fullY2))
                cycle = False
        if hpstatus == 1:
            if poitonUse == 0:
                autoit.control_send(bot.title, '', '{F10}', 0)
            poitonUse += 1
            if poitonUse > 5:
                poitonUse = 0
        else:
            poitonUse = 0
        res = bot.findHP();
        print 'tgs ' + str(res)
        if res == 3:
            fullCounter += 1
            print 'fc ' + str(fullCounter)
        else:
            fullCounter = 0
            lure = 0
        if fullCounter > 6:
            autoit.control_send(bot.title, '', '{ESC}', 0)
            bot.sleep(0.3,0.6)
            autoit.control_send(bot.title, '', '{F3}', 0)
            # bot.mouseRotate()
            fullCounter = 0
            
        if res > 0:
            autoit.control_send(bot.title, '', '{F1}', 0)
            counter = 0

            if res == 1 or res == 3:
                bot.sleep(0.3,0.6)
            if res > 1 and res < 3:
                bot.sleep(1,3)
        else:
            fullCounter = 0
            if counter < 2:
                autoit.control_send(bot.title, '', '{F3}', 0)
                bot.sleep(0.1,0.2)
                autoit.control_send(bot.title, '', '{F1}', 0)

            if counter > 1:
                # bot.findTarget()
                print 'counrter > 1'
                autoit.control_send(bot.title, '', '{F7}', 0)
                bot.sleep(0.3,0.5)
                if bot.findHP() > 0 :
                    print 'lure'
                    autoit.control_send(bot.title, '', '{F5}', 0)
                    bot.sleep(5,7)
                counter = 0
            counter += 1
        print 'cnt ' + str(counter)
    pass
Exemplo n.º 54
0
  for thread in threads:
    thread.join()
  print 'All threads joined'

# Return a free port on localhost. Note that another process could bind a socket to that port after it is closed.
def get_free_port():
  tcpSocket = socket.socket()
  tcpSocket.bind(('localhost', 0))
  port = tcpSocket.getsockname()[1]
  tcpSocket.close()
  return port

# Load a bot from the python file in 'botName' and launch it.
def load_bot(botModule, port, botName):
  nameMaxLength = 10
  if len(botName) > nameMaxLength: # Cut the name if too long.
    Bot.safe_print('Warning : Bot name too long ({}) truncated to {}'.format(botName, botName[:nameMaxLength]))
    botName = botName[:nameMaxLength]
  bot = Bot.Bot(port, botName) # Create the bot.
  try:
    botModule.main(bot) # Run the bot !
  except socket.error, exception: # The exception is raised when the socket is closed on server's side.
    Bot.safe_print('Bot {} shut down'.format(botName))
    del bot
  except Exception, exception: # Unexpected error (usually function main missing).
    Bot.safe_print('Error : Problem with bot {} : {}'.format(botName, exception))
    del bot

if __name__ == '__main__':
  launch_game()
Exemplo n.º 55
0
def multi_move(sender, msg):
    """
    Move all clients from one channel to another.
    :param sender: Client id of sender that sent the command.
    :param msg: Sent command.
    """
    channels = msg.split()[1:]
    source_name = ""
    dest_name = ""
    source = None
    dest = None
    ts3conn = bot.ts3conn
    if len(channels) < 2:
        if sender != 0:
            Bot.send_msg_to_client(ts3conn, sender, "Usage: multimove source destination")
            return
    elif len(channels) > 2:
        channel_name_list = ts3conn.channel_name_list()
        for channel_name in channel_name_list:
            if msg[len("!multimove "):].startswith(channel_name):
                source_name = channel_name
                dest_name = msg[len("!multimove ") + len(source_name)+1:]
    else:
        source_name = channels[0]
        dest_name = channels[1]
    if source_name == "":
        Bot.send_msg_to_client(ts3conn, sender, "Source channel not found")
        return
    if dest_name == "":
        Bot.send_msg_to_client(ts3conn, sender, "Destination channel not found")
        return
    try:
        channel_matches = ts3conn.channelfind(source_name)
        channel_candidates = [chan for chan in channel_matches if chan.get("channel_name", '-1').startswith(source_name)]
        if len(channel_candidates) == 1:
            source = channel_candidates[0].get("cid", '-1')
        elif len(channel_candidates) == 0:
            Bot.send_msg_to_client(ts3conn, sender, "Source channel could not be found.")
        else:
            channels = [chan.get('channel_name') for chan in channel_candidates]
            Bot.send_msg_to_client(ts3conn, sender, "Multiple source channels found: " + ", ".join(channels))
    except TS3QueryException:
        Bot.send_msg_to_client(ts3conn, sender, "Source channel not found")
    try:
        channel_matches = ts3conn.channelfind(dest_name)
        channel_candidates = [chan for chan in channel_matches if chan.get("channel_name",
            '-1').startswith(dest_name)]
        if len(channel_candidates) == 1:
            dest = channel_candidates[0].get("cid", '-1')
        elif len(channel_candidates) == 0:
            Bot.send_msg_to_client(ts3conn, sender, "Destination channel could not be found.")
        else:
            channels = [chan.get('channel_name') for chan in channel_candidates]
            Bot.send_msg_to_client(ts3conn, sender, "Multiple destination channels found: " + ", ".join(channels))
    except TS3QueryException:
        Bot.send_msg_to_client(ts3conn, sender, "Destination channel not found")
    if source != None and dest != None:
        try:
            client_list = ts3conn.clientlist()
            client_list = [client for client in client_list if client.get("cid", '-1') == source]
            for client in client_list:
                clid = client.get("clid", '-1')
                logger.info("Found client in channel: " + client.get("client_nickname", "") + " id = " + clid)
                ts3conn.clientmove(int(dest), int(clid))
        except TS3QueryException as e:
            Bot.send_msg_to_client(ts3conn, sender, "Error moving clients: id = " +
                    str(e.id) + e.message)
Exemplo n.º 56
0
import pprint
import requests
	# install request before via pip:
		# pip install requests
		# pip install requests[security]
import time
from Bot import *
from token import *

repeat = True
delay = 0.5

bot = Bot(BotName)

while repeat:
	# repeat = False
	receive = {'offset': bot.update_id}
	r = requests.post("https://api.telegram.org/bot"+token+"/getUpdates", params=receive)
	if r.status_code==200:
		update = r.json()
		for elem in update['result']:
			if not bot.answer(elem):
				print "Error during answere"
		time.sleep(delay)
	else :
		print "Error ",r.status_code
		print r.history
		time.sleep(delay)
Exemplo n.º 57
0
def whoami(sender, msg):
    Bot.send_msg_to_client(bot.ts3conn, sender, "None of your business!")
Exemplo n.º 58
0
def hello(sender, msg):
    Bot.send_msg_to_client(bot.ts3conn, sender, "Hello Casual!")
Exemplo n.º 59
0
def hello(sender, msg):
    Bot.send_msg_to_client(bot.ts3conn, sender, "Hello Moderator!")