Exemple #1
0
        public async Task GetInfo()
        {
            var emb = new EmbedBuilder
            {
                Title       = "Server info",
                Description = "There are informations about server."
            };

            emb.WithAuthor(Context.Client.CurrentUser);
            emb.WithColor(Color.Blue);
            emb.WithFooter("IceBot v" + BotInfo.GetBotVersion());
            emb.WithThumbnailUrl("https://cdn.discordapp.com/icons/516650791885471744/394b8f725ee8bfa2c770bc20bb206254.png");
            emb.AddField("Owner", Context.Guild.Owner.Username + "#" + Context.Guild.Owner.Discriminator);
            emb.AddField("Created at", Context.Guild.CreatedAt.ToString("dd.MM.yyyy - HH:mm:ss"));
            emb.AddField("Location", Context.Guild.VoiceRegionId);
            emb.AddField("All member count", Context.Guild.Users.Count);
            emb.AddField("Bot author", "Sevenisko#3292");
            await ReplyAsync(null, false, emb.Build());
        }
Exemple #2
0
        public static BotInfo GetBotInfo()
        {
            try
            {
                string name = GetBotName();

                BotInfo bot = new BotInfo();
                using (MarketBotDbContext db = new MarketBotDbContext())
                {
                    bot = db.BotInfo.Where(b => b.Name == name).Include(b => b.Configuration).FirstOrDefault();

                    return(db.BotInfo.FirstOrDefault());
                }
            }

            catch (Exception e)
            {
                return(null);
            }
        }
Exemple #3
0
 static void ReadBots()
 {
     using (StreamReader reader = new StreamReader("bot.conf"))
     {
         while (!reader.EndOfStream)
         {
             string line = reader.ReadLine().Trim();
             if (line.Length > 0 && line[0] == '!')
             {
                 BotInfo newBot = new BotInfo();
                 newBot.name    = line;
                 newBot.command = reader.ReadLine().Trim();
                 newBot.desc    = reader.ReadLine().Trim();
                 line           = reader.ReadLine().Trim();
                 newBot.flags   = line.Split(' ');
                 Bots.Add(newBot);
             }
         }
     }
 }
Exemple #4
0
    public void UpdateCurrentBot(int id)
    {
        if (currentBot != null)
        {
            SaveCurrentBehavior();
            ClearExistingBlocks();
        }

        currentBot = DataManager.Instance.AllBots[id];
        BotPreviewController.UpdateCurrentPreview(currentBot);

        UpdateBotSpecificBlocks();

        if (currentBot.Behaviors.Count > 0)
        {
            DisplayBehaviorForTrigger(currentBot.Behaviors[0].Trigger);
        }

        UpdateTriggerLists();
    }
        /// <summary>
        /// TODO maybe make Start async
        /// </summary>
        /// <param name="_sender"></param>
        /// <param name="_e"></param>
        private void StartClick(object _sender, RoutedEventArgs _e)
        {
            foreach (object botName in BotList.Items)
            {
                Task.Run(() =>
                {
                    BotListItem newBot = (BotListItem)botName;

                    if (newBot.m_Selected)
                    {
                        Console.WriteLine(newBot.m_Name);

                        BotInfo botInfo = JsonConvert.DeserializeObject <BotInfo>(File.ReadAllText(m_pathToFiles + "/Configs/" + newBot.m_Name + ".json"));

                        Bot bot = new Bot(botInfo);

                        bot.Start();
                    }
                });
            }
        }
Exemple #6
0
    private void LoadBot(int teamIndex, int botIndex)
    {
        BotInfo       botInfo    = teams[teamIndex].Bots[botIndex];
        GameObject    botObject  = Instantiate(Resources.Load <GameObject>("Battle/BasicBot"));
        BotController controller = botObject.GetComponent <BotController>();

        if (controller != null)
        {
            bots[teamIndex].Add(controller);
        }
        controller.LoadInfo(botInfo, teams[teamIndex]);

        botObject.transform.SetPositionAndRotation(locations[teamIndex][botIndex].transform.position,
                                                   locations[teamIndex][botIndex].transform.rotation);

        GameObject statusDisplayObject =
            Instantiate(Resources.Load <GameObject>("Battle/BotStatusDisplay"), huds[teamIndex].transform);
        BotStatusDisplay display = statusDisplayObject.GetComponent <BotStatusDisplay>();

        display.LoadBot(controller);
    }
Exemple #7
0
        public IActionResult Save(BotInfo bot)
        {
            using (MarketBotDbContext db = new MarketBotDbContext())
            {
                var spl     = bot.Token.Split(':');
                int chat_id = Convert.ToInt32(spl[0]);

                BotInfo botInfo = new BotInfo
                {
                    Name      = bot.Name,
                    Token     = bot.Token,
                    ChatId    = chat_id,
                    Timestamp = DateTime.Now
                };

                db.BotInfo.Add(botInfo);
                db.SaveChanges();
                Editor();
                return(Ok());
            }
        }
        public static void sendInfo(byte[] wallet_address)
        {
            int default_group = Int32.Parse(Node.settings.getOption("defaultGroup", "0"));

            var      user = Node.users.getUser(wallet_address);
            bool     send_notifications = user.sendNotification;
            int      role_index         = user.getPrimaryRole();
            BotGroup group;

            if (Node.groups.groupIndexToName(role_index) != "")
            {
                group = Node.groups.getGroup(Node.groups.groupIndexToName(role_index));
            }
            else
            {
                string group_name = Node.groups.groupIndexToName(default_group);
                if (group_name != null)
                {
                    group = Node.groups.getGroup(group_name);
                }
                else
                {
                    return;
                }
            }
            IxiNumber cost  = 0;
            bool      admin = false;

            if (group != null)
            {
                cost = group.messageCost;
                if (group.admin)
                {
                    admin = true;
                }
            }
            BotInfo bi = new BotInfo(0, Node.settings.getOption("serverName", "Bot"), Node.settings.getOption("serverDescription", "Bot"), cost, Int32.Parse(Node.settings.getOption("generatedTime", "0")), admin, default_group, Int32.Parse(Node.settings.getOption("defaultChannel", "0")), send_notifications, Node.users.contacts.Count);

            sendBotAction(wallet_address, SpixiBotActionCode.info, bi.getBytes());
        }
        private void InsertNewBotToDb(string token, string name, string Url, bool IsServerVersion = false)
        {
            if (db == null)
            {
                db = new MarketBotDbContext();
            }

            if (token != null && name != null && Url != null)
            {
                var spl     = token.Split(':');
                int chat_id = Convert.ToInt32(spl[0]);

                BotInfo botInfo = new BotInfo
                {
                    Token         = token,
                    Name          = name,
                    WebHookUrl    = Url,
                    Timestamp     = DateTime.Now,
                    HomeVersion   = !IsServerVersion,
                    ServerVersion = IsServerVersion,
                    ChatId        = chat_id
                };

                db.BotInfo.Add(botInfo);
                db.SaveChanges();

                var conf = new Configuration {
                    BotInfoId = botInfo.Id, VerifyTelephone = false, OwnerPrivateNotify = false, Delivery = true, Pickup = false, ShipPrice = 0, FreeShipPrice = 0, CurrencyId = 1, BotBlocked = false
                };
                db.Configuration.Add(conf);
                db.SaveChanges();

                Company company = new Company {
                    Instagram = "https://www.instagram.com/", Vk = "https://www.vk.com/", Chanel = "https://t.me/", Chat = "https://t.me/"
                };
                db.Company.Add(company);
                db.SaveChanges();
            }
        }
        public async Task <IActionResult> SetWebHook([FromBody] BotInfo botInfo)
        {
            try
            {
                DbContext = new BotMngmntDbContext();

                if (botInfo != null && botInfo.Id > 0)
                {
                    var _botInfo = DbContext.BotInfo.Find(botInfo.Id);

                    _botInfo.Name       = botInfo.Name;
                    _botInfo.Token      = botInfo.Token;
                    _botInfo.WebHookUrl = botInfo.WebHookUrl;

                    DbContext.SaveChanges();
                }

                if (botInfo != null && botInfo.Id == 0)
                {
                    DbContext.Add <BotInfo>(botInfo);
                    DbContext.SaveChanges();
                }

                await BusinessLayer.TelegramFunction.SetWebHook(botInfo.Token, botInfo.WebHookUrl);

                return(Ok());
            }

            catch (Exception e)
            {
                return(Json(e.Message));
            }

            finally
            {
                DbContext.Dispose();
            }
        }
Exemple #11
0
        public static async Task Init(MiraiHttpSession session, BotStartupConfig config)
        {
            BotAPI.Init(session);

            BotReg.Init();
            BotAuth.Init();
            await BotInfo.ReloadAll();

            MiddlewareCore.Init(config.Middlewares.ToArray());
            ModuleCore.Init(config.assembly);
            ServiceCore.Init(config.assembly);
            ComponentCore.Init(config.assembly);

            _ = Task.Run(async() =>
            {
                TimeSpan delta = config.autoSave;
                while (AutoSave && delta > TimeSpan.Zero)
                {
                    await Task.Delay(config.autoSave);
                    foreach (var w in MiddlewareCore.Middlewares)
                    {
                        w.SaveData();
                    }
                    foreach (var m in ModuleCore.Modules)
                    {
                        m.SaveData();
                    }
                    foreach (var s in ServiceCore.Services)
                    {
                        s.SaveData();
                    }
                    foreach (var c in ComponentCore.Components)
                    {
                        c.SaveData();
                    }
                }
            });
        }
Exemple #12
0
    // Start is called before the first frame update
    void Start()
    {
        DataManager.Instance.Latch(this);
        if (!DataManager.Instance.AuthEstablished)
        {
            DataManager.Instance.BypassAuth("DEV [email protected]");
        }


        StartCoroutine(DataManager.Instance.FetchInitialData(success =>
        {
            if (!success)
            {
                return;
            }

            userBots = new List <BotInfo>(DataManager.Instance.AllBots);


            IEnumerator <BotInfo> userBotEnum = userBots.GetEnumerator();
            userBotEnum.MoveNext();
            foreach (var bot in userBotArray)
            {
                bot.BotInfo = userBotEnum.Current;
                botPreviews.Add(bot.gameObject);
                userBotEnum.MoveNext();
            }
            userBotEnum.Dispose();

            userTeams = DataManager.Instance.UserTeams;
            BotPreviewGenerator.BotGenerators = botPreviews;
            BotPreviewGenerator.CreateAllBotImages();
            defaultBody    = DataManager.Instance.GetPart(100);
            defaultBotInfo = new BotInfo(0, "default", 0, new List <PartInfo>(), defaultBody, new List <BehaviorInfo>());
            InstantiateTeams();
        }));
    }
Exemple #13
0
        public BotInfo ScanBots(BotInfo bot, float heading, float resolution)
        {
            BotInfo result = null;

            resolution = GameMath.MinMax(0.01f, resolution, bot.RadarMaxResolution);
            FindBotsByDistance(bot.X, bot.Y, (other, distance) => {
                // skip ourselves
                if (other.Id == bot.Id)
                {
                    return(true);
                }

                // compute relative position
                var deltaX = other.X - bot.X;
                var deltaY = other.Y - bot.Y;

                // check if other bot is beyond scan range
                if (distance > bot.RadarRange)
                {
                    // no need to enumerate more
                    return(false);
                }

                // check if delta angle is within resolution limit
                var angle = MathF.Atan2(deltaX, deltaY) * 180.0f / MathF.PI;
                if (MathF.Abs(GameMath.NormalizeAngle(heading - angle)) <= resolution)
                {
                    // found a bot within range and resolution; stop enumerating
                    result = other;
                    return(false);
                }

                // enumerate more
                return(true);
            });
            return(result);
        }
Exemple #14
0
        public static bool CheckGameOwnsOnBot(List <int> AppIDs, BotInfo bot)
        {
            if (bot.GamesHave != null)
            {
                foreach (var appid in AppIDs)
                {
                    if (bot.GamesHave.Contains(appid))
                    {
                        return(false);///ja tem algum dos jogos
                    }
                }
            }

            string URL = $"http://{Main._Main.txt_IPC.Text}:{Main._Main.txt_PORT.Text}/Api/Command";

            string       AppIDsString = string.Join(",", AppIDs.ToArray());
            Exec_Command comando      = new Exec_Command {
                Command = $"owns {bot.BotName} {AppIDsString}"
            };

            string json = JsonConvert.SerializeObject(comando);

            var http = (HttpWebRequest)WebRequest.Create(new Uri(URL));

            http.Accept          = "application/json";
            http.ContentType     = "application/json";
            http.Method          = "POST";
            http.PreAuthenticate = true;
            http.Headers.Add("Authentication", Main._Main.txt_passIPC.Text);

            ASCIIEncoding encoding = new ASCIIEncoding();

            Byte[] bytes = encoding.GetBytes(json);

            Stream newStream = http.GetRequestStream();

            newStream.Write(bytes, 0, bytes.Length);
            newStream.Close();

            var response = http.GetResponse();

            var stream  = response.GetResponseStream();
            var sr      = new StreamReader(stream);
            var content = sr.ReadToEnd();

            Exec_ComandResponse resp = JsonConvert.DeserializeObject <Exec_ComandResponse>(content);

            if (resp.Success)
            {
                List <string> Results = resp.Result.Split(new[] { "\n" }, StringSplitOptions.None).ToList();

                var OwnsGame = Results.Where(a => a.Contains("Owned already") || a.Contains("Já possui")).FirstOrDefault();

                if (OwnsGame == null)
                {
                    return(true);
                }
                else
                {
                    int gameIDOwned = AppIDs.Where(a => OwnsGame.Contains(a.ToString())).FirstOrDefault();

                    if (gameIDOwned != 0)
                    {
                        Log.orange($"<ASF_Owns> <{bot.BotName}> Have AppID {gameIDOwned}");
                        Update_Bots_DB.Add_active_Game_to_File(bot.SteamID, new List <int> {
                            gameIDOwned
                        });
                    }

                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
 public InsertNewOrder(int FollowerId, BotInfo BotInfo)
 {
     this.FollowerId = FollowerId;
     this.BotInfo    = BotInfo;
     db = new MarketBotDbContext();
 }
Exemple #16
0
 public DeliveryPriceMessage(BotInfo bot)
 {
     this.BotInfo = bot;
 }
Exemple #17
0
 /// <summary>
 /// Constructor to initialize this class and our botInfo variable
 /// </summary>
 /// <param name="_botinfo"></param>
 public ChatHandler(BotInfo _botinfo)
 {
     m_botInfo = _botinfo;
 }
Exemple #18
0
 public Task InviteAsync()
 {
     return(SimpleEmbedAsync($"You may invite the bot to your own server using the following URL: {BotInfo.GetInvite(Context)}"));
 }
Exemple #19
0
 public void LoadInfoForPreview(BotInfo botInfo)
 {
     info = botInfo;
     LoadParts();
 }
Exemple #20
0
        public async Task <IActionResult> SaveInfo(BotInfo _bot, IFormFile file = null)
        {
            if (_bot != null)
            {
                TelegramBot = new TelegramBotClient(_bot.Token);

                db = new MarketBotDbContext();

                var reapet_bot = db.BotInfo.Where(b => b.Name == Bot.GeneralFunction.GetBotName()).FirstOrDefault();

                botInfo = db.BotInfo.Where(b => b.Id == _bot.Id).FirstOrDefault();

                Telegram.Bot.Types.FileToSend toSend;

                if (file != null)
                {
                    toSend = ConvertToFileToSend(file);
                }

                if (_bot.WebHookUrl != null && TelegramBot != null && _bot.WebHookUrl != null && file != null)     // обновляем вебхук
                {
                    await TelegramBot.SetWebhookAsync(_bot.WebHookUrl + "/bot/", toSend);
                }

                if (_bot.WebHookUrl != null && TelegramBot != null && _bot.WebHookUrl != null && file == null)     // обновляем вебхук
                {
                    await TelegramBot.SetWebhookAsync(_bot.WebHookUrl + "/bot/");
                }

                //TelegramBot.ExportChatInviteLinkAsync()

                if (_bot.Id == 0 && reapet_bot == null)     //Бот еще не настроен. Добавляем новые данные
                {
                    _bot.Name          = Bot.GeneralFunction.GetBotName();
                    _bot.ServerVersion = false;
                    _bot.HomeVersion   = false;
                    _bot.Configuration = new Configuration {
                        VerifyTelephone = false, OwnerPrivateNotify = false, Delivery = true, Pickup = false, ShipPrice = 0, FreeShipPrice = 0, CurrencyId = 1, BotBlocked = false
                    };
                    _bot = InsertBotInfo(_bot);
                    Company company = new Company {
                        Instagram = "https://www.instagram.com/", Vk = "https://vk.com/", Chanel = "https://t.me/", Chat = "https://t.me/"
                    };
                    db.Company.Add(company);
                    return(View("Own", "/owner" + _bot.Token.Split(':').ElementAt(1).Substring(0, 15)));
                }

                if (_bot.Id > 0)     // редактируем уже сущестующие данные
                {
                    UpdateBotInfo(_bot);

                    //если по каким то причинам пользователь не подрвердил себя как владельца
                    if (_bot.OwnerChatId == null)
                    {
                        return(View("Own", "/owner" + _bot.Token.Split(':').ElementAt(1).Substring(0, 15)));
                    }

                    return(RedirectToAction("Index"));
                }

                else
                {
                    return(RedirectToAction("Index"));
                }
            }


            else
            {
                return(RedirectToAction("Index"));
            }
        }
Exemple #21
0
 //Generates an image for the bot via the BotPreviewGenerator using the given bot info and the object
 //the Image is to be generated onto
 void CreateBotImage(BotInfo botInfo, GameObject botGenerator)
 {
     BotPreviewGenerator.CreateBotImage(botInfo, botGenerator);
 }
Exemple #22
0
 public AdditionalProductPhotoSearchInline(string Query, BotInfo botInfo) : base(Query)
 {
     this.BotInfo = botInfo;
 }
Exemple #23
0
        public static async Task <ReturnResult> VerifyDevice(IDeviceAuth device,
                                                             IUserInfo userInfoContext, string location, IBot botContext)
        {
            UserInfo userInfo;
            var      usersInfo = await userInfoContext.Get(device.CurrentDeviceName(), device.GetCurrentUserIp());

            if (usersInfo == null || !usersInfo.UserLocation.Equals(location))
            {
                var deviceAuth = device.GetDeviceDetails();

                if (deviceAuth.Client != null && deviceAuth.OsInfo != null)
                {
                    // future upgrade use for notification if the device location differs
                    userInfo = new UserInfo
                    {
                        BrowserId    = device.GetBrowserId(),
                        DeviceName   = device.CurrentDeviceName(),
                        OsName       = deviceAuth.OsInfo.Name,
                        OsPlatForm   = deviceAuth.OsInfo.PlatForm,
                        OsSuccess    = deviceAuth.OsInfo.Success,
                        OsVersion    = deviceAuth.OsInfo.Version,
                        OsShortName  = deviceAuth.OsInfo.ShortName,
                        UserIpHost   = device.GetCurrentUserIp(),
                        UserLocation = device.GetUserLocation(location),
                    };
                    var result = await userInfoContext.Add(userInfo);

                    if (result.Succeeded)
                    {
                        return(new ReturnResult
                        {
                            Succeeded = true
                        });
                    }
                }
                else
                {
                    BotInfo bot = new BotInfo();
                    bot.Category    = deviceAuth.Bot.Category;
                    bot.Name        = deviceAuth.Bot.Name;
                    bot.Producer    = deviceAuth.Bot.Producer;
                    bot.ProducerUrl = deviceAuth.Bot.ProducerUrl;
                    bot.Url         = deviceAuth.Bot.Url;
                    bot.Success     = deviceAuth.Bot.Success;
                    var result = await botContext.Add(bot);

                    if (result.Succeeded)
                    {
                        return(new ReturnResult
                        {
                            Succeeded = true
                        });
                    }
                }
            }

            return(new ReturnResult
            {
                Succeeded = false,
                Error = "verification failed"
            });
        }
Exemple #24
0
        public IActionResult Editor()
        {
            BotInfo bot = new BotInfo();

            return(View(bot));
        }
Exemple #25
0
 async Task <GetBuildResponse> IGameDependencyProvider.GetBotBuild(BotInfo bot) => new GetBuildResponse
 {
     Name = bot.Id
 };
 public static Task Event(DiscordClient c, GuildMemberAddEventArgs e, BotInfo botInfo)
 {
     Interlocked.Increment(ref botInfo.Membros);
     return(Task.CompletedTask);
 }
 protected BaseTelegramBot(BotInfo botInfo)
 {
     _client.BaseAddress    = new Uri(botInfo.BotUrl);
     FileClient.BaseAddress = new Uri(botInfo.BotFileUrl);
 }
Exemple #28
0
 Task <GetActionResponse> IGameDependencyProvider.GetBotAction(BotInfo bot) => throw new NotImplementedException();
Exemple #29
0
        public static void Update_Bots()
        {
            Main._Main.group_auth.Invoke(new Action(() => Main._Main.group_auth.Enabled           = false));
            Main._Main.groupbox_função.Invoke(new Action(() => Main._Main.groupbox_função.Enabled = false));

            var URL = $"http://{Main._Main.txt_IPC.Text}:{Main._Main.txt_PORT.Text}/Api/Bot/asf";

            if (Main._Main.ckc_usepass.Checked)
            {
                if (Main._Main.txt_passIPC.Text == "")
                {
                    Main._Main.lbl_status_auth.Text      = "Please enter the IPC password";
                    Main._Main.lbl_status_auth.ForeColor = Color.Red;
                    Main._Main.txt_passIPC.Focus();
                    return;
                }
                else
                {
                    URL = $"{URL}?password={Main._Main.txt_passIPC.Text}";
                }
            }

            var response = new RequestBuilder(URL)
                           .GET()
                           .Execute();

            ASFResponse_BotsResume.Root asf_response = JsonConvert.DeserializeObject <ASFResponse_BotsResume.Root>(response.Content);

            Log.orange("Starting Update Bots Database...");
            int counter = 0;

            foreach (var asf_Bot in asf_response.Result)
            {
                Log.info("Db Update.. {0}. {1}/{2}", asf_Bot.Value.BotName, ++counter, asf_response.Result.Count);

                if (asf_Bot.Value.BotConfig.Enabled == false)
                {
                    Log.orange($"Account: {asf_Bot.Value.BotName} - was set to disabled, on the ASF config!");

                    try
                    {
                        File.Delete(@"Bots/" + asf_Bot.Value.SteamID + ".json");
                    }
                    catch
                    {
                    }

                    continue;
                }

                if (asf_Bot.Value.SteamID == 0)
                {
                    Log.orange($"Account: {asf_Bot.Value.BotName} - not yet started!");
                    continue;
                }

                var GameList = GetOwnedGames.GetGames(asf_Bot.Value.SteamID.ToString());

                BotInfo bot = new BotInfo
                {
                    AvatarHash    = asf_Bot.Value.AvatarHash,
                    SteamID       = asf_Bot.Value.SteamID,
                    BotName       = asf_Bot.Value.BotName,
                    NickName      = asf_Bot.Value.Nickname,
                    WalletBalance = asf_Bot.Value.WalletBalance,
                    vds           = $"{Main._Main.txt_IPC.Text}:{Main._Main.txt_PORT.Text}",
                    Active        = true,
                    GamesHave     = GameList
                };

                File.WriteAllText($@"Bots/{bot.SteamID}.json", JsonConvert.SerializeObject(bot, Formatting.Indented));
            }

            Main._Main.group_auth.Invoke(new Action(() => Main._Main.group_auth.Enabled           = true));
            Main._Main.groupbox_função.Invoke(new Action(() => Main._Main.groupbox_função.Enabled = true));
        }
 public CurrencySettingsMessage(BotInfo botInfo)
 {
     BotInfo = botInfo;
 }