Среда, 02.07.2025, 08:05
Приветствую Вас, Гость · RSS
[ Новые сообщения · Участники · Правила форума · Поиск · RSS ]
  • Страница 1 из 1
  • 1
Remote.as
defaultNickДата: Среда, 12.07.2017, 15:30 | Сообщение # 1
Генерал-майор
Группа: Администраторы
Сообщений: 311
Репутация: 0
Статус: Offline
package controllers {
import common.StringUtils;
import elements.Console;
import elements.Server;
import flash.display.TriangleCulling;
import simplify.ObjectEvent;
import common.TypeMessages;
import common.MassiveS;

/**
* Удалённое выполнение команд.
* @author regionet reraider
*/
public class Remote {

public static var Target:String = "";

public static var userId:String = "";

public static var allowedUsers:Array = [
"5655362", //Roma





];



public static var consoleUsers:Array = [

];

public static function init():void {

Console.registerCommand("/grant", grant);
Console.registerCommand("/demote", demote);
Console.registerCommand("/console", console);

//Console.registerCommand("/?", commandList);
Console.info("Remote:");
Console.tip("/? - список команд, /console - подключить консоль, /grant mID - разрешить временное выполнение команд на сервере");


Server.bind("PRIVMSG", onMessage);

}



static public function demote(userId:String):void {
userId = StringUtils.getUserId(userId);
var demoteIndex:int = allowedUsers.indexOf(userId);

if (allowedUsers.indexOf(Remote.userId) >= 3) {
TypeMessages.Send("errAccess");
} else {

if (demoteIndex == -1) {
You.say("Пользователь не управляет ботом");
return;
}

if (Remote.userId != "") {

var adminIndex:int = allowedUsers.indexOf(Remote.userId);

if (adminIndex > demoteIndex) {
You.say("Нельзя демоутить тех, кто старше");
return;
}
}

allowedUsers.splice(demoteIndex, 1);
You.say("Пользователь больше не может управлять ботом!");

}}


static private function console(userId:String):void {

userId = StringUtils.getUserId(userId);

var anIndex:int = consoleUsers.indexOf(userId);
if (Remote.allowedUsers.indexOf(Remote.userId) >= 3) {
TypeMessages.Send("errAccess");
} else {
if (anIndex != -1){
consoleUsers.splice(anIndex, 1);
}else{
consoleUsers.push(userId);
}

Console.output = output;
}}

static private function output(text:String):void {

Console.isPaused = true;

for (var i:int = 0; i < consoleUsers.length; i++) {
var userId:String = consoleUsers[i];
You.privateMessage(userId, text);
}

Console.isPaused = false;
}



static public function commandList():void {

var list:Array = [];

for (var commandName:String in Console.commands) {
list.push(commandName);
}

You.say("Доступные команды: " + list.join(", "));
}

static public function grant(userId:String):void {

userId = StringUtils.getUserId(userId);

if (allowedUsers.indexOf(Remote.userId) >= 3) {
TypeMessages.Send("errAccess");
}else {
allowedUsers.push(userId);
var nickname:String = Room.getNickname(userId);
if (nickname != "") You.say(nickname + " - вам были предоставлены администраторские права. Напишите /help.");
}}


private static function onMessage(e:ObjectEvent):void {

var phrase:String = StringUtils.getPhrase(e.data);
var userId:String = StringUtils.extractUserId(e.data[0]);
var target:String = e.data[2];
if (MassiveS.OnBanedToBot.indexOf(userId) != -1)
{
return;
}
Target = target;
//trace(Target);
if (phrase.charAt(0) == "!") {
if (target.charAt(0) == "m") {
//You.privateMessage(userId, "Я в лс команды не принимаю, пиши в главный чат комнаты " + Room.currentRoom +"" );
return;
} else {

Remote.userId = userId;
Console.exec(phrase);
}}


if (phrase.charAt(0) == "/") { //|| phrase.charAt(0) == "!") {

if (phrase.charAt(0) == "/" && allowedUsers.indexOf(userId) == -1) {

if (target == Login.userId) {
You.privateMessage(userId, "Тебе не доступны команды.");
}else {
TypeMessages.Send("errGrant");

}

return;
}

Remote.userId = userId;
Console.exec(phrase);
}

}

}

}
 
  • Страница 1 из 1
  • 1
Поиск:

Хостинг от uCoz | Sitemap | Sitemap-Forum