Advertisement
FoxWorn3365

Hiro Integration LUA CC

Feb 9th, 2022 (edited)
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.22 KB | None | 0 0
  1. -- Stupidità artificiale
  2. -- (C) 2022 - FoxInvest Holding
  3. -- Tutti i diritti riservati (forse)
  4.  
  5. maxw, maxh = term.getSize()
  6. local function drawPixelInternal(xPos, yPos)
  7.     term.setCursorPos(xPos, yPos)
  8.     term.write(" ")
  9. end
  10.  
  11. local tColourLookup = {}
  12. for n = 1, 16 do
  13.     tColourLookup[string.byte("0123456789abcdef", n, n)] = 2 ^ (n - 1)
  14. end
  15.  
  16. function drawFilledBox(startX, startY, endX, endY, nColour)
  17.     if type(startX) ~= "number" or type(startX) ~= "number" or type(endX) ~=
  18.         "number" or type(endY) ~= "number" or
  19.         (nColour ~= nil and type(nColour) ~= "number") then
  20.         error("Expected startX, startY, endX, endY, colour", 2)
  21.     end
  22.  
  23.     startX = math.floor(startX)
  24.     startY = math.floor(startY)
  25.     endX = math.floor(endX)
  26.     endY = math.floor(endY)
  27.  
  28.     if nColour then term.setBackgroundColor(nColour) end
  29.     if startX == endX and startY == endY then
  30.         drawPixelInternal(startX, startY)
  31.         return
  32.     end
  33.  
  34.     local minX = math.min(startX, endX)
  35.     if minX == startX then
  36.         minY = startY
  37.         maxX = endX
  38.         maxY = endY
  39.     else
  40.         minY = endY
  41.         maxX = startX
  42.         maxY = startY
  43.     end
  44.  
  45.     for x = minX, maxX do for y = minY, maxY do drawPixelInternal(x, y) end end
  46. end
  47.  
  48. function clear()
  49.     sfondo(colors.black)
  50.     term.clear()
  51.     term.setCursorPos(1, 1)
  52. end
  53.  
  54. function clearRed()
  55.     sfondo(colors.red)
  56.     term.clear()
  57.     term.setCursorPos(1, 1)
  58. end
  59.  
  60. function titolo(testo)
  61.     drawFilledBox(1, 1, maxw, 1, colors.orange)
  62.     term.setCursorPos((maxw - #testo) / 2, 1)
  63.     term.setTextColor(colors.white)
  64.     term.write(testo)
  65. end
  66.  
  67. function alarm(testo, colore, y)
  68.     drawFilledBox(1, y, maxw, y, colors[colore])
  69.     term.setCursorPos((maxw - #testo) / 2, y)
  70.     term.setTextColor(colors.white)
  71.     term.write(testo)
  72.     no()
  73. end
  74.  
  75.  
  76. function bottone(color, text, x, y)
  77.    term.setBackgroundColor(colors[color])
  78.    term.setTextColor(colors.white)
  79.    term.setCursorPos(x, y)
  80.    print(text)
  81. end
  82.  
  83. function no()
  84.    term.setBackgroundColor(colors.white)
  85.    term.setTextColor(colors.black)
  86. end
  87.  
  88. term.setCursorPos(1, 1)
  89. term.setBackgroundColor(colors.black)
  90. term.setTextColor(colors.white)
  91. term.clear()
  92. x, y = term.getSize()
  93.  
  94. while true do
  95.    titolo("Chat hot con Hiro Akiba <3")
  96.    term.setBackgroundColor(colors.black)
  97.    term.setCursorPos(1, 18)
  98.    print("<Tu> ")
  99.    term.setCursorPos(6, 18)
  100.    rold = read()
  101.    if rold == "quit" or rold == "exit" then
  102.        shell.run("desktop")
  103.    end
  104.    rq = string.gsub(rold, "%s", "%%20")
  105.    if rq ~= nil and rq ~= "" then
  106.      id = os.getComputerID()
  107.      rsp = http.get("http://172.16.20.220/luanet/servlets/foxbot/?ask=" .. rq .. "&id=" .. id)
  108.      response = rsp.readAll()
  109.      rsp.close()
  110.      if response == nil then
  111.         response = "(La richiesta non e' arrivata al server!)"
  112.      end
  113.      -- Provvediamo a filtrare la risposta
  114.      if string.find(response, "Sul serio? Sembra un bambino di 8 anni |:") ~= nil then
  115.         response = "Sul serio? Sembra un bambino di 8 anni |:"
  116.      elseif string.find(response, "https://syrma.fcosma.it/bot/nsfw_hiro_1_1.gif") ~= nil then
  117.         response = "*Haaa... You taste so good...*"
  118.         getImg = http.get("http://172.16.20.220/luanet/servlets/foxbot/r34.php?scene=hiro00").readAll()
  119.      elseif string.find(response, "https://syrma.fcosma.it/bot/nsfw_hiro_1_0.png") ~= nil then
  120.         response = "*Uhhh... lo vuoi vedere~... Eccoti accontentato :wink:*"
  121.         getImg = http.get("http://172.16.20.220/luanet/servlets/foxbot/r34.php?scene=spogliati").readAll()
  122.      elseif string.find(response, "https://syrma.fcosma.it/bot/nsfw_hiro_1_1.png") ~= nil then
  123.         response = "*Uhhh... lo vuoi vedere~... Eccoti accontentato :wink:*"
  124.         getImg = http.get("http://172.16.20.220/luanet/servlets/foxbot/r34.php?scene=spogliati").readAll()
  125.      end
  126.    else
  127.      response = "<ErrorManager> Non hai scritto niente!"
  128.    end
  129.    -- Stampiamo la risposta del bot con sopra quella dell'utente
  130.    if getImg ~= nil and getImg ~= "" and #getImg < 1 then
  131.      print("<Hiro> " .. response)
  132.      print(getImg)
  133.      getImg = nil
  134.    else
  135.      print("<Hiro> " .. response)
  136.    end
  137.    print("")
  138.    rsp = nil
  139. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement