12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- """
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- """
- from matrix_bot_api.matrix_bot_api import MatrixBotAPI
- from matrix_bot_api.mregex_handler import MRegexHandler
- from matrix_bot_api.mcommand_handler import MCommandHandler
- import time
- import sys
- USERNAME = "theemacsshibe" # Bot's username
- PASSWORD = "get your own lol" # Bot's password
- SERVER = "https://disroot.org" # Matrix server URL
- def check_e(room, event):
- try:
- print("got a fifthglyph!")
- r = event["content"]["body"].replace("e","_").replace("E","_")
- if r.replace("_","") == "":
- room.send_text("{}, that wasn't funny.".format(event["sender"]))
- else:
- room.send_text("{}: Your last post contains fifthglyphs: \"{}\"".format(event["sender"], r))
- except Exception as e:
- print(e.message)
- pass
- def main():
- print("Connecting...")
- bot = MatrixBotAPI(USERNAME, PASSWORD, SERVER)
- e_handler = MRegexHandler("(?i)e", check_e)
- bot.add_handler(e_handler)
- print("Starting polling...")
- bot.start_polling()
- while True:
- time.sleep(1)
- if __name__ == "__main__":
- main()
|