Advertisement
Vulpes

VulpesBot

Oct 10th, 2011
425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. property mibbit_testing_room : "#Vulpes"
  2. property script_rooms : {{"#env-mod", "#idmf"}, {false, false}}
  3. property mibbitconn : 1
  4. property VulpesSupport : "/Users/Zygadenus/Library/Application Support/Colloquy/PlugIns/VulpesSupport.txt"
  5.  
  6. --{date last opped as number, priv as number,  address as string, username as string, adder as string}
  7. property idmf_quotes : {¬
  8.     "default", ¬
  9.     "ab: i became 3% more robot by just reading this"}
  10. property op_address_list : {}
  11. property oal_changed : false
  12. using terms from application "Colloquy"
  13.    
  14.     on process incoming chat message message_in from user_in in panel_in
  15.         mibbit_respond_function((name of panel_in as string), (address of user_in as string), (name of user_in as string), (HTML of message_in as string))
  16.         return false
  17.     end process incoming chat message
  18.    
  19.     on member joined user_a in room_a --of connection conn
  20.        
  21.         --send_debug((name of room_a as string) & " on conn: " & (id of room_a as string))
  22.         --if connection of room_a = mibbitconn then
  23.         --  display dialog "true"
  24.         if (name of room_a as string) is in (item 1 of script_rooms) then
  25.             op_user(mibbitconn, (address of user_a as string), (name of user_a as string), (real name of user_a as string), (name of room_a as string))
  26.         end if
  27.         return false
  28.     end member joined
  29.    
  30. end using terms from
  31.  
  32.  
  33. on mibbit_respond_function(room1, usradr, user1, chat1)
  34.     if ((room1 is "#Vulpes") and (user1 is "Vulpes") and (make_substring(chat1, 1, 2) is "!V")) then
  35.         set vcommand to make_substring(chat1, 3, (count of chat1))
  36.         if vcommand is "" then
  37.             return false
  38.         else if ((count of vcommand) > 1) and (item 1 of vcommand is " ") then
  39.             set vcommand to make_substring(vcommand, 2, count of vcommand)
  40.         end if
  41.         vcontrol(vcommand)
  42.         return true
  43.     end if
  44.     set roomno to roomnumber(room1)
  45.     if roomno ≠ 0 then
  46.        
  47.         if (chat1 is "!help") then
  48.             send_message(1, room1, "help: !V help")
  49.         else if (make_substring(chat1, 1, 2) is "!V") then
  50.             --you have now entered Vulpes command list
  51.             set vcommand to make_substring(chat1, 3, (count of chat1))
  52.             if vcommand is "" then
  53.                 return false
  54.             else if ((count of vcommand) > 1) and (item 1 of vcommand is " ") then
  55.                 set vcommand to make_substring(vcommand, 2, count of vcommand)
  56.             end if
  57.            
  58.             vfunctions(mibbitconn, room1, user1, vcommand)
  59.            
  60.         else if (chat1 is "!urlbot") then
  61.             if (item roomno of (item 2 of script_rooms)) then
  62.                 set (item roomno of (item 2 of script_rooms)) to false
  63.             else
  64.                 set (item roomno of (item 2 of script_rooms)) to true
  65.             end if
  66.             send_message(mibbitconn, room1, "urlbot: " & ((item roomno of (item 2 of script_rooms)) as string))
  67.         else if (item roomno of (item 2 of script_rooms)) then
  68.             if chat1 contains "<a href=\"http://" then
  69.                 send_message(1, room1, i_spy_link(room1, chat1))
  70.             end if
  71.         else if (make_substring(chat1, 1, 6) is "!idea ") then
  72.             try
  73.                 set v_number to (make_substring(chat1, 7, (count of chat1)) as integer)
  74.                 if v_number ≤ 12 then
  75.                     if v_number > 0 then
  76.                         get_genres(v_number, room1)
  77.                     end if
  78.                 else
  79.                     send_message(mibbitconn, room1, "troll")
  80.                 end if
  81.             end try
  82.         else if (chat1 is "idunnolol") then
  83.             send_message(mibbitconn, room1, \\(°_o)/¯")
  84.         else if (chat1 is "!wtf") then
  85.             set r to random number from 1 to (count of idmf_quotes)
  86.             send_message(mibbitconn, room1, (item r of idmf_quotes))
  87.         else if (make_substring(chat1, 1, 3) is "!ps") then
  88.             send_message(mibbitconn, room1, paulstretch(make_substring(remove_spans(chat1), 4, (count of chat1))))
  89.            
  90.             --else if (false) then
  91.             -- stuff
  92.         else
  93.             --nothing
  94.         end if
  95.     else
  96.         --nothing
  97.     end if
  98.    
  99. end mibbit_respond_function
  100.  
  101.  
  102. on vcontrol(cmd)
  103.     --this function uses op_address_list as a global variable
  104.     if (cmd is "l") then
  105.         try
  106.             set op_address_list to list_read()
  107.             send_debug("list has been loaded")
  108.         on error
  109.             send_debug("unable to load")
  110.         end try
  111.     else if ((item 1 of cmd) is "i") then
  112.         list_info(op_address_list, make_substring(cmd, 3, (count of cmd)) as number, mibbit_testing_room)
  113.     else if ((item 1 of cmd) is "s") then
  114.         list_write(op_address_list, mibbit_testing_room)
  115.     else if ((item 1 of cmd) is "o") then
  116.         try
  117.             open for access VulpesSupport
  118.             send_debug("opened")
  119.         on error
  120.             send_debug("err")
  121.         end try
  122.     else if ((item 1 of cmd) is "d") then
  123.         try
  124.             close access VulpesSupport
  125.             send_debug("dropped")
  126.         on error
  127.             send_debug("err")
  128.         end try
  129.     else if ((item 1 of cmd) is "t") then
  130.         send_debug(((count of op_address_list) as string))
  131.     else if ((item 1 of cmd) is "p") then
  132.         repeat with i from 1 to (count of op_address_list)
  133.             delay 2
  134.             list_info(op_address_list, i, mibbit_testing_room)
  135.         end repeat
  136.     else
  137.         --nothing
  138.     end if
  139. end vcontrol
  140.  
  141. on vfunctions(conn, rm, usr, cmd)
  142.     if (cmd is "help") then
  143.         send_message(conn, rm, "commands preceded with a !V:")
  144.         send_message(conn, rm, "~ help, oust, num, load, save, add &lt;addr&gt;, total, lookup &lt;addr&gt;, drop priv, sleep")
  145.         send_message(conn, rm, "~ misc. commands: !urlbot, !ps &lt;paulstretch&gt;, !idea &lt;number&gt;, idunnolol")
  146.        
  147.     else if (cmd is "oust") then
  148.         send_command(conn, "part " & rm)
  149.     else if (cmd is "sleep") then
  150.         send_message(conn, rm, "disabled (& for good reason)")
  151.         --do shell script "pmset sleepnow"
  152.     else if (cmd is "num") then
  153.         send_message(conn, rm, ("74D2 ") & ip_checker())
  154.     else if (cmd is "load") then
  155.         try
  156.             set op_address_list to list_read()
  157.             send_message(conn, rm, "list has been loaded")
  158.         on error
  159.             send_message(conn, rm, "unable to load")
  160.         end try
  161.     else if (cmd is "save") then
  162.         list_write(op_address_list, rm)
  163.         --send_message(conn, rm, "list has been saved")
  164.     else if ((make_substring(cmd, 1, 4)) is "add ") and ((count of cmd) > 4) then
  165.         set op_address_list to list_add(op_address_list, make_substring(cmd, 5, (count of cmd)), 1, "NUL", usr, rm)
  166.         --send_message(conn, rm, "addr added")
  167.     else if (cmd is "total") then
  168.         send_message(conn, rm, ((count of op_address_list) as string))
  169.     else if (make_substring(cmd, 1, 7) is "lookup ") then
  170.         set lkp_nfo to list_lookup(make_substring(cmd, 8, (count of cmd)))
  171.         send_message(conn, rm, (item 1 of lkp_nfo as string) & " " & (item 2 of lkp_nfo as string))
  172.     else if (make_substring(cmd, 1, 5) is "info ") then
  173.         list_info(op_address_list, (make_substring(cmd, 6, (count of cmd)) as integer), rm)
  174.     else if (cmd is "drop priv") then
  175.         try
  176.             close access VulpesSupport
  177.             send_message(conn, rm, "privileges dropped")
  178.         on error
  179.             send_message(conn, rm, "privileges not open")
  180.         end try
  181.     else
  182.         --nothing
  183.     end if
  184. end vfunctions
  185.  
  186. on roomnumber(roomname)
  187.     repeat with i from 1 to (count of item 1 of script_rooms)
  188.         if item i of (item 1 of script_rooms) is roomname then
  189.             return i
  190.         end if
  191.     end repeat
  192.     return 0
  193. end roomnumber
  194.  
  195. on i_spy_link(room_in, chat_in)
  196.     set link_begin to offset of "<a href=\"http://" in chat_in
  197.     if link_begin = 0 then
  198.         return "no url"
  199.     else
  200.         set link_begin to link_begin + 9
  201.     end if
  202.     set i1 to 0
  203.     repeat with i1 from 0 to ((count of chat_in) - link_begin)
  204.         --send_message(1, mibbit_testing_room, ((i1 as string) & ": " & (item (link_begin + i1) of chat_in)))
  205.         if (item (link_begin + i1) of chat_in) is "\"" then
  206.             exit repeat
  207.         else
  208.             --nothing
  209.         end if
  210.     end repeat
  211.     set url_frisk to make_substring(chat_in, link_begin, link_begin + i1 - 1)
  212.     --display dialog url_frisk
  213.     send_message(1, mibbit_testing_room, ("I spy a link in " & room_in & ": " & make_substring(url_frisk, 1, 7) & " " & make_substring(url_frisk, 8, 10) & " " & make_substring(url_frisk, 11, (count of url_frisk))))
  214.     (*
  215.     if paste is not:
  216.     .html
  217.     .com
  218.     .org
  219.     .edu
  220.    
  221.     or if it is:
  222.     .jpg
  223.     .gif
  224.     .png
  225.     .filename not site address
  226.    
  227.     then no source exists, not sure how to absolute this ...
  228.     *)
  229.     tell application "Safari"
  230.         run
  231.         --activate
  232.         make new document at end of documents
  233.         set URL of document 1 to url_frisk
  234.         delay 4
  235.         try
  236.             set url_source to source of document 1
  237.         on error
  238.             --could not get source
  239.             return false
  240.         end try
  241.         close document 1
  242.     end tell
  243.     set title_begin to offset of "<title>" in url_source
  244.     set title_end to offset of "</title>" in url_source
  245.     set url_title to make_substring(url_source, title_begin + 7, title_end - 1)
  246.     return ("link title: " & url_title)
  247. end i_spy_link
  248.  
  249. on send_file(rqconn, rqname, rqroom, rqfile)
  250.     send_message(rqconn, rqroom, "cannot get file \"" & rqfile & "\" because Vulpes is too unintelligent to figure out how CTCP works")
  251. end send_file
  252.  
  253. on send_command(connection_num, command_to_send)
  254.     tell application "Colloquy"
  255.         tell connection connection_num
  256.             send raw command command_to_send
  257.         end tell
  258.     end tell
  259. end send_command
  260.  
  261. on ip_checker()
  262.     set ip_url to "http://checkip.dyndns.com/"
  263.    
  264.     tell application "Safari"
  265.        
  266.         run
  267.         --activate
  268.         make new document at end of documents
  269.         set URL of document 1 to ip_url
  270.         delay 4
  271.         set text_of_doc to text of document 1
  272.         close document 1
  273.        
  274.     end tell
  275.     return ip_hex to make_ip_hex(get_ip_string(text_of_doc))
  276.    
  277. end ip_checker
  278.  
  279. on make_ip_hex(ip_string_in)
  280.     set error_out to 0
  281.     set ip_hex to 0
  282.     set hex_digit to 0
  283.     repeat with i0 from 1 to (count of ip_string_in)
  284.         if (item i0 of ip_string_in) is (".") then
  285.             if hex_digit > 255 then
  286.                 set error_out to error_out + 1
  287.             end if
  288.             set ip_hex to ip_hex * 256 + hex_digit
  289.             set hex_digit to 0
  290.         else
  291.             repeat with i1 from 0 to 9
  292.                 if (item i0 of ip_string_in) is (i1 as string) then
  293.                     set hex_digit to hex_digit * 10 + i1
  294.                     exit repeat
  295.                 end if
  296.                 if i1 = 9 then
  297.                     --flag error
  298.                     set error_out to error_out + 1
  299.                 end if
  300.             end repeat
  301.         end if
  302.     end repeat
  303.     set ip_hex to ip_hex * 256 + hex_digit
  304.    
  305.     return (ip_hex as string) & (" E") & (error_out as string)
  306.    
  307. end make_ip_hex
  308.  
  309. on get_ip_string(ip_string_in)
  310.     set ip_out to make_substring(ip_string_in, 21, (count of ip_string_in))
  311.     return ip_out
  312. end get_ip_string
  313.  
  314. on op_user(conn, user_addr, user_name, user_real, user_room)
  315.     --this function uses op_address_list as a global variable & oal_changed
  316.     (*
  317. optype:
  318. 0-nothing
  319. 1-voice
  320. 2-halfop
  321. 3-op
  322. *)
  323.     set op_type to list_lookup(user_addr)
  324.     user_info((user_name), (user_addr), user_real, (user_room), (((item 1 of op_type) as string) & " " & ((item 2 of op_type) as string)))
  325.     if (item 1 of op_type) = 0 then
  326.         return false
  327.     end if
  328.     set (item 1 of (item (item 1 of op_type) of op_address_list)) to cdtn()
  329.     set oal_changed to true
  330.     list_info(op_address_list, (item 1 of op_type), mibbit_testing_room)
  331.    
  332.     if ((item 2 of op_type) = -1) then
  333.         send_message(conn, user_room, (user_name & " has lost their voice privileges for the time being"))
  334.         return false
  335.     else if ((item 2 of op_type) = 4) then
  336.         --send_message(mibbitconn, mibbit_testing_room, "welcome back, " & user_name & ", to " & user_room)
  337.         return true
  338.     else
  339.         --continue
  340.     end if
  341.    
  342.     set command_type to command_set((item 2 of op_type))
  343.     if command_type = "0" then
  344.         return false
  345.     end if
  346.    
  347.     tell application "Colloquy"
  348.         tell connection conn
  349.             send raw command ("mode " & (user_room) & " " & command_type & " " & (user_name))
  350.         end tell
  351.     end tell
  352.    
  353.     return true
  354. end op_user
  355.  
  356. on command_set(op_type)
  357.     if op_type = 1 then
  358.         return "+v"
  359.     else if op_type = 2 then
  360.         return "+h"
  361.     else if op_type = 3 then
  362.         return "+o"
  363.     else
  364.         return "0"
  365.     end if
  366. end command_set
  367.  
  368. on send_message(conn, room1, message1)
  369.     tell application "Colloquy"
  370.         tell chat room (room1) of connection conn
  371.             send message message1
  372.         end tell
  373.     end tell
  374.     return false
  375. end send_message
  376.  
  377. on send_action(conn, room1, message1)
  378.     tell application "Colloquy"
  379.         tell chat room (room1) of connection conn
  380.             send message message1 with action tense
  381.         end tell
  382.     end tell
  383. end send_action
  384.  
  385. on send_debug(bug)
  386.     send_message(1, mibbit_testing_room, bug)
  387. end send_debug
  388.  
  389. on user_info(user_name, user_add, user_real, room_name, notes)
  390.     send_debug((room_name) & " - " & (user_name) & " : " & user_real & " : " & (user_add) & ", " & (notes))
  391.     return false
  392. end user_info
  393.  
  394. on remove_spans(string_in)
  395.     set spans_removed to ""
  396.     set addto to 1
  397.     repeat with i1 from 1 to (count of string_in)
  398.         if addto is 0 then
  399.             if (item i1 of string_in) is ">" then
  400.                 set addto to 1
  401.             else
  402.                 --nothing
  403.             end if
  404.         else
  405.             if (item i1 of string_in) is "<" then
  406.                 set addto to 0
  407.             else
  408.                 set spans_removed to spans_removed & (item i1 of string_in)
  409.             end if
  410.         end if
  411.     end repeat
  412.     return spans_removed
  413. end remove_spans
  414.  
  415. on shuffle(preshuffle, shufflewindow)
  416.     set r0 to random number from 1 to shufflewindow
  417.     set r1 to random number from 1 to shufflewindow
  418.     set slide to (count of preshuffle) - shufflewindow + 1
  419.     --repeat with i from 1 to slide
  420.     --end repeat
  421. end shuffle
  422.  
  423. on remove_html_code(html_)
  424.     --http://www.ascii.cl/htmlcodes.htm
  425.     set txtout to ""
  426.     set html_list to {¬
  427.         {"quot;", "\""}, ¬
  428.         {"apos;", "'"}, ¬
  429.         {"lt;", "<"}, ¬
  430.         {"gt;", ">"}, ¬
  431.         {"amp;", "&"}}
  432.     set check to ""
  433.     set i to 1
  434.     repeat while i ≤ (count of html_)
  435.         if (item i of html_ is "&") then
  436.             --display dialog "found something at " & (i as string)
  437.             repeat while ((item i of html_ is not ";") and (i < (count of html_)))
  438.                 set i to i + 1
  439.                 set check to (check & (item i of html_))
  440.             end repeat
  441.             --display dialog "check is " & check
  442.             repeat with j from 1 to (count of html_list)
  443.                 if (item 1 of (item j of html_list)) is check then
  444.                     --display dialog "found it at " & (j as string) & " which is " & (item 2 of (item j of html_list))
  445.                    
  446.                     set txtout to txtout & (item 2 of (item j of html_list))
  447.                     exit repeat
  448.                 end if
  449.             end repeat
  450.             set check to ""
  451.         else
  452.             set txtout to txtout & (item i of html_)
  453.         end if
  454.         set i to i + 1
  455.     end repeat
  456.     return txtout
  457. end remove_html_code
  458.  
  459. on paulstretch(pre_stretch)
  460.     --send_debug("~ps " & (pre_stretch as string))
  461.     set pre_stretch to remove_html_code(pre_stretch)
  462.     set repeat_size to repeat_amount(count of pre_stretch)
  463.     set post_stretch to ""
  464.     set pre_stretch_val to (string_char_value(pre_stretch))
  465.     set sum1 to 0
  466.    
  467.     if repeat_size < 1 then
  468.         return ""
  469.     end if
  470.     repeat with i1 from 1 to (count of pre_stretch)
  471.         set add1 to (pre_stretch_val) / (repeat_size * (string_char_value(item i1 of pre_stretch)))
  472.         repeat while sum1 < 1
  473.             set post_stretch to post_stretch & (item i1 of pre_stretch)
  474.             set sum1 to sum1 + add1
  475.         end repeat
  476.         set sum1 to sum1 - (1 + add1)
  477.     end repeat
  478.     return post_stretch
  479. end paulstretch
  480.  
  481. on repeat_amount(size1)
  482.     set botmax to 453
  483.     set total_length to upper_circle((botmax - size1), botmax)
  484.     if total_length < 0 then
  485.         return -1
  486.     else
  487.         return total_length
  488.     end if
  489. end repeat_amount
  490.  
  491. on abs1(in1)
  492.     if in1 ≥ 0 then
  493.         return in1
  494.     else
  495.         return -in1
  496.     end if
  497. end abs1
  498.  
  499. on upper_circle(x, r)
  500.     if abs1(x) > r then
  501.         return -1
  502.     end if
  503.     return (-(x ^ 2) + r ^ 2) ^ 0.5
  504. end upper_circle
  505.  
  506. on string_char_value(string1)
  507.     set return_val to 0
  508.     set cvlist to {¬
  509.         {"A", 8}, ¬
  510.         {"B", 3}, ¬
  511.         {"C", 3}, ¬
  512.         {"D", 3}, ¬
  513.         {"E", 10}, ¬
  514.         {"F", 3}, ¬
  515.         {"G", 3}, ¬
  516.         {"H", 3}, ¬
  517.         {"I", 7}, ¬
  518.         {"J", 3}, ¬
  519.         {"K", 3}, ¬
  520.         {"L", 4}, ¬
  521.         {"M", 4}, ¬
  522.         {"N", 3}, ¬
  523.         {"O", 8}, ¬
  524.         {"P", 5}, ¬
  525.         {"Q", 2}, ¬
  526.         {"R", 5}, ¬
  527.         {"S", 6}, ¬
  528.         {"T", 5}, ¬
  529.         {"U", 8}, ¬
  530.         {"V", 3}, ¬
  531.         {"W", 4}, ¬
  532.         {"X", 2}, ¬
  533.         {"Y", 6}, ¬
  534.         {"Z", 2}, ¬
  535.         {" ", 1}}
  536.     --set foundswitch to false
  537.     repeat with i1 from 1 to (count of string1)
  538.         repeat with i2 from 1 to (count of cvlist)
  539.             if (item 1 of (item i2 of cvlist)) = (item i1 of string1) then
  540.                 set return_val to return_val + (item 2 of (item i2 of cvlist))
  541.                 exit repeat
  542.             end if
  543.         end repeat
  544.     end repeat
  545.     if return_val > 0 then
  546.         return return_val
  547.     else
  548.         --error here
  549.         return 1
  550.     end if
  551. end string_char_value
  552.  
  553. on list_write(oal, rm)
  554.     if oal_changed then
  555.         --display dialog ((count of op_address_list) as string)
  556.         try
  557.             open for access VulpesSupport with write permission
  558.             set eof of VulpesSupport to 0
  559.             repeat with i1 from 1 to (count of op_address_list)
  560.                 --{date last opped as number,            priv as number,            address as string,           username as string,        adder as string}
  561.                 write ((item 1 of (item i1 of oal) as string) & " " & (item 2 of (item i1 of oal) as string) & " " & (item 3 of (item i1 of oal)) & " " & (item 4 of (item i1 of oal)) & " " & (item 5 of (item i1 of oal)) & "\n") to VulpesSupport starting at eof as string
  562.             end repeat
  563.             close access VulpesSupport
  564.             set oal_changed to false
  565.             send_message(1, rm, "list has been saved")
  566.         on error
  567.             try
  568.                 close access VulpesSupport
  569.             end try
  570.             send_message(1, rm, "error saving list")
  571.             return false
  572.         end try
  573.         return true
  574.     else
  575.         send_message(1, rm, "no changes to list")
  576.     end if
  577. end list_write
  578.  
  579. on list_add(oad, usr_addr, priv, usrnme, addername, rm)
  580.     --{date last opped as number, priv as number,  address as string, username as string, adder as string}
  581.     set a_on to list_lookup(usr_addr)
  582.     if ((item 1 of a_on)0) then
  583.         send_message(1, rm, "usr " & usr_addr & " already added at line " & (item 1 of a_on as string) & " priv " & (item 2 of a_on as string))
  584.     else
  585.         send_debug(usr_addr & " going to be added")
  586.         try
  587.             set oad to oad & {{cdtn(), priv, usr_addr, usrnme, addername}}
  588.             set oal_changed to true
  589.             send_message(1, rm, "addr added")
  590.         on error
  591.             send_debug("add failed " & usr_addr)
  592.             send_message(1, rm, "add failed")
  593.         end try
  594.     end if
  595.     return (oad)
  596. end list_add
  597.  
  598. on list_read()
  599.     set op_address_list to {}
  600.     set vulread to ""
  601.     set i1 to 1
  602.     set i2 to 1
  603.     set i3 to 1
  604.     set i4 to 1
  605.     set ict to 1
  606.     set list_line to ""
  607.     set list_item to {}
  608.    
  609.     try
  610.         open for access VulpesSupport --with write permission
  611.         set vulread to read VulpesSupport
  612.     on error
  613.         close access VulpesSupport
  614.         return {}
  615.     end try
  616.     close access VulpesSupport
  617.     --display dialog ((count of vulread) as string)
  618.     --delay 1
  619.     repeat while (i1 ≤ (count of vulread))
  620.         set list_item to {"0", "0", "addr", "usr", "adde"}
  621.         repeat while (i1 ≤ (count of vulread))
  622.            
  623.             if ((item i1 of vulread) is in {"\r", "\n"}) then
  624.                 --display dialog ("i1=" & (i2 as string) & "  i3=" & (i1 as string))
  625.                 set list_line to make_substring(vulread, i2, i1 - 1)
  626.                 set i1 to i1 + 1
  627.                 set i2 to i1
  628.                 exit repeat
  629.             else
  630.                 set i1 to i1 + 1
  631.             end if
  632.         end repeat
  633.         --display dialog ("|" & list_line & "|")
  634.         set i4 to 1
  635.         set ict to 1
  636.         repeat with i3 from 1 to (count of list_line)
  637.             --display dialog ((i3 as string) & " " & (item i3 of vulread))
  638.             if ((item i3 of list_line) is " ") then
  639.                 set (item ict of list_item) to (make_substring(list_line, i4, i3 - 1))
  640.                 set ict to ict + 1
  641.                 set i3 to i3 + 1
  642.                 set i4 to i3
  643.             else
  644.                 set i3 to i3 + 1
  645.             end if
  646.         end repeat
  647.         set (item ict of list_item) to (make_substring(list_line, i4, (count of list_line)))
  648.        
  649.         --display dialog ("|" & list_line & "|\n|" & (item 1 of list_item) & "|" & (item 2 of list_item) & "|" & (item 3 of list_item) & "|" & (item 4 of list_item) & "|" & (item 5 of list_item) & "|")
  650.         set op_address_list to op_address_list & {{(item 1 of list_item as number), (item 2 of list_item as number), (item 3 of list_item), (item 4 of list_item), (item 5 of list_item)}}
  651.     end repeat
  652.     set oal_changed to false
  653.     send_debug(((count of op_address_list) as string) & " names loaded")
  654.     return op_address_list
  655. end list_read
  656.  
  657. on list_lookup(addr)
  658.     --{date last opped as number, priv as number,  address as string, username as string, adder as string}
  659.     repeat with i from 1 to (count of op_address_list)
  660.         if ((item 3 of (item i of op_address_list)) is addr) then
  661.             return {i, (item 2 of (item i of op_address_list))}
  662.         end if
  663.     end repeat
  664.     return {0, 0}
  665. end list_lookup
  666.  
  667. on list_info(oal, idxno, nforoom)
  668.     --display dialog (idxno as string)
  669.     if ((idxno > 0) and (idxno ≤ (count of oal))) then
  670.         set olitem to (item idxno of oal)
  671.         send_message(1, nforoom, (item 1 of olitem as string) & " " & (item 2 of olitem as string) & " " & (item 3 of olitem) & " " & (item 4 of olitem) & " " & (item 5 of olitem))
  672.         return olitem
  673.     else
  674.         send_message(1, nforoom, "no such index")
  675.     end if
  676. end list_info
  677.  
  678. on make_substring(string_in, beg1, end1)
  679.     if (beg1 > end1) then
  680.         return ""
  681.     end if
  682.     if (beg1 < 1) then
  683.         set beg1 to 1
  684.     end if
  685.     if (end1 > (count of string_in)) then
  686.         set end1 to (count of string_in)
  687.     end if
  688.     return (text beg1 through end1 of string_in)
  689. end make_substring
  690.  
  691.  
  692. on cdtn()
  693.     --set yr to (((year of (current date)) - 2010) * 365)
  694.     set mth to month_to_days(month of (current date) as number)
  695.     set dy to (day of (current date))
  696.    
  697.     --set total to yr + mth + dy
  698.     set total to mth + dy
  699.     return total
  700.    
  701. end cdtn
  702.  
  703.  
  704. on month_to_days(monthno)
  705.     set dayscount to 0
  706.     set dayslist to {¬
  707.         31, ¬
  708.         28, ¬
  709.         31, ¬
  710.         30, ¬
  711.         31, ¬
  712.         30, ¬
  713.         31, ¬
  714.         31, ¬
  715.         30, ¬
  716.         31, ¬
  717.         30, ¬
  718.         31}
  719.     repeat with i from 1 to (count of dayslist)
  720.         if (monthno = i) then
  721.             return (dayscount)
  722.         else
  723.             set dayscount to dayscount + (item i of dayslist)
  724.         end if
  725.     end repeat
  726.     return 0
  727. end month_to_days
  728.  
  729.  
  730.  
  731. on get_genres(v_number, panel_name)
  732.     set genres_out to ""
  733.     repeat with i1 from 1 to v_number
  734.         set genres_out to genres_out & "[" & genre_pick() & "]"
  735.     end repeat
  736.     send_message(1, panel_name, genres_out)
  737. end get_genres
  738.  
  739. on genre_pick()
  740.     set genres to {¬
  741.         "Ambient", ¬
  742.         "Ambient house", ¬
  743.         "Ambient techno", ¬
  744.         "Dark ambient", ¬
  745.         "Drone music", ¬
  746.         "Illbient", ¬
  747.         "Psybient", ¬
  748.         "Breakbeat", ¬
  749.         "Baltimore Club", ¬
  750.         "Big beat", ¬
  751.         "Breakbeat hardcore", ¬
  752.         "Broken beat", ¬
  753.         "Florida breaks", ¬
  754.         "Nu skool breaks", ¬
  755.         "Chiptune", ¬
  756.         "Demoscene music", ¬
  757.         "Game Boy music", ¬
  758.         "Disco", ¬
  759.         "Cosmic disco", ¬
  760.         "Euro disco", ¬
  761.         "Hardcore breaks", ¬
  762.         "Hi-NRG", ¬
  763.         "New Beat", ¬
  764.         "Jungle techno", ¬
  765.         "Eurobeat", ¬
  766.         "Europop", ¬
  767.         "Hard NRG", ¬
  768.         "Italo Disco", ¬
  769.         "Italo dance", ¬
  770.         "Nu-disco", ¬
  771.         "Rave breaks", ¬
  772.         "Downtempo", ¬
  773.         "Acid jazz", ¬
  774.         "Balearic Beat", ¬
  775.         "Chill out", ¬
  776.         "Dub music", ¬
  777.         "Ethnic electronica", ¬
  778.         "New age music", ¬
  779.         "Nu jazz", ¬
  780.         "Trip hop", ¬
  781.         "Drum and bass/Jungle", ¬
  782.         "Clownstep", ¬
  783.         "Darkcore", ¬
  784.         "Darkstep", ¬
  785.         "Drumfunk", ¬
  786.         "Dubstep", ¬
  787.         "Hardstep", ¬
  788.         "Intelligent drum and bass", ¬
  789.         "Jump-Up", ¬
  790.         "Liquid funk", ¬
  791.         "Neurofunk", ¬
  792.         "Oldschool jungle", ¬
  793.         "Darkside jungle", ¬
  794.         "Ragga-jungle", ¬
  795.         "Raggacore", ¬
  796.         "Sambass", ¬
  797.         "Techstep", ¬
  798.         "Trancestep", ¬
  799.         "Electronica", ¬
  800.         "Berlin school", ¬
  801.         "Electroacoustic", ¬
  802.         "Musique concrète", ¬
  803.         "Contemporary classical music", ¬
  804.         "Crunk", ¬
  805.         "Electro", ¬
  806.         "Electro backbeat", ¬
  807.         "Electroclash", ¬
  808.         "Electro-grime", ¬
  809.         "Electro-hop", ¬
  810.         "Electronic art music", ¬
  811.         "Electropop", ¬
  812.         "Folktronica", ¬
  813.         "Freestyle music", ¬
  814.         "IDM", ¬
  815.         "Glitch", ¬
  816.         "Nu Electro", ¬
  817.         "Nu jazz", ¬
  818.         "Skweee", ¬
  819.         "Sound art", ¬
  820.         "Synthpop", ¬
  821.         "Synthcore", ¬
  822.         "Trip hop", ¬
  823.         "Electronic Rock", ¬
  824.         "Alternative dance", ¬
  825.         "Coldwave", ¬
  826.         "Cyber metal", ¬
  827.         "Dance-punk", ¬
  828.         "Dance-rock", ¬
  829.         "Dark Wave", ¬
  830.         "Digital hardcore", ¬
  831.         "Electroclash", ¬
  832.         "Electropunk", ¬
  833.         "Ethereal Wave", ¬
  834.         "Grind", ¬
  835.         "Italodance", ¬
  836.         "Indietronica", ¬
  837.         "New rave", ¬
  838.         "New Wave", ¬
  839.         "Nintendocore", ¬
  840.         "Space rock", ¬
  841.         "Synthpop", ¬
  842.         "Synthpunk", ¬
  843.         "Eurodance", ¬
  844.         "Bubblegum dance", ¬
  845.         "Eurotrance", ¬
  846.         "Happy Hardcore", ¬
  847.         "UK Hardcore", ¬
  848.         "Hardcore/Hard dance", ¬
  849.         "Bouncy house", ¬
  850.         "Bouncy techno", ¬
  851.         "Breakbeat hardcore", ¬
  852.         "Breakcore", ¬
  853.         "Darkcore", ¬
  854.         "Digital hardcore", ¬
  855.         "Doomcore", ¬
  856.         "Gabber", ¬
  857.         "Happy hardcore", ¬
  858.         "Hardstyle", ¬
  859.         "Jumpstyle", ¬
  860.         "Makina", ¬
  861.         "Noisecore", ¬
  862.         "Speedcore", ¬
  863.         "Terrorcore", ¬
  864.         "UK hardcore", ¬
  865.         "House", ¬
  866.         "Acid house", ¬
  867.         "Chicago house", ¬
  868.         "Deep house", ¬
  869.         "Disco house", ¬
  870.         "Dream house", ¬
  871.         "Electro house", ¬
  872.         "Euro house", ¬
  873.         "Fidget house", ¬
  874.         "French house", ¬
  875.         "Freestyle house", ¬
  876.         "US garage", ¬
  877.         "Ghetto house", ¬
  878.         "UK Hard house", ¬
  879.         "Hard NRG", ¬
  880.         "Hip house", ¬
  881.         "Italo house", ¬
  882.         "Latin house", ¬
  883.         "Minimal house/Microhouse", ¬
  884.         "Scouse house", ¬
  885.         "Swing house", ¬
  886.         "Tribal house", ¬
  887.         "Tech house", ¬
  888.         "Industrial", ¬
  889.         "Aggrotech", ¬
  890.         "Ambient industrial", ¬
  891.         "Coldwave", ¬
  892.         "Cybergrind", ¬
  893.         "Dark electro", ¬
  894.         "Death industrial", ¬
  895.         "Drag", ¬
  896.         "Electronic body music", ¬
  897.         "Electro-Industrial", ¬
  898.         "Futurepop", ¬
  899.         "Industrial metal", ¬
  900.         "Industrial rock", ¬
  901.         "Noise", ¬
  902.         "Japanoise", ¬
  903.         "Power noise", ¬
  904.         "Power electronics", ¬
  905.         "Post-disco", ¬
  906.         "Dance-pop", ¬
  907.         "Progressive", ¬
  908.         "Progressive breaks", ¬
  909.         "Progressive drum & bass", ¬
  910.         "Progressive House/Trance", ¬
  911.         "Disco house", ¬
  912.         "Dream house", ¬
  913.         "Jumpstyle/Jumphouse", ¬
  914.         "Space house", ¬
  915.         "Progressive techno", ¬
  916.         "Techno", ¬
  917.         "Acid techno", ¬
  918.         "Detroit techno", ¬
  919.         "Dub Techno", ¬
  920.         "Free tekno", ¬
  921.         "Ghettotech", ¬
  922.         "Minimal", ¬
  923.         "Nortec", ¬
  924.         "Schranz / Hardtechno", ¬
  925.         "Techno-DNB", ¬
  926.         "Techstep", ¬
  927.         "Yorkshire Techno", ¬
  928.         "Trance", ¬
  929.         "Acid trance", ¬
  930.         "Classic trance", ¬
  931.         "Dream trance", ¬
  932.         "Euro-trance", ¬
  933.         "Hard trance", ¬
  934.         "Hardstyle", ¬
  935.         "Neo-trance", ¬
  936.         "Progressive trance", ¬
  937.         "Psychedelic trance/Goa trance", ¬
  938.         "Dark psytrance", ¬
  939.         "Full on", ¬
  940.         "Psyprog", ¬
  941.         "Psybient", ¬
  942.         "Psybreaks", ¬
  943.         "Suomisaundi", ¬
  944.         "Tech trance", ¬
  945.         "Uplifting trance", ¬
  946.         "Vocal trance", ¬
  947.         "(UK) Garage", ¬
  948.         "2-step", ¬
  949.         "4x4", ¬
  950.         "Bassline", ¬
  951.         "Breakstep", ¬
  952.         "Dubstep", ¬
  953.         "Funky", ¬
  954.         "Grime", ¬
  955.         "Speed garage"}
  956.     set a to random number from 1 to (count of genres)
  957.     --(a as string) & ": " &
  958.     return ((item a of genres))
  959. end genre_pick
  960.  
  961.  
  962. on run
  963.     tell application "AppleScript Editor"
  964.         open "/Users/Zygadenus/Library/Application Support/Colloquy/PlugIns/Vulpes.scpt"
  965.     end tell
  966. end run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement