fix
This commit is contained in:
parent
05aab5ab41
commit
e9a196ff06
24
client.py
24
client.py
@ -1,24 +0,0 @@
|
||||
from socket import *
|
||||
import sys
|
||||
|
||||
host = 'localhost'
|
||||
port = 777
|
||||
addr = (host,port)
|
||||
|
||||
udp_socket = socket(AF_INET, SOCK_DGRAM)
|
||||
|
||||
|
||||
data = input('write to server: ')
|
||||
if not data :
|
||||
udp_socket.close()
|
||||
sys.exit(1)
|
||||
|
||||
#encode - перекодирует введенные данные в байты, decode - обратно
|
||||
data = str.encode(data)
|
||||
udp_socket.sendto(data, addr)
|
||||
data = bytes.decode(data)
|
||||
data = udp_socket.recvfrom(1024)
|
||||
print(data)
|
||||
|
||||
|
||||
udp_socket.close()
|
||||
@ -1,5 +0,0 @@
|
||||
[Global]
|
||||
IRC_bot_nickname = GandC_LogMon_Bot
|
||||
IRC_chat_name = #notifications
|
||||
IRC_host = s1.tomasgl.piv
|
||||
IRC_port = 6667
|
||||
16
server.py
16
server.py
@ -1,12 +1,9 @@
|
||||
## ##
|
||||
##/dev/udp/ip/port##
|
||||
##pip3 install irc##
|
||||
from irc import client, connection
|
||||
from socket import socket, AF_INET, SOCK_DGRAM
|
||||
|
||||
#from os import chdir, path
|
||||
from threading import Thread
|
||||
|
||||
host = '10.10.18.3'
|
||||
host = '0.0.0.0'
|
||||
port = 7747
|
||||
addr = (host,port)
|
||||
|
||||
@ -18,9 +15,6 @@ irc_bot_nickname = 'GandC_LogMon_Bot'
|
||||
s = socket(AF_INET, SOCK_DGRAM) # Socket creation
|
||||
s.bind(addr) # Bind socket to ip
|
||||
|
||||
|
||||
#chdir(path.dirname(path.abspath(__file__)))
|
||||
|
||||
def on_connect(connection, event):
|
||||
connection.mode(irc_bot_nickname, '+B')
|
||||
connection.join(irc_chat_name)
|
||||
@ -41,7 +35,7 @@ Thread(target=reactor.process_forever).start()
|
||||
|
||||
while True:
|
||||
message, addr = s.recvfrom(1024) # receive message
|
||||
print('client addr: ', addr)
|
||||
print('info: ', message)
|
||||
irc.connection.privmsg(irc_chat_name, message)
|
||||
#print('client addr: ', addr)
|
||||
#print('info: ', message.decode())
|
||||
irc.privmsg(irc_chat_name, message.decode().strip())
|
||||
s.close()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user