[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tyndur-devel] [PATCH] Command-Abfrage erweitert



+ kirc.pas: Gängige Kürzel wie /cs, /voice etc. werden nun verarbeitet
! kirc.pas: Standardserver auf "irc.euirc.eu" geändert

Signed-off-by: Alexander Hartmut Kluth <hartmut@xxxxxxxxxx>
---
 src/modules/pas/kirc/kirc.pas |   63 +++++++++++++++++++++++++++++++++++++----
 1 files changed, 57 insertions(+), 6 deletions(-)

diff --git a/src/modules/pas/kirc/kirc.pas b/src/modules/pas/kirc/kirc.pas
index 7b6ad9b..2c52c5a 100644
--- a/src/modules/pas/kirc/kirc.pas
+++ b/src/modules/pas/kirc/kirc.pas
@@ -2,7 +2,7 @@ program kirc;
 {$MODE ObjFPC}
 {$H+}
 
-uses sysutils, crt, ircwindow;
+uses sysutils, crt, ircwindow, classes;
 
 var
     theIRCWindow: TIRCWindow;
@@ -57,10 +57,10 @@ var
     server: String;
     port: String;
 begin
-    Write('Server [217.26.49.12]: ');
+    Write('Server [irc.euirc.net]: ');
     ReadLn(server);
     if server = '' then begin
-        server := '217.26.49.12';
+        server := 'irc.euirc.net';
     end;
 
     Write('Port [6667]: ');
@@ -160,10 +160,10 @@ begin
         theIRCWindow.Incoming(line, 8);
         theIRCWindow.Incoming('PONG :'+parameter+#10, 8);
         WriteConn(conn, 'PONG :'+parameter+#10);
-    end 
+    end
     else if command = 'JOIN' then begin
         theIRCWindow.Incoming(prefix + ' hat den Kanal betreten', 2);
-    end 
+    end
     else if command = 'PART' then begin
         theIRCWindow.Incoming(GetNickFromPrefix(prefix) 
             + ' hat den Kanal verlassen (' 
@@ -222,6 +222,11 @@ begin
 end;
 
 procedure EvaluateIRCCommand(const line: String);
+var
+    linearr: Array[1..255] of String;
+    command: String;
+    i: Integer;
+    space: Integer;
 begin
     // Bei Leerzeilen machen wir gleich mal gar nichts
     // Vor allem keinen Zugriff auf line[1], sonst ist kirc weg
@@ -239,7 +244,53 @@ begin
         end;
     end else begin
         if line[1] = '/' then begin
-            WriteConn(conn, Copy(line, 2, length(line)) + #10);
+            // Wir brauchen so etwas wie TStringList in der RTL
+            // Höhö, das kennen wir doch aus kedit: Wir prüfen
+            // per LeftStr, ob es ein (uns bekanntest) Kommando ist
+            if LeftStr(line, 3) = '/ns' then begin
+                command := 'PRIVMSG NickServ :' + Copy(line, 5, length(line))
+                + #10;
+            end else if LeftStr(line, 3) = '/cs' then begin
+                command := 'PRIVMSG ChanServ :' + Copy(line, 5, length(line)) +
+                #10;
+            end else if LeftStr(line, 6) = '/voice' then begin
+                // mit Copy(line, 7...) spare ich mir ein zusätzliches + " " +
+                command := 'MODE ' + channel + ' +v ' + Copy(line, 8,
+                length(line)) + #10;
+            end else if LeftStr(line, 8) = '/devoice' then begin
+                command := 'MODE ' + channel + ' -v ' + Copy(line, 8,
+                length(line)) + #10;
+            end else if LeftStr(line, 3) = '/op' then begin
+                command := 'MODE ' + channel + ' +o ' + Copy(line, 8,
+                length(line)) + #10;
+            end else if LeftStr(line, 5) = '/deop' then begin
+                command := 'MODE ' + channel + ' -o ' + Copy(line, 8,
+                length(line)) + #10;
+            end else if LeftStr(line, 6) = '/admin' then begin
+                command := 'MODE ' + channel + ' +a ' + Copy(line, 8,
+                length(line)) + #10;
+            end else if LeftStr(line, 8) = '/deadmin' then begin
+                command := 'MODE ' + channel + ' -a ' + Copy(line, 8,
+                length(line)) + #10;
+            end else if LeftStr(line, 5) = '/kick' then begin
+                space := Pos(' ', Copy(line, 7, length(line)));
+
+                command := 'KICK ' + channel + ' ' + Copy(line, 7, space-1) +
+                ' :' + Copy(line, space+1, length(line)) + #10;
+            end else if LeftStr(line, 4) = '/ban' then begin
+                command := 'MODE ' + channel + ' +b ' + Copy(line, 6,
+                length(line)) + '!*@*' + #10;
+            end else if LeftStr(line, 6) = '/unban' then begin
+                command := 'MODE ' + channel + ' -b ' + Copy(line, 8,
+                length(line)) + '!*@*' + #10;
+            end else if LeftStr(line, 6) = '/42' then begin
+                theIRCWindow.title := 'The Answer to Life, the Universe, and Everything is ... 42';
+            end else begin
+                WriteConn(conn, (Copy(line, 2, length(line)) + #10));
+            end;
+
+            WriteConn(conn, command);
+
         end else begin
             theIRCWindow.Incoming('<' + nick + '> ' + line+#10, 7);
             WriteConn(conn, 'PRIVMSG '+channel+' :'+line+#10);
-- 
1.6.3.3