Advertisement
Ham62

Hambot 1.0 Source Code.bas

Aug 16th, 2018
1,259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QBasic 4.66 KB | None | 0 0
  1. DIM SHARED Client AS LONG
  2. DIM SHARED Channel AS STRING
  3. DIM SHARED LineEnding AS STRING
  4. DIM SHARED Nick AS STRING
  5. DIM SHARED Port AS STRING
  6. DIM SHARED Server AS STRING
  7. DIM SHARED Speaker AS STRING
  8. DIM SHARED TextIn AS STRING
  9. DIM SHARED TextOut AS STRING
  10.  
  11. LineEnding = CHR$(10)
  12. OPEN "SETUP.DAT" FOR INPUT AS #1
  13. INPUT #1, Server
  14. INPUT #1, Port
  15. INPUT #1, Nick
  16. INPUT #1, Channel
  17. CLOSE #1
  18.  
  19. CALL ConnectionSequence
  20.  
  21. PollTimer = INT(TIMER)
  22.  
  23. DO
  24.     _LIMIT 1000
  25.     TextIn = ""
  26.     TextOut = ""
  27.  
  28.     'This will respond to the server pings
  29.     IF INT(TIMER) > PollTime + 1.5 THEN
  30.         PollTimer = INT(TIMER)
  31.  
  32.         GET #Client&, , TextIn
  33.  
  34.         IF LEFT$(TextIn, 4) = "PING" THEN
  35.             Resp$ = "PONG" + MID$(TextIn$, 5) + LineEnding
  36.             PUT #Client&, , Resp$
  37.         END IF
  38.     END IF
  39.  
  40.     'This will check for any new posts and read the data from the string (eg. The speaking user)
  41.     IF TextIn <> "" THEN
  42.  
  43.         Speaker = MID$(TextIn$, 2, INSTR(TextIn$, "!") - 2)
  44.         chantemp$ = Channel + " :"
  45.         ChatEval$ = RIGHT$(TextIn$, LEN(TextIn$) - INSTR(TextIn$, chantemp$) - LEN(chantemp$) + 1)
  46.         ChatEval$ = LCASE$(LEFT$(ChatEval$, LEN(ChatEval$) - 2))
  47.  
  48.         PRINT "[" + TIME$ + "] " + "<" + Speaker + ">: " + ChatEval$
  49.         OPEN "logs\" + Channel + " " + DATE$ + ".txt" FOR APPEND AS #1
  50.         PRINT #1, "[" + TIME$ + "] " + "<" + Speaker + ">: " + ChatEval$
  51.         CLOSE #1
  52.  
  53.         IF ChatEval$ = "shutup hambot you stupid jew!" THEN
  54.             OutCommand$ = "QUIT shutdown called by " + Speaker
  55.             SendData (OutCommand$)
  56.             END
  57.         END IF
  58.  
  59.         IF ChatEval$ = "ping" THEN
  60.             TextOut = "pong"
  61.         END IF
  62.  
  63.         IF ChatEval$ = "pong" THEN
  64.             Secs$ = STR$(VAL(RIGHT$(TIME$, 2)) - 1)
  65.             IF VAL(Secs$) < 10 THEN
  66.                 Secs$ = "0" + STR$(VAL(Secs$))
  67.             END IF
  68.             PastTime$ = LEFT$(TIME$, 2) + MID$(TIME$, 3, 4) + LTRIM$(Secs$)
  69.             TextOut = "[" + PastTime$ + "] " + "<HamBot> " + "ping"
  70.         END IF
  71.  
  72.         IF INSTR(ChatEval$, "fagit") > 0 THEN
  73.             IF DontKick$ <> "y" THEN
  74.                 OutCommand$ = "NICK spoderman"
  75.                 SendData (OutCommand$)
  76.                 TextOut = "ur teh bigest fagit I hav ever seen"
  77.                 BrodcastOut
  78.                 OutCommand$ = "KICK " + Channel + " " + Speaker + " fagit"
  79.                 SendData OutCommand$
  80.                 OutCommand$ = "NICK HamBot"
  81.                 SendData (OutCommand$)
  82.                 TextOut = ""
  83.                 DontKick$ = "y"
  84.             ELSE DontKick$ = "n"
  85.             END IF
  86.         END IF
  87.  
  88.         IF INSTR(ChatEval$, "nigg") > 0 THEN
  89.             OutCommand$ = "NICK J3W_N1663R"
  90.             SendData (OutCommand$)
  91.             TextOut = "I've been saving up these pennies for 3 years to buy some fried chicken at KFC!!"
  92.             BrodcastOut
  93.             OutCommand$ = "NICK HamBot"
  94.             SendData (OutCommand$)
  95.             TextOut = ""
  96.         END IF
  97.  
  98.         IF a = a THEN
  99.         END IF
  100.  
  101.         IF ChatEval$ = "hello hambot" THEN
  102.             TextOut = "Hello " + Speaker
  103.         END IF
  104.     END IF
  105.  
  106.     tmp$ = INKEY$
  107.     IF LCASE$(tmp$) = "j" THEN
  108.         OutCommand$ = "PRIVMSG NickServ :identify Fuk-u-Komputerkid" + LineEnding
  109.         SendData (OutCommand$)
  110.         SLEEP 2
  111.         OutCommand$ = "JOIN " + Channel + LineEnding
  112.         SendData (OutCommand$)
  113.     END IF
  114.  
  115.     'Send out the text to the channel
  116.     IF TextOut <> "" THEN
  117.         BrodcastOut
  118.     END IF
  119. LOOP
  120.  
  121.  
  122.  
  123.  
  124. SUB ConnectionSequence
  125. PRINT "Attempting connection to " + Server + " on port " + Port;
  126. Client = _OPENCLIENT("TCP/IP:" + Port + ":" + Server): PRINT "..."
  127.  
  128. IF Client THEN
  129.     PRINT "Sucsessfuly connected to " + Server
  130. ELSE
  131.     PRINT "Connection failed!"
  132. END IF
  133.  
  134. PRINT "Sending NICK... " + Nick: SendData ("NICK " + Nick)
  135. PRINT "Sending USER... " + Nick: SendData ("USER " + Nick + " 0 * : " + Nick)
  136. PRINT "Sending JOIN... " + Channel: SendData ("JOIN " + Channel)
  137. PRINT "Sending TOPIC..." + Channel: SendData ("Topic " + Channel)
  138. PRINT "Sucsessfuly joined " + Channel
  139. END SUB
  140.  
  141. SUB SendData (TextIn$)
  142. txt$ = TextIn$ + LineEnding
  143. PUT #Client&, , txt$
  144.  
  145. PRINT txt$
  146. OPEN "logs\" + Channel + " - " + DATE$ + ".txt" FOR APPEND AS #1
  147. PRINT #1, "[" + TIME$ + "] " + txt$
  148. CLOSE #1
  149. END SUB
  150.  
  151. SUB BrodcastOut
  152.  
  153. txt$ = "PRIVMSG " + Channel + " :" + TextOut + LineEnding
  154. PUT #Client&, , txt$
  155. COLOR 4: PRINT "[" + TIME$ + "] " + LEFT$(txt$, LEN(txt$) - 1): COLOR 7
  156.  
  157. OPEN "logs\" + Channel + " - " + DATE$ + ".txt" FOR APPEND AS #1
  158. PRINT #1, "[" + TIME$ + "] " + LEFT$(txt$, LEN(txt$) - 1): COLOR 7
  159. CLOSE #1
  160. END SUB
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement