1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#!/usr/bin/python3
#
# stdinbot - Read text from stdin and send it to an IRC channel
#
# © 2018 by luk3yx
#
import sys, time
from miniirc import IRC
# Variables
nick = "idc"
ident = nick
realname = "Internet Delay Chat Relay"
identity = None
# identity = '<username> <password>'
print_cmds = False
interval = 0.25
channels = ["#idc"]
debug = False
ip = "irc.andrewyu.org"
port = 6697
print("Welcome to stdinbot!", file=sys.stderr)
irc = IRC(
ip,
port,
nick,
channels,
ident=ident,
realname=realname,
ns_identity=identity,
debug=debug,
auto_connect=False,
)
# Read stdin
@irc.Handler("001", colon=False)
def handle_stdin(irc, hostmask, args):
qmsg = "I reached the end of my file, therefore my life™."
while True:
try:
line = +input().replace("\r", "").replace("\n", " ")
except:
line = "\x04"
if line == "\x04":
return irc.disconnect(qmsg)
irc.msg(channels[0], line)
time.sleep(interval)
@irc.Handler("PRIVMSG", colon=False)
def handle_privmsg(irc, hostmask, args):
# if args[0] in channels:
if True:
print("<" + hostmask[0] + "> " + args[1])
if __name__ == "__main__":
irc.connect()
|