Exemplo n.º 1
0
 public async Task Welcome()
 {
     if (!HasExecutePermission)
         return;
     if (CurrentTickets.Any(x => x.TicketChannel == Context.Channel.Id))
     {
         var ticket = CurrentTickets.Find(x => x.TicketChannel == Context.Channel.Id);
         if(!ticket.Welcomed)
         {
             var dmchan = await Context.Client.GetUser(ticket.UserID).GetOrCreateDMChannelAsync();
             var usr = Context.Message.Author as SocketGuildUser;
             await Context.Message.DeleteAsync();
             ticket.Transcript.AddMessage("Hello! Swiss001 Support! How May I help you?", usr, Context.Message.Id, Context.Message.Timestamp);
             string msg = $"**[Staff] {(usr.Nickname == null ? usr.ToString() : usr.Nickname)}** - Hello! Swiss001 Support! How May I help you?";
             await Context.Guild.GetTextChannel(ticket.TicketChannel).SendMessageAsync(msg);
             await dmchan.SendMessageAsync(msg);
             ticket.Welcomed = true;
         
         }
         else
         {
             var msg = await Context.Channel.SendMessageAsync("The user has been welcomed, are you sure you want to still want to send them another welcome message?");
             await msg.AddReactionsAsync(new IEmote[] { new Emoji("✅"), new Emoji("❌") });
             WelcomeMessages.Add(msg.Id);
         }
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Returns an enumerator that iterates through a collection.
 /// </summary>
 /// <returns>An IEnumerator object that can be used to iterate through the collection.</returns>
 public IEnumerator <WelcomeMessage> GetEnumerator()
 {
     return(WelcomeMessages?.AsEnumerable().GetEnumerator()
            ?? Enumerable.Empty <WelcomeMessage>().GetEnumerator());
 }
Exemplo n.º 3
0
    public void LoadDialoges(string lang)
    {
        dialogs         = new List <DialogQuestion>();
        welcomeMessages = new WelcomeMessages();
        tiredMessages   = new TiredMessages();

        //Dialogs
        bool        staticAnswers = false;
        TextAsset   textAsset     = (TextAsset)Resources.Load("dialogs_" + lang);
        XmlDocument xmldoc        = new XmlDocument();

        xmldoc.LoadXml(textAsset.text);

        foreach (XmlNode rep in xmldoc.ChildNodes[0].ChildNodes)
        {
            DialogQuestion diag = new DialogQuestion();

            foreach (XmlNode i in rep.ChildNodes)
            {
                if (i.Name == "stat")
                {
                    if (i.InnerText == "None")
                    {
                        staticAnswers = true;
                    }
                    else
                    {
                        diag.linkedStat = (StatsHolder.Stat)System.Enum.Parse(typeof(StatsHolder.Stat), i.InnerText);
                        staticAnswers   = false;
                    }
                }
                else if (i.Name == "question")
                {
                    diag.questions.Add(i.InnerText);
                }
                else if (i.Name == "answer")
                {
                    DialogAnswer da = new DialogAnswer();
                    da.answer = i.InnerText;
                    foreach (XmlAttribute attr in i.Attributes)
                    {
                        if (attr.Name == "min")
                        {
                            da.minRange = sbyte.Parse(attr.Value);
                        }
                        else if (attr.Name == "max")
                        {
                            da.maxRange = sbyte.Parse(attr.Value);
                        }
                    }
                    diag.answers.Add(da);
                }
            }
            if (staticAnswers)
            {
                foreach (var an in diag.answers)
                {
                    DialogQuestion.answersForAll.Add(an);
                }
            }
            else
            {
                dialogs.Add(diag);
            }
        }

        //Dialogs welcome
        textAsset = (TextAsset)Resources.Load("welcomedialogs_" + lang);
        xmldoc    = new XmlDocument();
        xmldoc.LoadXml(textAsset.text);

        foreach (XmlNode i in xmldoc.ChildNodes[0].ChildNodes)
        {
            if (i.Name == "regular")
            {
                welcomeMessages.regularMessages.Add(i.InnerText);
            }
            else if (i.Name != "#text")
            {
                DialogQuestion dq = new DialogQuestion();
                dq.linkedStat = (StatsHolder.Stat)System.Enum.Parse(typeof(StatsHolder.Stat), i.Name, true);

                foreach (XmlNode spec in i.ChildNodes)
                {
                    DialogAnswer da = new DialogAnswer();
                    da.answer = spec.InnerText;
                    foreach (XmlAttribute attr in spec.Attributes)
                    {
                        if (attr.Name == "min")
                        {
                            da.minRange = sbyte.Parse(attr.Value);
                        }
                        else if (attr.Name == "max")
                        {
                            da.maxRange = sbyte.Parse(attr.Value);
                        }
                    }
                    dq.answers.Add(da);
                }

                welcomeMessages.specialMessages.Add(dq);
            }
        }

        //Dialogs tired
        textAsset = (TextAsset)Resources.Load("tireddialogs_" + lang);
        xmldoc    = new XmlDocument();
        xmldoc.LoadXml(textAsset.text);

        foreach (XmlNode i in xmldoc.ChildNodes[0].ChildNodes)
        {
            if (i.Name == "regular")
            {
                tiredMessages.regularMessages.Add(i.InnerText);
            }
            else if (i.Name != "#text")
            {
                DialogQuestion dq = new DialogQuestion();
                dq.linkedStat = (StatsHolder.Stat)System.Enum.Parse(typeof(StatsHolder.Stat), i.Name, true);

                foreach (XmlNode spec in i.ChildNodes)
                {
                    DialogAnswer da = new DialogAnswer();
                    da.answer = spec.InnerText;
                    foreach (XmlAttribute attr in spec.Attributes)
                    {
                        if (attr.Name == "min")
                        {
                            da.minRange = sbyte.Parse(attr.Value);
                        }
                        else if (attr.Name == "max")
                        {
                            da.maxRange = sbyte.Parse(attr.Value);
                        }
                    }
                    dq.answers.Add(da);
                }

                tiredMessages.specialMessages.Add(dq);
            }
        }
    }