Advertisement
Guest User

Untitled

a guest
Jun 14th, 2017
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 24.53 KB | None | 0 0
  1. require 'net/https'
  2.  
  3. custom_require.call(%w(lnet))
  4.  
  5. class Rshell
  6.  
  7.   def initialize
  8.     @api_url = 'https://slack.com/api/'
  9.     no_pause_all
  10.     @lnet = (Script.running + Script.hidden).find { |val| val.name == 'lnet' }
  11.     find_token unless authed?(UserVars.rshell_token)
  12.  
  13.     @channelType="channels.history"
  14.     @slack_shell = get_shell
  15.     @slack_user_id = get_user_id
  16.     @startFrom = Time.now.to_i
  17.     @last_command_timestamp = 0
  18.    
  19.     mainloop
  20.   end
  21.  
  22.   def mainloop
  23.     while true
  24.       commands = get_commands
  25.       commands.each do | command |
  26.         echo command
  27.         result = []
  28.         if command.start_with?(";chat") or command.start_with?(";reply")
  29.           command[0] = ''
  30.           lnet(command)
  31.          
  32.         elsif command == ";pa"
  33.           pause_scripts
  34.           next
  35.         elsif command == ";ua"
  36.           unpause_scripts
  37.           next
  38.         elsif command.start_with?(";reget")
  39.           lines = reget(command.split(' ')[1])
  40.           lines.each do | line |
  41.             result << line
  42.           end
  43.         elsif command.start_with?(";")
  44.           runscript(command)
  45.         else
  46.           fput(command)
  47.         end
  48.        
  49.         buffer_end = Time.now.to_i + 1
  50.         while line = get? or Time.now.to_i <= buffer_end
  51.           if line
  52.             result << line
  53.           end
  54.         end
  55.         output = ""
  56.         result.each do | line |
  57.           output << line << "\r\n"
  58.         end
  59.         params = { 'token' => UserVars.rshell_token, 'channel' => @slack_shell, 'text' => output, 'as_user' => true }
  60.         post('chat.postMessage',params)
  61.       end
  62.       pause 2        #Don't overload slack.  They rate limit to 1 request/second
  63.     end
  64.   end
  65.  
  66.   def authed?(token)
  67.     params = { 'token' => token }
  68.     res = post('auth.test', params)
  69.     body = JSON.parse(res.body)
  70.     body['ok']
  71.   end
  72.  
  73.   def post(method, params)
  74.     uri = URI.parse("#{@api_url}#{method}")
  75.     http = Net::HTTP.new(uri.host, uri.port)
  76.     http.use_ssl = true
  77.     http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  78.     req = Net::HTTP::Post.new(uri.path)
  79.     req.set_form_data(params)
  80.     return http.request(req)
  81.   end
  82.  
  83.   def direct_message(username, message)
  84.     dm_channel = get_dm_channel(username)
  85.  
  86.     params = { 'token' => UserVars.rshell_token, 'channel' => dm_channel, 'text' => "#{checkname}: #{message}", 'as_user' => true }
  87.     post('chat.postMessage', params)
  88.   end
  89.  
  90.   def get_dm_channel(username)
  91.     user = @users_list['members'].find { |u| u['name'] == username }
  92.     user['id']
  93.   end
  94.  
  95.   ##Get the shell to use for the character.  Must have channel already created: <username>_shell
  96.   def get_shell()
  97.     shell = checkname.downcase + "_shell"
  98.     params = { 'token' => UserVars.rshell_token}
  99.     response = post('groups.list', params)
  100.     JSON.parse(response.body)['groups'].each do | channel |
  101.       if channel["name"] == shell
  102.         @channelType="groups.history"
  103.         return channel["id"]
  104.       end
  105.     end
  106.     response = post('channels.list', params)
  107.     JSON.parse(response.body)['channels'].each do | channel |
  108.       if channel["name"] == shell
  109.         return channel["id"]
  110.       end
  111.     end
  112.     return nil
  113.   end
  114.  
  115.   ##Get the internal slack id of the slack user to prevent
  116.   def get_user_id()
  117.     username = get_settings.slack_username
  118.     params = { 'token' => UserVars.rshell_token}
  119.     response = post('users.list', params)
  120.     JSON.parse(response.body)['members'].each do | member |
  121.       if member["name"] == username
  122.         return member["id"]
  123.       end
  124.     end
  125.     return nil
  126.   end
  127.  
  128.   def get_commands()
  129.     commands = []
  130.     params = { 'token' => UserVars.rshell_token, 'channel' => @slack_shell, 'oldest' => @startFrom}
  131.     response = post(@channelType, params)
  132.     @startFrom = Time.now.to_f
  133.    
  134.     messages = JSON.parse(response.body)
  135.    
  136.     messages["messages"].each do | message |
  137.      
  138.       if message["user"] == @slack_user_id                                                      ##Prevent other people from controlling your guys
  139.         if message["ts"] != @last_command_timestamp                                              ##Prevent duplicate slack api message retrieval
  140.           if message["text"].start_with?("&gt;") or message["text"].start_with?(";")             ##Only get 'command' type messages ex: >look
  141.             @last_command_timestamp = message["ts"]
  142.             commands << clean_message(message["text"])
  143.           end
  144.         end
  145.       end
  146.     end
  147.     return commands
  148.   end
  149.  
  150.   def runscript(command)
  151.     command = command.sub(';','')
  152.     command_parts = command.split(' ')
  153.     script_name = command_parts.shift
  154.     start_script(script_name,command_parts)
  155.   end
  156.  
  157.   def clean_message(message)
  158.     message = message.sub("&gt;","")
  159.     message = message.strip
  160.     return message
  161.   end
  162.  
  163.   def lnet(msg)
  164.     if msg =~ /^chat\s+\:\:(.+?) (.*)/i or msg =~ /^chat\s+to\s+(.+?) (.*)/i
  165.       LNet.send_message(attr={'type'=>'private', 'to'=>$1}, $2)
  166.     elsif msg =~ /^chat\s+\:([^\:].*?) (.*)/i or msg =~ /^chat\s+on\s+(.+?) (.*)/i
  167.       LNet.send_message(attr={'type'=>'channel', 'channel'=>$1}, $2)
  168.     elsif msg =~ /^chat\s+(?!:\:|to |on |ot )(.*)/i
  169.       message = $1.sub(/^\.(to|on) /i, '\\1 ')
  170.       LNet.send_message(attr={'type'=>'channel'}, message)
  171.     elsif msg =~/reply\s(.+)/i
  172.       if LNet.last_priv
  173.         LNet.send_message(attr={'type'=>'private', 'to'=>LNet.last_priv}, $1)
  174.       else
  175.         echo "No private message to reply to."
  176.       end
  177.     elsif msg =~ /^who$/i
  178.       LNet.send_query(attr={'type'=>'connected'})
  179.     elsif msg =~ /^stats$/i
  180.       LNet.send_query(attr={'type'=>'server stats'})
  181.     elsif msg =~ /^who\s+([A-z\:]+)$/i
  182.       LNet.send_query(attr={'type'=>'connected', 'name'=>$1})
  183.     elsif msg =~ /^channels?\s*(full|all)?/i
  184.       if $1
  185.         LNet.send_query(attr={'type'=>'channels'})
  186.       else
  187.         LNet.send_query(attr={'type'=>'channels', 'num'=>'15'})
  188.       end
  189.     elsif msg =~ /^tune\s+([A-z]+)$/i
  190.       LNet.tune_channel($1)
  191.     elsif msg =~ /^untune\s+([A-z]+)$/i
  192.       LNet.untune_channel($1)
  193.     elsif msg =~ /^(spells|skills|info|locate|health|bounty)\s+([A-z\:]+)$/i
  194.       type = $1.downcase
  195.       name = $2
  196.       if LNet.ignored?(name)
  197.         echo "There's no point in sending a request to someone you're ignoring."
  198.       else
  199.         LNet.send_request(attr={'type'=>type, 'to'=>name})
  200.       end
  201.     elsif msg =~ /^add\s?alias\s+([^\s]+)\s+(.+)$/i
  202.       real_name = $1
  203.       aliased_name = $2
  204.       old_alias = LNet.alias[real_name]
  205.       LNet.alias[real_name] = aliased_name
  206.       echo "chats from #{real_name} will now appear as #{aliased_name}"
  207.       if real_name !~ /^[A-Z][A-z]+:[A-Z][a-z]+$/
  208.         echo "The name should be entered exactly as it appears in the thought window, for example:   ;lnet add alias GSIV:Jeril StrangerDanger"
  209.         echo "If #{real_name} is incorrect, you can remove it using:   ;lnet remove alias #{aliased_name}"
  210.       end
  211.     elsif msg =~ /^(?:del|rem|delete|remove)\s?alias\s+(.+)$/i
  212.       aliased_name = $1
  213.       if LNet.alias.values.any? { |v| v == aliased_name }
  214.         LNet.alias.delete_if { |k,v| v == aliased_name }
  215.         echo "alias deleted"
  216.       else
  217.         echo "couldn't find an alias by that name"
  218.       end
  219.     elsif msg =~ /^aliases$/i
  220.       if LNet.alias.empty?
  221.         echo 'You have no aliases.'
  222.       else
  223.         output = "\n"
  224.         max_k = 0; max_v = 0; LNet.alias.each_pair { |k,v| max_k = [max_k,k.length].max; max_v = [max_v,v.length].max }
  225.         LNet.alias.each_pair { |k,v|
  226.           output.concat "   #{k.ljust(max_k)} => #{v.ljust(max_v)}\n"
  227.         }
  228.         output.concat "\n"
  229.         respond output
  230.       end
  231.     elsif msg =~ /^add\s?friends?\s+([A-z]+\:)?([A-z]+)$/i
  232.       fix_game = { 'gsf' => 'GSF', 'gsiv' => 'GSIV', 'gsplat' => 'GSPlat' }
  233.       name = $2.capitalize
  234.       if game = $1.sub(/\:$/, '')
  235.         game = fix_game[game.downcase] if fix_game[game.downcase]
  236.         name = "#{game}:#{name}"
  237.       end
  238.       if LNet.options['friends'].include?(name)
  239.         echo "#{name} is already on your friend list."
  240.       else
  241.         LNet.options['friends'].push(name)
  242.         echo "#{name} was added to your friend list."
  243.       end
  244.     elsif msg =~ /^(?:del|rem|delete|remove)\s?friends?\s+([A-z]+\:)?([A-z]+)$/i
  245.       fix_game = { 'gsf' => 'GSF', 'gsiv' => 'GSIV', 'gsplat' => 'GSPlat' }
  246.       name = $2.capitalize
  247.       if game = $1.sub(/\:$/, '')
  248.         game = fix_game[game.downcase] if fix_game[game.downcase]
  249.         name = "#{game}:#{name}"
  250.       end
  251.       if LNet.options['friends'].delete(name)
  252.         echo "#{name} was removed from your friend list."
  253.       else
  254.         echo "#{name} was not found on your friend list."
  255.       end
  256.     elsif msg =~ /^add\s?en[ie]m(?:y|ies)\s+([A-z]+\:)?([A-z]+)$/i
  257.       fix_game = { 'gsf' => 'GSF', 'gsiv' => 'GSIV', 'gsplat' => 'GSPlat' }
  258.       name = $2.capitalize
  259.       if game = $1.sub(/\:$/, '')
  260.         game = fix_game[game.downcase] if fix_game[game.downcase]
  261.         name = "#{game}:#{name}"
  262.       end
  263.       if LNet.options['enemies'].include?(name)
  264.         echo "#{name} is already on your enemy list."
  265.       else
  266.         LNet.options['enemies'].push(name)
  267.         echo "#{name} was added to your enemy list."
  268.       end
  269.     elsif msg =~ /^(?:del|rem|delete|remove)\s?en[ie]m(?:y|ies)\s+([A-z]+\:)?([A-z]+)$/i
  270.       fix_game = { 'gsf' => 'GSF', 'gsiv' => 'GSIV', 'gsplat' => 'GSPlat' }
  271.       name = $2.capitalize
  272.       if game = $1.sub(/\:$/, '')
  273.         game = fix_game[game.downcase] if fix_game[game.downcase]
  274.         name = "#{game}:#{name}"
  275.       end
  276.       if LNet.options['enemies'].delete(name)
  277.         echo "#{name} was removed from your enemy list."
  278.       else
  279.         echo "#{name} was not found on your enemy list."
  280.       end
  281.     elsif msg =~ /^friends?$/i
  282.       if LNet.options['friends'].empty?
  283.         echo 'You have no friends.'
  284.       else
  285.         echo "friends: #{LNet.options['friends'].join(', ')}"
  286.       end
  287.     elsif msg =~ /^enem(?:y|ies)$/i
  288.       if LNet.options['enemies'].empty?
  289.         echo 'You have no enemies.'
  290.       else
  291.         echo "enemies: #{LNet.options['enemies'].join(', ')}"
  292.       end
  293.     elsif msg =~ /^allow$/i
  294.       fix_type = { 'all' => 'everyone', 'friends' => 'only your friends', 'enemies' => 'everyone except your enemies', 'none' => 'no one', nil => 'no one' }
  295.       fix_action = { 'locate' => 'locate you', 'spells' => 'view your active spells', 'skills' => "view your #{if rand(100)==0; 'mad '; end}skills", 'info' => 'view your stats', 'health' => 'view your health', 'bounty' => 'view your bounties' }
  296.       [ 'locate', 'spells', 'skills', 'info', 'health', 'bounty' ].each { |action|
  297.         respond "You are allowing #{fix_type[LNet.options['permission'][action]]} to #{fix_action[action]}."
  298.       }
  299.     elsif msg =~ /^allow\s+(locate|spells|skills|info|health|bounty|all)\s+(all|friend|friends|non\-enemies|nonenemies|enemies|enemy|none)$/i
  300.       action, group = $1, $2
  301.       fix_action = { 'locate' => 'locate you', 'spells' => 'view your active spells', 'skills' => "view your #{if rand(100)==0; 'mad '; end}skills", 'info' => 'view your stats', 'health' => 'view your health', 'bounty' => 'view your bounties' }
  302.       if action =~ /^all$/i
  303.         for action in [ 'locate', 'spells', 'skills', 'info', 'health', 'bounty' ]
  304.             if group =~ /^all$/i
  305.               LNet.options['permission'][action] = 'all'
  306.               echo "You are now allowing everyone to #{fix_action[action]}."
  307.             elsif group =~ /^friends?$/i
  308.               LNet.options['permission'][action] = 'friends'
  309.               echo "You are now allowing only your friends to #{fix_action[action]}."
  310.             elsif group =~ /enem/i
  311.               LNet.options['permission'][action] = 'enemies'
  312.               echo "You are now allowing everyone except your enemies to #{fix_action[action]}."
  313.             elsif group =~ /^none$/i
  314.               LNet.options['permission'][action] = 'none'
  315.               echo "You are now allowing no one to #{fix_action[action]}."
  316.             end
  317.         end
  318.       elsif group =~ /^all$/i
  319.         LNet.options['permission'][action] = 'all'
  320.         echo "You are now allowing everyone to #{fix_action[action]}."
  321.       elsif group =~ /^friends?$/i
  322.         LNet.options['permission'][action] = 'friends'
  323.         echo "You are now allowing only your friends to #{fix_action[action]}."
  324.       elsif group =~ /enem/i
  325.         LNet.options['permission'][action] = 'enemies'
  326.         echo "You are now allowing everyone except your enemies to #{fix_action[action]}."
  327.       elsif group =~ /^none$/i
  328.         LNet.options['permission'][action] = 'none'
  329.         echo "You are now allowing no one to #{fix_action[action]}."
  330.       end
  331.     elsif msg =~ /^ignore$/i
  332.       if LNet.options['ignore'].empty?
  333.         echo 'You are not ignoring anyone.'
  334.       else
  335.         echo "You are ignoring the following people: #{LNet.options['ignore'].join(', ')}"
  336.       end
  337.     elsif msg =~ /^ignore\s+([A-z]+\:)?([A-z]+)$/i
  338.       fix_game = { 'gsf' => 'GSF', 'gsiv' => 'GSIV', 'gsplat' => 'GSPlat' }
  339.       name = $2.capitalize
  340.       if game = $1.sub(/\:$/, '')
  341.         game = fix_game[game.downcase] if fix_game[game.downcase]
  342.         name = "#{game}:#{name}"
  343.       end
  344.       if LNet.options['ignore'].include?(name)
  345.         echo "You were already ignoring #{name}."
  346.       else
  347.         LNet.options['ignore'].push(name)
  348.         echo "You are now ignoring #{name}."
  349.       end
  350.     elsif msg =~ /^unignore\s+([A-z]+\:)?([A-z]+)$/i
  351.       fix_game = { 'gsf' => 'GSF', 'gsiv' => 'GSIV', 'gsplat' => 'GSPlat' }
  352.       name = $2.capitalize
  353.       if game = $1.sub(/\:$/, '')
  354.         game = fix_game[game.downcase] if fix_game[game.downcase]
  355.         name = "#{game}:#{name}"
  356.       end
  357.       if LNet.options['ignore'].delete(name)
  358.         echo "You are no longer ignoring #{name}."
  359.       else
  360.         echo "#{name} wasn't being ignored."
  361.       end
  362.     elsif msg =~ /^timestamps?=(on|off)$/i
  363.       if $1 == 'on'
  364.         LNet.options['timestamps'] = true
  365.         echo 'timestamps will be shown'
  366.       else
  367.         LNet.options['timestamps'] = false
  368.         echo 'timestamps will not be shown'
  369.       end
  370.     elsif msg =~ /^famwindow=(on|off)$/i
  371.       if $1 == 'on'
  372.         LNet.options['fam_window'] = true
  373.         echo 'chats will be sent to the familiar window'
  374.       else
  375.         LNet.options['fam_window'] = false
  376.         echo 'chats will be sent to the thought window'
  377.       end
  378.     elsif msg =~ /^greeting=(on|off)$/i
  379.       if $1 == 'on'
  380.         LNet.options['greeting'] = true
  381.         echo 'greeting will be shown at login'
  382.       else
  383.         LNet.options['greeting'] = false
  384.         echo 'getting will not be shown'
  385.       end
  386.     elsif msg =~ /^password=([^\s]+)$/i
  387.       LNet.send_data(attr={'type'=>'newpassword'}, $1)
  388.       if $1 == 'nil'
  389.         LNet.secret = nil
  390.         echo 'Password cleared.'
  391.       else
  392.         LNet.secret = $1
  393.         echo 'Password saved locally.'
  394.       end
  395.     elsif msg =~ /^email=([^\s]+)$/i
  396.       LNet.send_data(attr={'type'=>'newemail'}, $1)
  397.     elsif msg =~ /^(ban|gag|mod|banip)\s+([\:A-z0-9]+)\s+on\s+([A-z]+)$/i
  398.       LNet.moderate(attr={'action'=>$1.downcase, 'name'=>$2, 'channel'=>$3})
  399.     elsif msg =~ /^(ban|gag|banip)\s+([\:A-z0-9]+)\s+on\s+([A-z]+)\s+for\s+([0-9]+)\s*(seconds?|minutes?|hours?|days?|years?|s|m|h|d|y)$/i
  400.       multiplier = { nil => 1, 's' => 1, 'second' => 1, 'seconds' => 1, 'm' => 60, 'minute' => 60, 'minutes' => 60, 'h' => 3600, 'hour' => 3600, 'hours' => 3600, 'd' => 86400, 'day' => 86400, 'days' => 86400, 'y' => 31536000, 'year' => 31536000, 'years' => 31536000 }
  401.       LNet.moderate(attr={'action'=>$1.downcase, 'name'=>$2, 'channel'=>$3, 'length'=>($4.to_i * multiplier[$5]).to_s})
  402.     elsif msg =~ /^(unban|ungag|unmod)\s+([\:A-z0-9]+)\s+on\s+([A-z]+)$/i
  403.       LNet.moderate(attr={'action'=>$1.downcase, 'name'=>$2, 'channel'=>$3})
  404.     elsif msg =~ /^create\s+(hidden)?\s*(private)?\s*channel\s+([A-z]+)\s+(.+?)$/i
  405.       attr = attr={ 'action'=>'create channel', 'name'=>$3, 'description'=>$4.strip }
  406.       if $1
  407.         attr['hidden'] = 'yes'
  408.       else
  409.         attr['hidden'] = 'no'
  410.       end
  411.       if $2
  412.         attr['private'] = 'yes'
  413.       else
  414.         attr['private'] = 'no'
  415.       end
  416.       LNet.admin(attr)
  417.     elsif msg =~ /^create\s+poll\s+/i
  418.       if msg =~ /\-\-question\s+(.+?)\s*(?:\-\-|$)/
  419.         question = $1[0,512].strip
  420.       else
  421.         question = nil
  422.       end
  423.       if msg =~ /\-\-vote\-time\s+([0-9]+)\s*(seconds?|minutes?|hours?|days?|years?|s|m|h|d|y)(?:\-\-|$)/
  424.         multiplier = { nil => 1, 's' => 1, 'second' => 1, 'seconds' => 1, 'm' => 60, 'minute' => 60, 'minutes' => 60, 'h' => 3600, 'hour' => 3600, 'hours' => 3600, 'd' => 86400, 'day' => 86400, 'days' => 86400, 'y' => 31536000, 'year' => 31536000, 'years' => 31536000 }
  425.         vote_time = $1.to_i * multiplier[$2]
  426.       else
  427.         vote_time = nil
  428.       end
  429.       num = 1
  430.       option = Hash.new
  431.       while msg =~ /\-\-option\-#{num}\s+(.+?)\s*(?:\-\-|$)/
  432.         option[num] = $1[0,64].strip
  433.         num += 1
  434.       end
  435.       if question and (option.length > 1)
  436.         attr = { 'action'=>'create poll', 'question'=>question }
  437.         option.each_pair { |num,opt| attr["option #{num}"] = opt }
  438.         if vote_time
  439.             attr['length'] = vote_time
  440.         end
  441.         # fixme: confirm
  442.         LNet.admin(attr)
  443.       else
  444.         echo "You're doing it wrong.  Type #{$clean_lich_char}#{script.name} help"
  445.       end
  446.     elsif msg =~ /^delete\s+channel\s+([A-z]+)$/i
  447.       LNet.admin(attr={'action'=>'delete channel', 'name'=>$1})
  448.     elsif msg =~ /^eval (.+)$/
  449.       LNet.send_data(attr={'type'=>'eval'}, $1)
  450.     elsif msg =~ /^help$/i
  451.       output = String.new
  452.       output.concat "\n"
  453.       output.concat "#{$clean_lich_char}chat <message>                     send a message to your default channel\n"
  454.       output.concat "#{$clean_lich_char},<message>                         ''\n"
  455.       output.concat "#{$clean_lich_char}chat on <channel name> <message>   send a message to the given channel\n"
  456.       output.concat "#{$clean_lich_char}chat :<channel name> <message>     ''\n"
  457.       output.concat "#{$clean_lich_char}chat to <name> <message>           send a private message\n"
  458.       output.concat "#{$clean_lich_char}chat ::<name> <message>            ''\n"
  459.       output.concat "#{$clean_lich_char}<name>:<message>                   ''\n"
  460.       output.concat "#{$clean_lich_char}who                                list who's connected\n"
  461.       output.concat "#{$clean_lich_char}who <channel>                      list who's tuned into the given channel\n"
  462.       output.concat "#{$clean_lich_char}who <name>                         tells if a user is connected\n"
  463.       output.concat "#{$clean_lich_char}channels                           list the 15 most populated channels\n"
  464.       output.concat "#{$clean_lich_char}channels full                      list all available channels\n"
  465.       output.concat "#{$clean_lich_char}tune <channel name>                listen to the given channel, or set as default if already tuned\n"
  466.       output.concat "#{$clean_lich_char}untune <channel name>              stop listening to the given channel\n"
  467.       output.concat "\n"
  468.       output.concat "#{$clean_lich_char}locate <name>                      show someone's current room\n"
  469.       output.concat "#{$clean_lich_char}spells <name>                      show someone's active spells and time remaining\n"
  470.       output.concat "#{$clean_lich_char}skills <name>                      show someone's skills\n"
  471.       output.concat "#{$clean_lich_char}info <name>                        show someone's stats\n"
  472.       output.concat "#{$clean_lich_char}health <name>                      show someone's health, spirit, stamina and injuries\n"
  473.       output.concat "#{$clean_lich_char}bounty <name>                      show someone's current adventurer's guild task\n"
  474.       output.concat "\n"
  475.       output.concat "#{$clean_lich_char}#{script.name} stats                         unhelpful information\n"
  476.       output.concat "#{$clean_lich_char}#{script.name} timestamps=<on/off>           turn on/off all chats having a timestamp\n"
  477.       output.concat "#{$clean_lich_char}#{script.name} famwindow=<on/off>            turn on/off sending chats to your familiar window\n"
  478.       output.concat "#{$clean_lich_char}#{script.name} greeting=<on/off>             turn on/off showing a server greeting at logon\n"
  479.       output.concat "\n"
  480.       output.concat "#{$clean_lich_char}#{script.name} friends                       list friends\n"
  481.       output.concat "#{$clean_lich_char}#{script.name} add friend <name>             add a name to your friend list\n"
  482.       output.concat "#{$clean_lich_char}#{script.name} del friend <name>             delete a name from your friend list\n"
  483.       output.concat "\n"
  484.       output.concat "#{$clean_lich_char}#{script.name} enemies                       list enemies\n"
  485.       output.concat "#{$clean_lich_char}#{script.name} add enemy <name>              add a name to your enemy list\n"
  486.       output.concat "#{$clean_lich_char}#{script.name} del enemy <name>              delete a name from your enemy list\n"
  487.       output.concat "\n"
  488.       output.concat "#{$clean_lich_char}#{script.name} allow                         list your current permissions\n"
  489.       output.concat "#{$clean_lich_char}#{script.name} allow <action> <group>        set permissions\n"
  490.       output.concat "      <action> can be one of: locate, spells, skills, info, health, bounty, all\n"
  491.       output.concat "      <group> can be one of: all, friends, non-enemies, none\n"
  492.       output.concat "\n"
  493.       output.concat "#{$clean_lich_char}#{script.name} aliases                       list aliases\n"
  494.       output.concat "#{$clean_lich_char}#{script.name} add alias <name> <new_name>   causes chats from name to appear as new_name\n"
  495.       output.concat "#{$clean_lich_char}#{script.name} del alias <new_name>          delete an alias\n"
  496.       output.concat "\n"
  497.       output.concat "#{$clean_lich_char}#{script.name} ignore                        list names currently being ignored\n"
  498.       output.concat "#{$clean_lich_char}#{script.name} ignore <name>                 ignore chats/private chats/data requests from a person\n"
  499.       output.concat "#{$clean_lich_char}#{script.name} unignore <name>               unignore a person\n"
  500.       output.concat "\n"
  501.       output.concat "#{$clean_lich_char}#{script.name} password=<password>           protect your character name on the server with a password\n"
  502.       output.concat "#{$clean_lich_char}#{script.name} password=nil                  remove password protection\n"
  503. #      output.concat "#{$clean_lich_char}#{script.name} email=<email>                 save your email address on the server for password recovery\n"
  504. #      output.concat "#{$clean_lich_char}#{script.name} email=nil                     delete your email address from the server\n"
  505.       output.concat "\n"
  506.       output.concat "#{$clean_lich_char}#{script.name} create [hidden] [private] channel <name> <description>\n"
  507.       output.concat "      hidden channels don't show up in the channel list\n"
  508.       output.concat "      private channels ban everyone by default, and the owner (or moderator) must unban anyone he wants to allow in\n"
  509. #      output.concat "#{$clean_lich_char}#{script.name} modify channel <name> <new description>\n"
  510.       output.concat "#{$clean_lich_char}#{script.name} delete channel <name>\n"
  511.       output.concat "\n"
  512.       output.concat "#{$clean_lich_char}#{script.name} ban <character> on <channel> for <time>\n"
  513.       output.concat "#{$clean_lich_char}#{script.name} unban <character> on <channel>\n"
  514.       output.concat "#{$clean_lich_char}#{script.name} gag <character> on <channel> for <time>\n"
  515.       output.concat "#{$clean_lich_char}#{script.name} ungag <character> on <channel>\n"
  516.       output.concat "#{$clean_lich_char}#{script.name} mod <character> on <channel>\n"
  517.       output.concat "#{$clean_lich_char}#{script.name} unmod <character> on <channel>\n"
  518.       output.concat "      <time> should be a number followed by one of: seconds, minutes, hours, days, or years (may be abbreviated to one letter)\n"
  519.       output.concat "\n"
  520.       respond output
  521.     else
  522.       echo "You're doing it wrong.  Type #{$clean_lich_char}#{script.name} help"
  523.     end
  524.   end
  525.  
  526.  
  527.   def pause_scripts
  528.     Script.running.find_all { |s| not s.paused? and not s.no_pause_all }.each { |s| s.pause; did_something  = true }
  529.   end    
  530.  
  531.   def unpause_scripts
  532.     Script.running.find_all { |s| s.paused? and not s.no_pause_all }.each { |s| s.unpause; did_something = true }
  533.   end
  534. end
  535.  
  536. Rshell.new
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement