IRC bot (oude kanaal)

From VoidWarranties - Hackerspace Antwerp, Belgium
(Difference between revisions)
Jump to: navigation, search
(moet wel reageren op ping)
Line 7: Line 7:
 
|Short description=A bot that runs on our old, abandoned, channel
 
|Short description=A bot that runs on our old, abandoned, channel
 
}}
 
}}
this is a very simpel bot that tells everyone who moved that we moved our IRC channel:
+
this is a very simpel bot that tells everyone who enters the old IRC channel ( #hackerspace-voidwarranties ) that we moved our IRC channel to #voidwarranties
 
==source code==
 
==source code==
<source lang="python">
+
*sourcecode can be found in our SVN: http://discuss.voidwarranties.be/svn/ircbot-voidbotty/
import socket
+
 
+
network = 'irc.freenode.net'
+
port = 6667
+
irc = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
+
irc.connect ( ( network, port ) )
+
print irc.recv ( 4096 )
+
irc.send ( 'NICK Voidbotty\r\n' )
+
irc.send ( 'USER botty botty botty :Python IRC\r\n' )
+
irc.send ( 'JOIN #hackerspace-voidwarranties\r\n' )
+
irc.send ( 'PRIVMSG #hackerspace-voidwarranties :Hello World.\r\n' )
+
while True:
+
  data = irc.recv ( 4096 )
+
  if data.find ( 'PING' ) != -1:
+
      irc.send ( 'PONG ' + data.split() [ 1 ] + '\r\n' )
+
  if data.find ("JOIN") != -1:
+
      nick = data[1:]
+
      nick = data.split("!")[0]
+
      irc.send ( 'PRIVMSG #hackerspace-voidwarranties ' + nick + ', we moved to #voidwarranties\r\n' )
+
  print data
+
</source>
+

Revision as of 17:48, 25 November 2012


IRC bot (oude kanaal)
What:
A bot that runs on our old, abandoned, channel
Event.png
Participants:
warddr
Category:
Coding
Locations:
irc

this is a very simpel bot that tells everyone who enters the old IRC channel ( #hackerspace-voidwarranties ) that we moved our IRC channel to #voidwarranties

source code

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox
Content Creation
Belgian Spaces