Exemplo n.º 1
0
 private void Lib_OnClientMoved(object sender, IEnumerable <ClientMoved> e)
 {
     if (!Enabled)
     {
         return;
     }
     foreach (var client in e)
     {
         if (lib.WhoAmI().ChannelId == client.TargetChannelId)
         {
             continue;
         }
         var clientinfo = lib.ClientInfo(client.ClientId);
         if (!clientUIDs.Contains(clientinfo.Uid))
         {
             continue;
         }
         if (!clientinfo.ServerGroups.Contains(Convert.ToUInt64(13)))
         {
             continue;
         }
         var welcomemsg = welcomeMSG.Replace("{nickname}", clientinfo.NickName).Replace("{uid}", clientinfo.Uid);
         PluginLog(Log.Level.Debug, "\n" + welcomemsg + "\n");
         bot.QueryConnection.SendMessage(welcomemsg, client.ClientId);
         clientUIDs.Add(clientinfo.Uid);
     }
 }
Exemplo n.º 2
0
        private void Lib_OnTextMessageReceived(object sender, IEnumerable <TextMessage> e)
        {
            if (!Enabled)
            {
                return;
            }
            List <ClientData> clientbuffer = null;

            foreach (var msg in e)
            {
                if (msg.Target != TextMessageTargetMode.Private || msg.InvokerId == lib.WhoAmI().ClientId)
                {
                    continue;
                }
                try {
                    clientbuffer = clientbuffer ?? lib.ClientList(ClientListOptions.uid).ToList();
                    foreach (var client in clientbuffer)
                    {
                        if (client.Uid == msg.InvokerUid)
                        {
                            continue;
                        }
                        if (!bot.RightsManager.HasAllRights(new InvokerData(client.Uid), "PMRedirect.isowner"))
                        {
                            continue;
                        }
                        // PluginLog(Log.Level.Debug, "Got PM from " + msg.InvokerUid + ". Redirecting to " + client.Uid);
                        bot.QueryConnection.SendMessage("Got PM from " + ParseInvoker(msg) + ": " + msg.Message, client.ClientId);
                    }
                    //foreach (var uid in Settings.Default.uids)
                    //{
                    //    PluginLog(Log.Level.Debug, "uid: " + uid);
                    //}
                } catch (Ts3CommandException exception) {
                    PluginLog(Log.Level.Error, exception.ToString());
                }
            }
        }
Exemplo n.º 3
0
 public string CommandGetOwnChannelID(ExecutionInformation info)
 {
     return(lib.WhoAmI().ChannelId.ToString());
 }
        public static ChannelIdT GetMyChannelID(Ts3FullClient sender)
        {
            WhoAmI data = sender.WhoAmI();

            return(data.ChannelId);
        }
Exemplo n.º 5
0
        private void PlayManager_AfterResourceStarted(object sender, PlayInfoEventArgs e)
        {
            if (!Settings.Default.Enabled)
            {
                return;
            }
            PluginLog(Log.Level.Debug, "Track changed. Applying now playing values");
            if (!string.IsNullOrWhiteSpace(Settings.Default.Description))
            {
                try {
                    bot.QueryConnection.ChangeDescription(ParseNowPlayingString(Settings.Default.Description, e));
                } catch (Exception ex) { PluginLog(Log.Level.Warning, "Exeption thrown while trying to change Description: " + ex.Message); }
            }
            if (!string.IsNullOrWhiteSpace(Settings.Default.ServerChat))
            {
                try {
                    bot.QueryConnection.SendServerMessage(ParseNowPlayingString(Settings.Default.ServerChat, e));
                } catch (Exception ex) { PluginLog(Log.Level.Warning, "Exeption thrown while trying to send Server Message: " + ex.Message); }
            }
            if (!string.IsNullOrWhiteSpace(Settings.Default.ChannelChat))
            {
                try {
                    bot.QueryConnection.SendChannelMessage(ParseNowPlayingString(Settings.Default.ChannelChat, e));
                } catch (Exception ex) { PluginLog(Log.Level.Warning, "Exeption thrown while trying to send Channel Message: " + ex.Message); }
            }
            if (!string.IsNullOrWhiteSpace(Settings.Default.PrivateChat))
            {
                try {
                    var clientbuffer = lib.ClientList(ClientListOptions.uid).ToList();
                    foreach (var client in clientbuffer)
                    {
                        foreach (var uid in Settings.Default.PrivateChatUIDs)
                        {
                            if (client.Uid == uid)
                            {
                                bot.QueryConnection.SendMessage(ParseNowPlayingString(Settings.Default.PrivateChat, e), client.ClientId);
                            }
                        }
                    }
                } catch (Exception ex) { PluginLog(Log.Level.Warning, "Exeption thrown while trying to send private Message: " + ex.Message); }
            }
            if (!string.IsNullOrWhiteSpace(Settings.Default.NickName))
            {
                try {
                    bot.QueryConnection.ChangeName(ParseNowPlayingString(Settings.Default.NickName, e));
                } catch (Exception ex) { PluginLog(Log.Level.Warning, "Exeption thrown while trying to change nickname: " + ex.Message); }
            }
            if (!string.IsNullOrWhiteSpace(Settings.Default.PluginCommand))
            {
                try {
                    lib.Send("plugincmd", new CommandParameter("name", "TS3AudioBot"),
                             new CommandParameter("targetmode", 0),
                             new CommandParameter("data", ParseNowPlayingString(Settings.Default.PluginCommand, e)));
                } catch (Exception ex) { PluginLog(Log.Level.Warning, "Exeption thrown while trying to send Plugin Command: " + ex.Message); }
            }
            if (!string.IsNullOrWhiteSpace(Settings.Default.MetaData))
            {
                try {
                    /* TODO: Append Meta Data
                     * var clid = lib.ClientId;
                     * var ownClient = lib.Send<ClientData>("clientinfo", new CommandParameter("clid", clid)).FirstOrDefault();
                     * ownClient.*/
                    lib.Send("clientupdate", new CommandParameter("client_meta_data", ParseNowPlayingString(Settings.Default.MetaData, e)));
                } catch (Exception ex) { PluginLog(Log.Level.Warning, "Exeption thrown while trying to set Meta Data: " + ex.Message); }
            }
            var ownChannelId = lib.WhoAmI().ChannelId;

            if (!string.IsNullOrWhiteSpace(Settings.Default.ChannelName))
            {
                try {
                    lib.Send("channeledit", new CommandParameter("cid", ownChannelId),
                             new CommandParameter("channel_name", ParseNowPlayingString(Settings.Default.ChannelName, e)));
                } catch (Exception ex) { PluginLog(Log.Level.Warning, "Exeption thrown while trying to set channel name: " + ex.Message); }
            }
            if (!string.IsNullOrWhiteSpace(Settings.Default.ChannelTopic))
            {
                try {
                    lib.Send("channeledit", new CommandParameter("cid", ownChannelId),
                             new CommandParameter("channel_topic", ParseNowPlayingString(Settings.Default.ChannelTopic, e)));
                } catch (Exception ex) { PluginLog(Log.Level.Warning, "Exeption thrown while trying to set channel topic: " + ex.Message); }
            }
            if (!string.IsNullOrWhiteSpace(Settings.Default.ChannelDescription))
            {
                try {
                    lib.Send("channeledit", new CommandParameter("cid", ownChannelId),
                             new CommandParameter("channel_description", ParseNowPlayingString(Settings.Default.ChannelDescription, e)));
                } catch (Exception ex) { PluginLog(Log.Level.Warning, "Exeption thrown while trying to set channel description: " + ex.Message); }
            }
        }