From 5576d2b08768b3586afefb582c3004e0ab8fd2c1 Mon Sep 17 00:00:00 2001 From: ComputerTech <60820431+ComputerTech312@users.noreply.github.com> Date: Thu, 21 Oct 2021 01:57:56 +0100 Subject: [PATCH 01/15] Update cbot.py --- cbot.py | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/cbot.py b/cbot.py index 4424edd..45d8a7c 100644 --- a/cbot.py +++ b/cbot.py @@ -7,27 +7,30 @@ import string import time +BotNick = "CBot" +BotAlt = "CBot-" +BotIdent = "CBot" +BotRealname = "CBot" +SERVER = "irc.irchighway.net" +PORT = 6667 + + sockChan = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +sockChan.connect((SERVER, PORT)) -sockChan.connect((BSERVER, BPORT)) -sockChan.send('NICK ' + BNICK + '\r\n'.encode('UTF-8')) -sockChan.send('USER ' + BREALNAME + ' * * :' + BIDENT + '\r\n'.encode('UTF-8')) +def SendIRC (msg): + sockChan.send(bytes(f'{str(msg)} \r\n', 'UTF-8')) + +SendIRC(f'USER {BotIdent} * * :{BotRealname}') +SendIRC(f'NICK {BotNick}') +connected = True -while 1: - line = sockChan.recv(2040) - print(line) +while connected: + line = sockChan.recv(2040).decode('UTF-8') + print(line) + if line != "": lline = line.split() if 'PING' in lline[0]: - sockChan.send("PONG " + lline[1] + "\r\n") - if '001' in lline[1]: - sockChan.send("JOIN " + BCHANNEL + "\r\n") - # sockChan.send("PRIVMSG NICKSERV :IDENTIFY " + BPASSWORD + "\r\n") + SendIRC(f'PONG {lline[1]}') if '433' in lline[1]: - sockChan.send("NICK " + BALT + "\r\n") - if 'PRIVMSG' in lline[1]: - if '!quit' in lline[3]: - sockChan.send("QUIT \r\n") - if '!join' in lline[3]: - sockChan.send("JOIN " + lline[4] + "\r\n") - if '!part' in lline[3]: - sockChan.send("PART " + lline[4] + "\r\n") + SendIRC(f'NICK {BotAlt}') From 4f1a2928b5f061007b070e9f8c0ee7f68513c541 Mon Sep 17 00:00:00 2001 From: ComputerTech <60820431+ComputerTech312@users.noreply.github.com> Date: Thu, 21 Oct 2021 01:58:53 +0100 Subject: [PATCH 02/15] Update config.py --- config.py | 61 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 24 deletions(-) diff --git a/config.py b/config.py index a4a5bb2..d706ef5 100644 --- a/config.py +++ b/config.py @@ -1,4 +1,4 @@ -############################################################################### +################################################# # _____ ____ _ # / ____| _ \ | | # | | | |_) | ___ | |_ @@ -14,28 +14,41 @@ ### Start of configuration ### -## Bot nick. -BNICK = "CBot" -##----------------------------------------------------------------------- -## Bot alter nick. -BALT = "CBot-" -##----------------------------------------------------------------------- -## Bot ident. -BIDENT = "CBot" -##----------------------------------------------------------------------- -## Bot realname. -BREALNAME = "CBot" -##----------------------------------------------------------------------- -## Bot server. -BSERVER = "irc.libera.chat" -##----------------------------------------------------------------------- -## Bot port. -BPORT = 6667 -##----------------------------------------------------------------------- -## Bot admin. -BADMIN = "Your-nick" -##----------------------------------------------------------------------- -## Bot channel. -BCHANNEL = "#CBot" + +### +# Bot's nick. +## +BotNick = "CBot" + +### +# Bot's alter nick. +## +BotAlt = "CBot-" + +### +# Bot's ident. +## +BotIdent = "CBot" + +### +# Bot realname. +## +BotRealName = "CBot" + +### +# Bot server. +## +BotServer = "irc.libera.chat" + +### +# Bot port. +## +BotPort = 6667 + +### +# Bot channel. +## +BotHome = "#CBot" + ### End of configuration ### From 09b5cdc1e6c9c0cc65dfa30ecb27863ef25bc3dc Mon Sep 17 00:00:00 2001 From: ComputerTech <60820431+ComputerTech312@users.noreply.github.com> Date: Thu, 21 Oct 2021 05:35:54 +0100 Subject: [PATCH 03/15] Delete config.py --- config.py | 54 ------------------------------------------------------ 1 file changed, 54 deletions(-) delete mode 100644 config.py diff --git a/config.py b/config.py deleted file mode 100644 index d706ef5..0000000 --- a/config.py +++ /dev/null @@ -1,54 +0,0 @@ -################################################# -# _____ ____ _ -# / ____| _ \ | | -# | | | |_) | ___ | |_ -# | | | _ < / _ \| __| -# | |____| |_) | (_) | |_ -# \_____|____/ \___/ \__| -# -################################################# -# Description: -# -# -################################################# - -### Start of configuration ### - - -### -# Bot's nick. -## -BotNick = "CBot" - -### -# Bot's alter nick. -## -BotAlt = "CBot-" - -### -# Bot's ident. -## -BotIdent = "CBot" - -### -# Bot realname. -## -BotRealName = "CBot" - -### -# Bot server. -## -BotServer = "irc.libera.chat" - -### -# Bot port. -## -BotPort = 6667 - -### -# Bot channel. -## -BotHome = "#CBot" - - -### End of configuration ### From eb7dc2cae6c51c23bea35dfd450a65206ee78762 Mon Sep 17 00:00:00 2001 From: ComputerTech <60820431+ComputerTech312@users.noreply.github.com> Date: Thu, 21 Oct 2021 05:36:09 +0100 Subject: [PATCH 04/15] Delete cbot.py --- cbot.py | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 cbot.py diff --git a/cbot.py b/cbot.py deleted file mode 100644 index 45d8a7c..0000000 --- a/cbot.py +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/python - -from config import * - -import socket -import sys -import string -import time - -BotNick = "CBot" -BotAlt = "CBot-" -BotIdent = "CBot" -BotRealname = "CBot" -SERVER = "irc.irchighway.net" -PORT = 6667 - - -sockChan = socket.socket(socket.AF_INET, socket.SOCK_STREAM) -sockChan.connect((SERVER, PORT)) - -def SendIRC (msg): - sockChan.send(bytes(f'{str(msg)} \r\n', 'UTF-8')) - -SendIRC(f'USER {BotIdent} * * :{BotRealname}') -SendIRC(f'NICK {BotNick}') -connected = True - -while connected: - line = sockChan.recv(2040).decode('UTF-8') - print(line) - if line != "": - lline = line.split() - if 'PING' in lline[0]: - SendIRC(f'PONG {lline[1]}') - if '433' in lline[1]: - SendIRC(f'NICK {BotAlt}') From aa662db582bf92a5c5d12a40ae4d146e119cfae8 Mon Sep 17 00:00:00 2001 From: ComputerTech <60820431+ComputerTech312@users.noreply.github.com> Date: Thu, 21 Oct 2021 05:36:20 +0100 Subject: [PATCH 05/15] Delete example.py --- Modules/example.py | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Modules/example.py diff --git a/Modules/example.py b/Modules/example.py deleted file mode 100644 index 8b13789..0000000 --- a/Modules/example.py +++ /dev/null @@ -1 +0,0 @@ - From 4f5961f8d8294d361c9f20f4e4028a337fd68aa0 Mon Sep 17 00:00:00 2001 From: ComputerTech <60820431+ComputerTech312@users.noreply.github.com> Date: Thu, 21 Oct 2021 05:37:04 +0100 Subject: [PATCH 06/15] Add files via upload --- cbot.py | 26 ++++++++++++++++++++++++++ config.py | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 cbot.py create mode 100644 config.py diff --git a/cbot.py b/cbot.py new file mode 100644 index 0000000..02a76c0 --- /dev/null +++ b/cbot.py @@ -0,0 +1,26 @@ +#!/usr/bin/python + +import socket +import sys +from config import * + +sockChan = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +sockChan.connect((SERVER, PORT)) + +def SendIRC (msg): + sockChan.send(bytes(f'{str(msg)} \r\n', 'UTF-8')) + +SendIRC(f'USER {BotIdent} * * :{BotRealname}') +SendIRC(f'NICK {BotNick}') +connected = True + +while connected: + line = sockChan.recv(2040).decode('UTF-8') + if line != "": + lline = line.split() + if 'PING' in lline[0]: + SendIRC(f'PONG {lline[1]}') + if '433' in lline[0]: + SendIRC(f'NICK {BotAlt}') + if '001' in lline[0]: + SendIRC(f'JOIN {Home}') \ No newline at end of file diff --git a/config.py b/config.py new file mode 100644 index 0000000..5af4367 --- /dev/null +++ b/config.py @@ -0,0 +1,51 @@ +################################################# +# _____ ____ _ +# / ____| _ \ | | +# | | | |_) | ___ | |_ +# | | | _ < / _ \| __| +# | |____| |_) | (_) | |_ +# \_____|____/ \___/ \__| +# +################################################# +# +# Python release. v0.1 +################################################# + +### Start of configuration ### + +### +# Bot's nick. +## +BotNick = 'CBot-Python' + +### +# Bot's alter nick. +## +BotAlt = 'CBot-Python-' + +### +# Bot's ident. +## +BotIdent = 'CBot-Python' + +### +# Bot realname. +## +BotRealname = 'CBot-Python' + +### +# Bot server. +## +BotServer = 'IRC.irchighway.net' + +### +# Bot port. +## +BotPort = 6667 + +### +# Bot channel. +## +BotHome = '#CBot' + +### End of configuration ### From b0095bcce1ab17474c77f9672c154c32b6eab817 Mon Sep 17 00:00:00 2001 From: ComputerTech <60820431+ComputerTech312@users.noreply.github.com> Date: Thu, 21 Oct 2021 07:40:01 +0100 Subject: [PATCH 07/15] update cbot.py --- cbot.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cbot.py b/cbot.py index 02a76c0..07c0d4e 100644 --- a/cbot.py +++ b/cbot.py @@ -1,11 +1,9 @@ -#!/usr/bin/python - import socket import sys -from config import * +#from config import * sockChan = socket.socket(socket.AF_INET, socket.SOCK_STREAM) -sockChan.connect((SERVER, PORT)) +sockChan.connect((BotServer, BotPort)) def SendIRC (msg): sockChan.send(bytes(f'{str(msg)} \r\n', 'UTF-8')) @@ -16,11 +14,14 @@ def SendIRC (msg): while connected: line = sockChan.recv(2040).decode('UTF-8') + prin5(line) if line != "": lline = line.split() if 'PING' in lline[0]: SendIRC(f'PONG {lline[1]}') + if '433' in lline[0]: SendIRC(f'NICK {BotAlt}') + if '001' in lline[0]: - SendIRC(f'JOIN {Home}') \ No newline at end of file + SendIRC(f'JOIN {BotHome}') \ No newline at end of file From 9aedf829fa24e37c4b09b6e162c254270dd4d25c Mon Sep 17 00:00:00 2001 From: ComputerTech <60820431+ComputerTech312@users.noreply.github.com> Date: Fri, 22 Oct 2021 01:44:45 +0100 Subject: [PATCH 08/15] Update config.py --- config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.py b/config.py index 5af4367..7b24a20 100644 --- a/config.py +++ b/config.py @@ -36,7 +36,7 @@ ### # Bot server. ## -BotServer = 'IRC.irchighway.net' +BotServer = 'irc.address.org' ### # Bot port. From 26e24579ed9d7a34c71053f5aed2a550ffa52c7b Mon Sep 17 00:00:00 2001 From: ComputerTech <60820431+ComputerTech312@users.noreply.github.com> Date: Fri, 22 Oct 2021 20:21:13 +0100 Subject: [PATCH 09/15] update config.py --- config.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/config.py b/config.py index 7b24a20..3da1dae 100644 --- a/config.py +++ b/config.py @@ -29,23 +29,28 @@ BotIdent = 'CBot-Python' ### -# Bot realname. +# Bot's realname. ## BotRealname = 'CBot-Python' ### -# Bot server. +# Bot's server. ## BotServer = 'irc.address.org' ### -# Bot port. +# Bot's port. ## BotPort = 6667 ### -# Bot channel. +# Bot's home channel. ## -BotHome = '#CBot' +BotHome = '#CBot + +### Bot +# Bot's Admin's nick. +## +BotAdmin = 'Your-nick' ### End of configuration ### From aff61ad4a47a036c926802c06f6366049d7ad239 Mon Sep 17 00:00:00 2001 From: ComputerTech <60820431+ComputerTech312@users.noreply.github.com> Date: Fri, 22 Oct 2021 23:09:55 +0100 Subject: [PATCH 10/15] update cbot.py --- cbot.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/cbot.py b/cbot.py index 07c0d4e..1135f1d 100644 --- a/cbot.py +++ b/cbot.py @@ -19,9 +19,29 @@ def SendIRC (msg): lline = line.split() if 'PING' in lline[0]: SendIRC(f'PONG {lline[1]}') - + if '433' in lline[0]: SendIRC(f'NICK {BotAlt}') if '001' in lline[0]: - SendIRC(f'JOIN {BotHome}') \ No newline at end of file + SendIRC(f'JOIN {BotHome}') + + if 'PRIVMSG' in lline[1]: + zline = lline.split('!') + zline = zline.split(':') + zline = zline.split('@') + nick = zline[0] + ident = zline[1] + host = zline[2] + targ = zline[4] + text = zline[5] + + if 'NOTICE' in lline[1]: + zline = lline.split('!') + zline = zline.split(':') + zline = zline.split('@') + nick = zline[0] + ident = zline[1] + host = zline[2] + targ = zline[4] + text = zline[5] \ No newline at end of file From 53b304cb19ec99b06eadaecd800327b71af7665a Mon Sep 17 00:00:00 2001 From: ComputerTech <60820431+ComputerTech312@users.noreply.github.com> Date: Fri, 22 Oct 2021 23:14:01 +0100 Subject: [PATCH 11/15] update cbot.py --- cbot.py | 63 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/cbot.py b/cbot.py index 1135f1d..8935d4e 100644 --- a/cbot.py +++ b/cbot.py @@ -1,6 +1,6 @@ import socket import sys -#from config import * +from config import * sockChan = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sockChan.connect((BotServer, BotPort)) @@ -12,36 +12,39 @@ def SendIRC (msg): SendIRC(f'NICK {BotNick}') connected = True -while connected: - line = sockChan.recv(2040).decode('UTF-8') - prin5(line) - if line != "": - lline = line.split() - if 'PING' in lline[0]: - SendIRC(f'PONG {lline[1]}') +def main(): + try: + while connected: + + line = sockChan.recv(2040).decode('UTF-8') + print(line) + if line != "": + lline = line.split() + if 'PING' in lline[0]: + SendIRC(f'PONG {lline[1]}') - if '433' in lline[0]: - SendIRC(f'NICK {BotAlt}') + if '433' in lline[0]: + SendIRC(f'NICK {BotAlt}') - if '001' in lline[0]: - SendIRC(f'JOIN {BotHome}') + if '001' in lline[0]: + SendIRC(f'JOIN {BotHome}') - if 'PRIVMSG' in lline[1]: - zline = lline.split('!') - zline = zline.split(':') - zline = zline.split('@') - nick = zline[0] - ident = zline[1] - host = zline[2] - targ = zline[4] - text = zline[5] + if 'PRIVMSG' in lline[1]: + zline = lline.split('!') + zline = zline.split(':') + zline = zline.split('@') + nick = zline[0] + ident = zline[1] + host = zline[2] + targ = zline[4] + text = zline[5] - if 'NOTICE' in lline[1]: - zline = lline.split('!') - zline = zline.split(':') - zline = zline.split('@') - nick = zline[0] - ident = zline[1] - host = zline[2] - targ = zline[4] - text = zline[5] \ No newline at end of file + if 'NOTICE' in lline[1]: + zline = lline.split('!') + zline = zline.split(':') + zline = zline.split('@') + nick = zline[0] + ident = zline[1] + host = zline[2] + targ = zline[4] + text = zline[5] \ No newline at end of file From 29d646040eb9f9308358825fa932efbc70862476 Mon Sep 17 00:00:00 2001 From: ComputerTech <60820431+ComputerTech312@users.noreply.github.com> Date: Fri, 22 Oct 2021 23:14:53 +0100 Subject: [PATCH 12/15] update cbot.py --- cbot.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cbot.py b/cbot.py index 8935d4e..6f11dc3 100644 --- a/cbot.py +++ b/cbot.py @@ -47,4 +47,6 @@ def main(): ident = zline[1] host = zline[2] targ = zline[4] - text = zline[5] \ No newline at end of file + text = zline[5] + +main() \ No newline at end of file From 2803783509a69a0958edb737ec5cbb1796a57bf7 Mon Sep 17 00:00:00 2001 From: ComputerTech <60820431+ComputerTech312@users.noreply.github.com> Date: Fri, 22 Oct 2021 23:19:31 +0100 Subject: [PATCH 13/15] Create weather.py --- modules/weather.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 modules/weather.py diff --git a/modules/weather.py b/modules/weather.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/modules/weather.py @@ -0,0 +1 @@ + From 9d85133ff80e12f4ae081d43344aa7f915470f05 Mon Sep 17 00:00:00 2001 From: ComputerTech <60820431+ComputerTech312@users.noreply.github.com> Date: Sat, 23 Oct 2021 00:21:27 +0100 Subject: [PATCH 14/15] Create cbot2.py --- cbot2.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 cbot2.py diff --git a/cbot2.py b/cbot2.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/cbot2.py @@ -0,0 +1 @@ + From 55d25600bcca1b996f4574a114e4ad78bfe80b32 Mon Sep 17 00:00:00 2001 From: ComputerTech <60820431+ComputerTech312@users.noreply.github.com> Date: Sat, 23 Oct 2021 00:21:57 +0100 Subject: [PATCH 15/15] update cbot2.py --- cbot2.py | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/cbot2.py b/cbot2.py index 8b13789..1d34878 100644 --- a/cbot2.py +++ b/cbot2.py @@ -1 +1,87 @@ +#!/usr/bin/python3 +# +# +import os +import sys +import time +import socket +import string +import logging +from config import * + +dirName = os.path.dirname(os.path.abspath(__file__)) +logname = f'{dirName}/{LogFileName}.log' +#handlers = [logging.FileHandler(logname), logging.StreamHandler()] +handlers = [logging.FileHandler(logname)] +logging.basicConfig( + handlers=handlers, + level=logging.DEBUG, + format='%(asctime)s %(levelname)s - %(message)s', + datefmt='%Y-%m-%d %H:%M:%S' + ) + +log = logging.getLogger() + +sockChan = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +sockChan.connect_ex((BotServer, BotPort)) + + +def sendIRC(msg): + sockChan.sendall(bytes(f'{str(msg)} \r\n', 'UTF-8')) # Send data to IRC server. + if DebugMode: + print(f'Sending to Server: {msg}') + + +def sendmsg(msg, target=BotHome): # Sends messages to the target. + sendIRC(f'PRIVMSG {target} :{msg}') + + +sendIRC(f'USER {BotIdent} * * :{BotRealName}') #Command: USER Parameters: +sendIRC(f'NICK {BotNick}') + +if BotPassword != '': + sendIRC(f'PRIVMSG NICKSERV :IDENTIFY {BotPassword}') + +connected = True + +def main(): + try: + while connected: + + line = sockChan.recv(2040).decode('utf-8') + + if DebugMode: + print(line) + + lline = line.split() + if 'PING' in lline[0]: + sendIRC(f'PONG {lline[1]}' ) + if '001' in str(lline[1]): + if BotHome != '': + sendIRC(f'JOIN {BotHome}' ) + if '433' in lline[1]: + sendIRC(f'NICK {BotAlt}' ) + + if 'PRIVMSG' in lline[1]: + if '!quit' in lline[3]: + sendIRC(f'QUIT {QuitMessage}' ) + sys.exit() + if '!join' in lline[3]: + sendIRC(f'JOIN {lline[4]}' ) + if '!part' in lline[3]: + sendIRC(f'PART {lline[4]}' ) + if '!danceBtch' in lline[3]: + sendmsg("""\(゚ー゚\) (ノ^_^)ノ(~‾▿‾)~ """) + + except Exception as iconnex: + if DebugMode: + exc_type, exc_obj, exc_tb = sys.exc_info() + fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] + print(f'Exception: {str(iconnex)}') + print(f'Failed to connect to {str(server)}:{str(port)}. Retrying in 10 seconds...') + logging.exception('\n\n\n ========================= --ERROR-- =======================================================================================================================================================================================================================================================================================================================\n ') + + + +main() \ No newline at end of file