Last active
August 29, 2022 12:11
-
-
Save researcx/d384a1384690aa96485d11490a33a2f6 to your computer and use it in GitHub Desktop.
video game style chat donate message bot, set it to automatically run on a cron
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from twisted.words.protocols import irc | |
from twisted.internet import reactor, protocol | |
from re import search, IGNORECASE | |
from random import randint | |
import time | |
import os, signal | |
serv_ip = "10.3.0.50" | |
serv_port = 6667 | |
with open('/root/DonateBot/donate.txt') as f: | |
message = f.read() | |
class DonateBot(irc.IRCClient): | |
nickname = "DonateBot" | |
chatroom = "#xch" | |
def signedOn(self): | |
self.join(self.chatroom) | |
time.sleep(2) | |
self.msg(self.chatroom, message) | |
self.part(self.chatroom) | |
time.sleep(2) | |
self.quit() | |
def quit(self, message=""): | |
self.sendLine("QUIT :%s" % message) | |
def main(): | |
f = protocol.ReconnectingClientFactory() | |
f.protocol = DonateBot | |
reactor.connectTCP(serv_ip, serv_port, f) | |
reactor.run() | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment