一个简单有效的事件处理程序类,基于Python3的回调

eventhandler的Python项目详细描述


事件处理程序

是一个基于python3回调的简单有效的事件处理程序类。在

生成状态:

Build StatusCoverage StatusPypiPython package and publish

Github代码和示例https://github.com/davidvicenteranz/eventhandler

快速启动

安装程序包

$ pip install eventhandler

使用示例

让我们看一个由bot使用事件调用控制的聊天室的简单示例。在

您只需将下一个代码保存到一个文件中,然后运行python3来执行它文件名.py在

^{pr2}$

avobe代码必须生成并输出以下内容:

Chatroom's EventHandler object representation...
<class EventHandler at 0x10da97760: onNewuser:[__on_newuser_join, saludate_new_user], onMessage:[__on_message, read_user_message], verbose=False, tolerate_exceptions=False>


** ChatRoom info ** user sergio has joined the chat ** 1 user/s **

bot says:      Hello sergio, welcome to the chat room.
sergio says:   Hello World!
sergio says:   Hey bot, are there anyone here?
bot says:      Nope sergio. Just you and me.

** ChatRoom info ** user david has joined the chat ** 2 user/s **

bot says:      Hello david, welcome to the chat room.
david says:    Hello everybody!
david says:    Hey bot, are there anyone here?
bot says:      Yes david. there are 1 non bots users in the room, you, and me.
sergio says:   Hi david!

** ChatRoom info ** user kate has joined the chat ** 3 user/s **

bot says:      Hello kate, welcome to the chat room.
kate says:     Hey bot, are there anyone here?
bot says:      Yes kate. there are 2 non bots users in the room, you, and me.

感谢您的收看和欣赏。

David Vicente Ranz编写、测试和包装

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java@AfterEach注释在Spring测试中被忽略   散列如何使用bouncy castle在Java中创建SHA512摘要字符串?   java无法使用Okhttp获取响应cookie   100个数的java阶乘   多线程如何在Java中实现对象计数器   java我的精灵不显示背景   java如何在com上应用PanelSlideListener。索特里。滑动面板。SlidengUpPanelLayout SlideUp库   java如何在JDBC中使用WHERE EXISTS函数   java Swing:标签前景中的白色被绘制为黑色   获取java的时间戳。util。另一个java的日期对象为(10/7/14)。util。日期对象(2014年10月7日星期二11:21:00)   java如何在Spring/OpenJPA 1中重新创建用于更新行锁定的选择   java在保存另一个maven项目中的类时,有没有办法让eclipse识别对该类的更改?   java如何解决Spring中的Servlet上下文错误?   java在mongodb中删除记录   显示的java片段与当前片段重叠,而不是替换它